선버스트 차트

선버스트 차트는 계층 구조 데이터를 표시하는 데 이상적입니다. 계층 구조의 각 수준은 가장 안쪽에 있는 원을 계층 구조의 최상위 수준으로 하는 하나의 링 또는 원으로 표시됩니다. 계층 구조 데이터가 없는 선버스트 차트(1개의 범주 수준)는 도넛형 차트와 모습이 유사합니다. 이와 다르게 범주 수준이 여러 개인 선버스트 차트는 외부 링이 내부 링과 어떤 관련성을 갖고 있는지를 보여줍니다. 선버스트 차트는 하나의 링이 관련성을 가진 여러 요소로 분류되는 방법을 보여주는 데 가장 효과적입니다.

SpreadJS는 선버스트 차트를 지원합니다. 차트 유형을 가져오려면 GC.Spread.Sheets.Charts.ChartType.sunburst 속성을 사용하십시오. Spread에 선버스트 차트를 추가하고 차트 API를 사용하여 스타일을 변경할 수 있습니다..
import * as React from 'react'; import * as ReactDOM from 'react-dom'; import './styles.css'; import { AppFunc } from './app-func'; // import { App } from './app-class'; // 1. Functional Component sample ReactDOM.render(<AppFunc />, document.getElementById('app')); // 2. Class Component sample // ReactDOM.render(<App />, document.getElementById('app'));
import * as React from 'react'; import GC from '@mescius/spread-sheets'; import { SpreadSheets, Worksheet } from '@mescius/spread-sheets-react'; import '@mescius/spread-sheets-shapes'; import '@mescius/spread-sheets-charts'; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); export function AppFunc() { const 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(); } const _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]); } } } const initSunburst = (sheet, chartType, chartName) => { sheet.resumePaint(); return sheet.charts.add(chartName, chartType, 450, 0, 400, 400, "B2:E18"); } const _setChartArea = (chart) => { let area = chart.chartArea(); area.backColor = '#fff'; area.backColorTransparency = 0; area.color = '#000' chart.chartArea(area) } const _setTitle = (chart) => { let title = chart.title(); title.text = 'World Population'; chart.title(title); } const _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); }) } const _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); } return (<div class="sample-tutorial"> <div class="sample-spreadsheets"> <SpreadSheets workbookInitialized={spread => initSpread(spread)}> <Worksheet /> <Worksheet /> </SpreadSheets> </div> </div>); }
import * as React from 'react'; import GC from '@mescius/spread-sheets'; import { SpreadSheets, Worksheet } from '@mescius/spread-sheets-react'; import '@mescius/spread-sheets-shapes'; import '@mescius/spread-sheets-charts'; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); const Component = React.Component; export class App extends Component { constructor(props) { super(props); this.spread = null; } render() { return (<div class="sample-tutorial"> <div class="sample-spreadsheets"> <SpreadSheets workbookInitialized={spread => this.initSpread(spread)}> <Worksheet /> <Worksheet /> </SpreadSheets> </div> </div>); } initSpread(spread) { let sheets = spread.sheets; spread.suspendPaint(); // custom sheets style this._setSheet(sheets); this._setData(sheets[0], 'sunburstChart'); this.initSunburst(sheets[0], GC.Spread.Sheets.Charts.ChartType.sunburst, 'sunburstChart'); this._setData(sheets[1], 'customStyle'); let customSunburstChart = this.initSunburst(sheets[1], GC.Spread.Sheets.Charts.ChartType.sunburst, 'customStyle Chart'); // custom sunburst chart style this._setChartArea(customSunburstChart); this._setTitle(customSunburstChart); this._setDataPoints(customSunburstChart); spread.resumePaint(); } _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]); } } } initSunburst(sheet, chartType, chartName) { sheet.resumePaint(); return sheet.charts.add(chartName, chartType, 450, 0, 400, 400, "B2:E18"); } _setChartArea(chart) { let area = chart.chartArea(); area.backColor = '#fff'; area.backColorTransparency = 0; area.color = '#000' chart.chartArea(area) } _setTitle(chart) { let title = chart.title(); title.text = 'World Population'; chart.title(title); } _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); }) } _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); } }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/react/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- SystemJS --> <script src="$DEMOROOT$/ko/react/node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('$DEMOROOT$/ko/lib/react/license.js').then(function () { System.import('./src/app'); }); </script> </head> <body> <div id="app"></div> </body> </html>
.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%; }
(function (global) { System.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true, react: true }, meta: { '*.css': { loader: 'css' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { '@mescius/spread-sheets-shapes': 'npm:@mescius/spread-sheets-shapes/index.js', '@mescius/spread-sheets-charts': 'npm:@mescius/spread-sheets-charts/index.js', '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js', '@mescius/spread-sheets-react': 'npm:@mescius/spread-sheets-react/index.js', '@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js', 'react': 'npm:react/umd/react.production.min.js', 'react-dom': 'npm:react-dom/umd/react-dom.production.min.js', 'css': 'npm:systemjs-plugin-css/css.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', 'systemjs-babel-build':'npm:systemjs-plugin-babel/systemjs-babel-browser.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'jsx' }, "node_modules": { defaultExtension: 'js' }, } }); })(this);