Sunburst Chart

The sunburst chart is ideal for displaying hierarchical data. Each level of the hierarchy is represented by one ring or circle with the innermost circle as the top of the hierarchy. A sunburst chart without any hierarchical data (one level of categories), looks similar to a doughnut chart. However, a sunburst chart with multiple levels of categories shows how the outer rings relate to the inner rings. The sunburst chart is most effective at showing how one ring is broken into its contributing pieces.

Description
app.vue
index.html
Copy to CodeMine

SpreadJS supports sunburst chart. Use the GC.Spread.Sheets.Charts.ChartType.sunburst property to get the chart type.

You can add a sunburst chart to Spread and change its style using the chart API.

     var chart = sheet.charts.add('line', GC.Spread.Sheets.Charts.ChartType.sunburst, 0, 200, 400, 400, 'A1:D17')
     var title = chart.title()
     title.text = 'DEMO';
     chart.title(title);
SpreadJS supports sunburst chart. Use the GC.Spread.Sheets.Charts.ChartType.sunburst property to get the chart type. You can add a sunburst chart to Spread and change its style using the chart API.
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> <gc-worksheet /> <gc-worksheet /> </gc-spread-sheets> </div> </template> <script setup> import GC from "@mescius/spread-sheets"; import { ref } from "vue"; import "@mescius/spread-sheets-vue"; import "@mescius/spread-sheets-charts"; const spreadRef = ref(null); function initSpread(spread) { let sheets = spread.sheets; spread.suspendPaint(); // custom sheets style _setSheet(sheets); _setData(sheets[0], 'sunburstChart'); initSunburst(sheets[0], GC.Spread.Sheets.Charts.ChartType.sunburst, 'sunburstChart'); _setData(sheets[1], 'customStyle'); let customSunburstChart = initSunburst(sheets[1], GC.Spread.Sheets.Charts.ChartType.sunburst, 'customStyle Chart'); // custom sunburst chart style _setChartArea(customSunburstChart); _setTitle(customSunburstChart); _setDataPoints(customSunburstChart); spread.resumePaint(); } function _setSheet(sheets) { let columnWidths = [20, 70, 100, 80, 120]; for (let i = 0; i < sheets.length; i++) { sheets[i].options.gridline.showHorizontalGridline = false; sheets[i].options.gridline.showVerticalGridline = false; sheets[i].getRange(1, 1, 17, 4) .hAlign(GC.Spread.Sheets.HorizontalAlign.center) .setBorder(new GC.Spread.Sheets.LineBorder('black', GC.Spread.Sheets.LineStyle.thin), { all: true }); sheets[i].getRange(1, 1, 1, 4).font('bold normal 10pt Arial'); for (let j = 0; j < columnWidths.length; j++) { sheets[i].setColumnWidth(j, columnWidths[j]); } } } function initSunburst(sheet, chartType, chartName) { sheet.resumePaint(); return sheet.charts.add(chartName, chartType, 450, 0, 400, 400, "B2:E18"); } function _setChartArea(chart) { let area = chart.chartArea(); area.backColor = '#fff'; area.backColorTransparency = 0; area.color = '#000' chart.chartArea(area) } function _setTitle(chart) { let title = chart.title(); title.text = 'World Population'; chart.title(title); } function _setDataPoints(chart) { let dataPoints = chart.series().dataPoints(); let fillColors = ['#4472c4', '#a5a5a5', '#ffc000', '#ed7d31']; fillColors.forEach(function (color, index) { let dataPoint = dataPoints.get(index); dataPoint.fillColor = color; dataPoint.transparency = 0; // 0~1 dataPoints.set(index, dataPoint); }) } function _setData(sheet, sheetName) { sheet.name(sheetName); sheet.suspendPaint(); let dataArray = [ ['Region', 'Subregion', 'country', 'Population'], ['Asia', 'Southern', 'India', 1354051854], [, , 'Pakistan', 200813818], [, , 'Bangladesh', 166368149], [, , 'Others', 170220300], [, 'Eastern', 'China', 1415045928], [, , 'Japan', 127185332], [, , 'Others', 111652273], [, 'South-Eastern', , 655636576], [, 'Western', , 272298399], [, 'Central', , 71860465], ['Africa', 'Eastern', , 433643132], [, 'Western', , 381980688], [, 'Northern', , 237784677], [, 'Others', , 234512021], ['Europe', , , 742648010], ['Others', , , 1057117703] ]; sheet.setArray(1, 1, dataArray); } </script> <style scoped> .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: 100%; height: 100%; overflow: hidden; float: left; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } #app { height: 100%; } </style>
<!DOCTYPE html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>SpreadJS VUE</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/en/vue3/node_modules/systemjs/dist/system.src.js"></script> <script src="./systemjs.config.js"></script> <script src="./compiler.js" type="module"></script> <script> var System = SystemJS; System.import("./src/app.js"); System.import('$DEMOROOT$/en/lib/vue3/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
(function (global) { SystemJS.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, packageConfigPaths: [ './node_modules/*/package.json', "./node_modules/@mescius/*/package.json", "./node_modules/@babel/*/package.json", "./node_modules/@vue/*/package.json" ], map: { 'vue': "npm:vue/dist/vue.esm-browser.js", 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js", '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-en': 'npm:@mescius/spread-sheets-resources-en/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js', '@mescius/spread-sheets-shapes': 'npm:@mescius/spread-sheets-shapes/index.js', '@mescius/spread-sheets-charts': 'npm:@mescius/spread-sheets-charts/index.js', }, meta: { '*.css': { loader: 'systemjs-plugin-css' }, '*.vue': { loader: "../plugin-vue/index.js" } } }); })(this);