@techie_doubts/tui.chart.2026 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -0
- package/dist/esm/animator.d.ts +32 -0
- package/dist/esm/animator.js +102 -0
- package/dist/esm/brushes/axis.d.ts +3 -0
- package/dist/esm/brushes/axis.js +21 -0
- package/dist/esm/brushes/basic.d.ts +9 -0
- package/dist/esm/brushes/basic.js +95 -0
- package/dist/esm/brushes/boxPlot.d.ts +2 -0
- package/dist/esm/brushes/boxPlot.js +22 -0
- package/dist/esm/brushes/circleLegend.d.ts +2 -0
- package/dist/esm/brushes/circleLegend.js +26 -0
- package/dist/esm/brushes/dataLabel.d.ts +6 -0
- package/dist/esm/brushes/dataLabel.js +176 -0
- package/dist/esm/brushes/exportMenu.d.ts +2 -0
- package/dist/esm/brushes/exportMenu.js +55 -0
- package/dist/esm/brushes/gauge.d.ts +2 -0
- package/dist/esm/brushes/gauge.js +39 -0
- package/dist/esm/brushes/label.d.ts +34 -0
- package/dist/esm/brushes/label.js +165 -0
- package/dist/esm/brushes/legend.d.ts +7 -0
- package/dist/esm/brushes/legend.js +162 -0
- package/dist/esm/brushes/lineSeries.d.ts +5 -0
- package/dist/esm/brushes/lineSeries.js +41 -0
- package/dist/esm/brushes/polygon.d.ts +2 -0
- package/dist/esm/brushes/polygon.js +24 -0
- package/dist/esm/brushes/resetButton.d.ts +3 -0
- package/dist/esm/brushes/resetButton.js +112 -0
- package/dist/esm/brushes/scatterSeries.d.ts +2 -0
- package/dist/esm/brushes/scatterSeries.js +125 -0
- package/dist/esm/brushes/sector.d.ts +2 -0
- package/dist/esm/brushes/sector.js +54 -0
- package/dist/esm/brushes/spectrumLegend.d.ts +14 -0
- package/dist/esm/brushes/spectrumLegend.js +199 -0
- package/dist/esm/charts/areaChart.d.ts +254 -0
- package/dist/esm/charts/areaChart.js +358 -0
- package/dist/esm/charts/barChart.d.ts +203 -0
- package/dist/esm/charts/barChart.js +300 -0
- package/dist/esm/charts/boxPlotChart.d.ts +209 -0
- package/dist/esm/charts/boxPlotChart.js +288 -0
- package/dist/esm/charts/bubbleChart.d.ts +188 -0
- package/dist/esm/charts/bubbleChart.js +263 -0
- package/dist/esm/charts/bulletChart.d.ts +199 -0
- package/dist/esm/charts/bulletChart.js +278 -0
- package/dist/esm/charts/chart.d.ts +133 -0
- package/dist/esm/charts/chart.js +484 -0
- package/dist/esm/charts/columnChart.d.ts +205 -0
- package/dist/esm/charts/columnChart.js +299 -0
- package/dist/esm/charts/columnLineChart.d.ts +271 -0
- package/dist/esm/charts/columnLineChart.js +386 -0
- package/dist/esm/charts/gaugeChart.d.ts +191 -0
- package/dist/esm/charts/gaugeChart.js +279 -0
- package/dist/esm/charts/heatmapChart.d.ts +199 -0
- package/dist/esm/charts/heatmapChart.js +292 -0
- package/dist/esm/charts/lineAreaChart.d.ts +271 -0
- package/dist/esm/charts/lineAreaChart.js +374 -0
- package/dist/esm/charts/lineChart.d.ts +253 -0
- package/dist/esm/charts/lineChart.js +360 -0
- package/dist/esm/charts/lineScatterChart.d.ts +200 -0
- package/dist/esm/charts/lineScatterChart.js +285 -0
- package/dist/esm/charts/nestedPieChart.d.ts +192 -0
- package/dist/esm/charts/nestedPieChart.js +268 -0
- package/dist/esm/charts/pieChart.d.ts +156 -0
- package/dist/esm/charts/pieChart.js +224 -0
- package/dist/esm/charts/radarChart.d.ts +169 -0
- package/dist/esm/charts/radarChart.js +240 -0
- package/dist/esm/charts/radialBarChart.d.ts +172 -0
- package/dist/esm/charts/radialBarChart.js +251 -0
- package/dist/esm/charts/scatterChart.d.ts +184 -0
- package/dist/esm/charts/scatterChart.js +279 -0
- package/dist/esm/charts/treemapChart.d.ts +166 -0
- package/dist/esm/charts/treemapChart.js +239 -0
- package/dist/esm/component/areaSeries.d.ts +96 -0
- package/dist/esm/component/areaSeries.js +474 -0
- package/dist/esm/component/axis.d.ts +40 -0
- package/dist/esm/component/axis.js +176 -0
- package/dist/esm/component/axisTitle.d.ts +25 -0
- package/dist/esm/component/axisTitle.js +67 -0
- package/dist/esm/component/axisUsingCenterY.d.ts +32 -0
- package/dist/esm/component/axisUsingCenterY.js +175 -0
- package/dist/esm/component/backButton.d.ts +13 -0
- package/dist/esm/component/backButton.js +26 -0
- package/dist/esm/component/background.d.ts +10 -0
- package/dist/esm/component/background.js +15 -0
- package/dist/esm/component/boxPlotSeries.d.ts +126 -0
- package/dist/esm/component/boxPlotSeries.js +410 -0
- package/dist/esm/component/boxSeries.d.ts +211 -0
- package/dist/esm/component/boxSeries.js +603 -0
- package/dist/esm/component/boxStackSeries.d.ts +62 -0
- package/dist/esm/component/boxStackSeries.js +447 -0
- package/dist/esm/component/bubbleSeries.d.ts +35 -0
- package/dist/esm/component/bubbleSeries.js +174 -0
- package/dist/esm/component/bulletSeries.d.ts +89 -0
- package/dist/esm/component/bulletSeries.js +392 -0
- package/dist/esm/component/circleLegend.d.ts +10 -0
- package/dist/esm/component/circleLegend.js +37 -0
- package/dist/esm/component/component.d.ts +64 -0
- package/dist/esm/component/component.js +170 -0
- package/dist/esm/component/componentManager.d.ts +23 -0
- package/dist/esm/component/componentManager.js +45 -0
- package/dist/esm/component/dataLabels.d.ts +23 -0
- package/dist/esm/component/dataLabels.js +134 -0
- package/dist/esm/component/exportMenu.d.ts +38 -0
- package/dist/esm/component/exportMenu.js +147 -0
- package/dist/esm/component/gaugeSeries.d.ts +160 -0
- package/dist/esm/component/gaugeSeries.js +447 -0
- package/dist/esm/component/heatmapSeries.d.ts +64 -0
- package/dist/esm/component/heatmapSeries.js +152 -0
- package/dist/esm/component/hoveredSeries.d.ts +27 -0
- package/dist/esm/component/hoveredSeries.js +95 -0
- package/dist/esm/component/legend.d.ts +26 -0
- package/dist/esm/component/legend.js +149 -0
- package/dist/esm/component/lineSeries.d.ts +69 -0
- package/dist/esm/component/lineSeries.js +319 -0
- package/dist/esm/component/noDataText.d.ts +9 -0
- package/dist/esm/component/noDataText.js +31 -0
- package/dist/esm/component/pieSeries.d.ts +137 -0
- package/dist/esm/component/pieSeries.js +390 -0
- package/dist/esm/component/plot.d.ts +37 -0
- package/dist/esm/component/plot.js +163 -0
- package/dist/esm/component/radarSeries.d.ts +85 -0
- package/dist/esm/component/radarSeries.js +222 -0
- package/dist/esm/component/radialAxis.d.ts +26 -0
- package/dist/esm/component/radialAxis.js +210 -0
- package/dist/esm/component/radialBarSeries.d.ts +111 -0
- package/dist/esm/component/radialBarSeries.js +349 -0
- package/dist/esm/component/radialPlot.d.ts +55 -0
- package/dist/esm/component/radialPlot.js +188 -0
- package/dist/esm/component/rangeSelection.d.ts +61 -0
- package/dist/esm/component/rangeSelection.js +150 -0
- package/dist/esm/component/resetButton.d.ts +13 -0
- package/dist/esm/component/resetButton.js +26 -0
- package/dist/esm/component/scatterSeries.d.ts +34 -0
- package/dist/esm/component/scatterSeries.js +159 -0
- package/dist/esm/component/selectedSeries.d.ts +26 -0
- package/dist/esm/component/selectedSeries.js +109 -0
- package/dist/esm/component/spectrumLegend.d.ts +15 -0
- package/dist/esm/component/spectrumLegend.js +76 -0
- package/dist/esm/component/title.d.ts +12 -0
- package/dist/esm/component/title.js +53 -0
- package/dist/esm/component/tooltip.d.ts +41 -0
- package/dist/esm/component/tooltip.js +131 -0
- package/dist/esm/component/treemapSeries.d.ts +57 -0
- package/dist/esm/component/treemapSeries.js +191 -0
- package/dist/esm/component/zeroAxis.d.ts +9 -0
- package/dist/esm/component/zeroAxis.js +49 -0
- package/dist/esm/eventEmitter.d.ts +8 -0
- package/dist/esm/eventEmitter.js +15 -0
- package/dist/esm/helpers/arrayUtil.d.ts +10 -0
- package/dist/esm/helpers/arrayUtil.js +54 -0
- package/dist/esm/helpers/axes.d.ts +67 -0
- package/dist/esm/helpers/axes.js +345 -0
- package/dist/esm/helpers/boxSeries.d.ts +5 -0
- package/dist/esm/helpers/boxSeries.js +71 -0
- package/dist/esm/helpers/calculator.d.ts +19 -0
- package/dist/esm/helpers/calculator.js +153 -0
- package/dist/esm/helpers/color.d.ts +153 -0
- package/dist/esm/helpers/color.js +218 -0
- package/dist/esm/helpers/colorSpectrum.d.ts +5 -0
- package/dist/esm/helpers/colorSpectrum.js +17 -0
- package/dist/esm/helpers/coordinate.d.ts +9 -0
- package/dist/esm/helpers/coordinate.js +51 -0
- package/dist/esm/helpers/dataLabels.d.ts +36 -0
- package/dist/esm/helpers/dataLabels.js +405 -0
- package/dist/esm/helpers/dom.d.ts +2 -0
- package/dist/esm/helpers/dom.js +8 -0
- package/dist/esm/helpers/downloader.d.ts +7 -0
- package/dist/esm/helpers/downloader.js +287 -0
- package/dist/esm/helpers/formatDate.d.ts +16 -0
- package/dist/esm/helpers/formatDate.js +140 -0
- package/dist/esm/helpers/geometric.d.ts +3 -0
- package/dist/esm/helpers/geometric.js +35 -0
- package/dist/esm/helpers/googleAnalytics.d.ts +1 -0
- package/dist/esm/helpers/googleAnalytics.js +39 -0
- package/dist/esm/helpers/htmlSanitizer.d.ts +1 -0
- package/dist/esm/helpers/htmlSanitizer.js +86 -0
- package/dist/esm/helpers/legend.d.ts +9 -0
- package/dist/esm/helpers/legend.js +47 -0
- package/dist/esm/helpers/pieSeries.d.ts +15 -0
- package/dist/esm/helpers/pieSeries.js +72 -0
- package/dist/esm/helpers/plot.d.ts +2 -0
- package/dist/esm/helpers/plot.js +4 -0
- package/dist/esm/helpers/radarSeries.d.ts +1 -0
- package/dist/esm/helpers/radarSeries.js +7 -0
- package/dist/esm/helpers/range.d.ts +6 -0
- package/dist/esm/helpers/range.js +16 -0
- package/dist/esm/helpers/responders.d.ts +37 -0
- package/dist/esm/helpers/responders.js +197 -0
- package/dist/esm/helpers/sector.d.ts +55 -0
- package/dist/esm/helpers/sector.js +117 -0
- package/dist/esm/helpers/squarifier.d.ts +8 -0
- package/dist/esm/helpers/squarifier.js +110 -0
- package/dist/esm/helpers/style.d.ts +14 -0
- package/dist/esm/helpers/style.js +48 -0
- package/dist/esm/helpers/theme.d.ts +58 -0
- package/dist/esm/helpers/theme.js +557 -0
- package/dist/esm/helpers/tooltip.d.ts +2 -0
- package/dist/esm/helpers/tooltip.js +18 -0
- package/dist/esm/helpers/tooltipTemplate.d.ts +21 -0
- package/dist/esm/helpers/tooltipTemplate.js +147 -0
- package/dist/esm/helpers/utils.d.ts +42 -0
- package/dist/esm/helpers/utils.js +268 -0
- package/dist/esm/helpers/validation.d.ts +6 -0
- package/dist/esm/helpers/validation.js +16 -0
- package/dist/esm/index.d.ts +40 -0
- package/dist/esm/index.js +75 -0
- package/dist/esm/message.d.ts +11 -0
- package/dist/esm/message.js +11 -0
- package/dist/esm/painter.d.ts +27 -0
- package/dist/esm/painter.js +88 -0
- package/dist/esm/responderDetectors.d.ts +6 -0
- package/dist/esm/responderDetectors.js +124 -0
- package/dist/esm/scale/coordinateScaleCalculator.d.ts +24 -0
- package/dist/esm/scale/coordinateScaleCalculator.js +174 -0
- package/dist/esm/scale/datetimeScaleCalculator.d.ts +20 -0
- package/dist/esm/scale/datetimeScaleCalculator.js +59 -0
- package/dist/esm/store/axes.d.ts +30 -0
- package/dist/esm/store/axes.js +282 -0
- package/dist/esm/store/category.d.ts +4 -0
- package/dist/esm/store/category.js +73 -0
- package/dist/esm/store/colorValueScale.d.ts +3 -0
- package/dist/esm/store/colorValueScale.js +56 -0
- package/dist/esm/store/dataRange.d.ts +4 -0
- package/dist/esm/store/dataRange.js +170 -0
- package/dist/esm/store/gaugeAxes.d.ts +4 -0
- package/dist/esm/store/gaugeAxes.js +175 -0
- package/dist/esm/store/heatmapAxes.d.ts +3 -0
- package/dist/esm/store/heatmapAxes.js +98 -0
- package/dist/esm/store/heatmapSeriesData.d.ts +3 -0
- package/dist/esm/store/heatmapSeriesData.js +34 -0
- package/dist/esm/store/layout.d.ts +12 -0
- package/dist/esm/store/layout.js +487 -0
- package/dist/esm/store/legend.d.ts +3 -0
- package/dist/esm/store/legend.js +435 -0
- package/dist/esm/store/nestedPieSeriesData.d.ts +3 -0
- package/dist/esm/store/nestedPieSeriesData.js +49 -0
- package/dist/esm/store/options.d.ts +3 -0
- package/dist/esm/store/options.js +62 -0
- package/dist/esm/store/plot.d.ts +3 -0
- package/dist/esm/store/plot.js +102 -0
- package/dist/esm/store/radialAxes.d.ts +8 -0
- package/dist/esm/store/radialAxes.js +199 -0
- package/dist/esm/store/reactive.d.ts +11 -0
- package/dist/esm/store/reactive.js +196 -0
- package/dist/esm/store/root.d.ts +3 -0
- package/dist/esm/store/root.js +46 -0
- package/dist/esm/store/scale.d.ts +3 -0
- package/dist/esm/store/scale.js +102 -0
- package/dist/esm/store/seriesData.d.ts +3 -0
- package/dist/esm/store/seriesData.js +299 -0
- package/dist/esm/store/stackSeriesData.d.ts +8 -0
- package/dist/esm/store/stackSeriesData.js +192 -0
- package/dist/esm/store/store.d.ts +20 -0
- package/dist/esm/store/store.js +112 -0
- package/dist/esm/store/theme.d.ts +3 -0
- package/dist/esm/store/theme.js +139 -0
- package/dist/esm/store/treemapSeriesData.d.ts +4 -0
- package/dist/esm/store/treemapSeriesData.js +93 -0
- package/dist/td-chart.css +127 -0
- package/dist/td-chart.js +41463 -0
- package/dist/td-chart.min.css +6 -0
- package/dist/td-chart.min.js +9 -0
- package/package.json +112 -0
- package/types/brushes.d.ts +30 -0
- package/types/charts.d.ts +152 -0
- package/types/components/axis.d.ts +71 -0
- package/types/components/circleLegend.d.ts +9 -0
- package/types/components/dataLabels.d.ts +119 -0
- package/types/components/exportMenu.d.ts +14 -0
- package/types/components/legend.d.ts +27 -0
- package/types/components/plot.d.ts +8 -0
- package/types/components/radialAxis.d.ts +22 -0
- package/types/components/radialPlot.d.ts +11 -0
- package/types/components/rangeSelection.d.ts +3 -0
- package/types/components/resetButton.d.ts +13 -0
- package/types/components/series.d.ts +386 -0
- package/types/components/spectrumLegend.d.ts +25 -0
- package/types/components/tooltip.d.ts +58 -0
- package/types/components/zoom.d.ts +3 -0
- package/types/eventEmitter.d.ts +12 -0
- package/types/index.d.ts +615 -0
- package/types/options.d.ts +833 -0
- package/types/resizeObserver.d.ts +54 -0
- package/types/store/store.d.ts +564 -0
- package/types/theme.d.ts +670 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import Chart from "./chart";
|
|
2
|
+
import nestedPieSeriesData from "../store/nestedPieSeriesData";
|
|
3
|
+
import Tooltip from "../component/tooltip";
|
|
4
|
+
import Legend from "../component/legend";
|
|
5
|
+
import Title from "../component/title";
|
|
6
|
+
import ExportMenu from "../component/exportMenu";
|
|
7
|
+
import HoveredSeries from "../component/hoveredSeries";
|
|
8
|
+
import DataLabels from "../component/dataLabels";
|
|
9
|
+
import SelectedSeries from "../component/selectedSeries";
|
|
10
|
+
import Background from "../component/background";
|
|
11
|
+
import PieSeries from "../component/pieSeries";
|
|
12
|
+
import NoDataText from "../component/noDataText";
|
|
13
|
+
import * as basicBrush from "../brushes/basic";
|
|
14
|
+
import * as legendBrush from "../brushes/legend";
|
|
15
|
+
import * as labelBrush from "../brushes/label";
|
|
16
|
+
import * as exportMenuBrush from "../brushes/exportMenu";
|
|
17
|
+
import * as sectorBrush from "../brushes/sector";
|
|
18
|
+
import * as dataLabelBrush from "../brushes/dataLabel";
|
|
19
|
+
/**
|
|
20
|
+
* @class
|
|
21
|
+
* @classdesc NestedPie Chart
|
|
22
|
+
* @param {Object} props
|
|
23
|
+
* @param {HTMLElement} props.el - The target element to create chart.
|
|
24
|
+
* @param {Object} props.data - Data for making NestedPie Chart.
|
|
25
|
+
* @param {Array<string>} [props.data.categories] - Categories.
|
|
26
|
+
* @param {Array<Object>} props.data.series - Series data.
|
|
27
|
+
* @param {string} props.data.series.name - Series name.
|
|
28
|
+
* @param {number} props.data.series.data - Series data.
|
|
29
|
+
* @param {string} [props.data.series.parentName] - Value specifying parent data when using group nested pie chart.
|
|
30
|
+
* @param {Object} [props.options] - Options for making NestedPie Chart.
|
|
31
|
+
* @param {Object} [props.options.chart]
|
|
32
|
+
* @param {string|Object} [props.options.chart.title] - Chart title text or options.
|
|
33
|
+
* @param {string} [props.options.chart.title.text] - Chart title text.
|
|
34
|
+
* @param {number} [props.options.chart.title.offsetX] - Offset value to move title horizontally.
|
|
35
|
+
* @param {number} [props.options.chart.title.offsetY] - Offset value to move title vertically.
|
|
36
|
+
* @param {string} [props.options.chart.title.align] - Chart text align. 'left', 'right', 'center' is available.
|
|
37
|
+
* @param {boolean|Object} [props.options.chart.animation] - Whether to use animation and duration when rendering the initial chart.
|
|
38
|
+
* @param {number|string} [props.options.chart.width] - Chart width. 'auto' or if not write, the width of the parent container is followed. 'auto' or if not created, the width of the parent container is followed.
|
|
39
|
+
* @param {number|string} [props.options.chart.height] - Chart height. 'auto' or if not write, the width of the parent container is followed. 'auto' or if not created, the height of the parent container is followed.
|
|
40
|
+
* @param {Object} [props.options.series]
|
|
41
|
+
* @param {boolean} [props.options.series.selectable=false] - Whether to make selectable series or not.
|
|
42
|
+
* @param {Object} [props.options.series.dataLabels] - Set the visibility, location, and formatting of dataLabel. For specific information, refer to the {@link https://github.com/nhn/tui.chart|DataLabels guide} on github.
|
|
43
|
+
* @param {Object} [props.options.series.aliasName] - Chart options are specified based on the alias name. 'radiusRange', 'angleRange', 'clockwise', 'dataLabels' is available. For specific information, refer to the {@link https://github.com/nhn/tui.chart|NestedPie Chart guide} on github.
|
|
44
|
+
* @param {Object} [props.options.legend]
|
|
45
|
+
* @param {string} [props.options.legend.align] - Legend align. 'top', 'bottom', 'right', 'left' is available.
|
|
46
|
+
* @param {string} [props.options.legend.showCheckbox] - Whether to show checkbox.
|
|
47
|
+
* @param {boolean} [props.options.legend.visible] - Whether to show legend.
|
|
48
|
+
* @param {number} [props.options.legend.width] - Width of legend.
|
|
49
|
+
* @param {Object} [props.options.legend.item] - `width` and `overflow` options of the legend item. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Legend guide} on github.
|
|
50
|
+
* @param {Object} [props.options.exportMenu]
|
|
51
|
+
* @param {boolean} [props.options.exportMenu.visible] - Whether to show export menu.
|
|
52
|
+
* @param {string} [props.options.exportMenu.filename] - File name applied when downloading.
|
|
53
|
+
* @param {Object} [props.options.tooltip]
|
|
54
|
+
* @param {number} [props.options.tooltip.offsetX] - Offset value to move title horizontally.
|
|
55
|
+
* @param {number} [props.options.tooltip.offsetY] - Offset value to move title vertically.
|
|
56
|
+
* @param {Function} [props.options.tooltip.formatter] - Function to format data value.
|
|
57
|
+
* @param {Function} [props.options.tooltip.template] - Function to create custom template. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Tooltip guide} on github.
|
|
58
|
+
* @param {Object} [props.options.responsive] - Rules for changing chart options. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Responsive guide} on github.
|
|
59
|
+
* @param {boolean|Object} [props.options.responsive.animation] - Animation duration when the chart is modified.
|
|
60
|
+
* @param {Array<Object>} [props.options.responsive.rules] - Rules for the Chart to Respond.
|
|
61
|
+
* @param {Object} [props.options.lang] - Options for changing the text displayed on the chart or i18n languages.
|
|
62
|
+
* @param {Object} [props.options.lang.noData] - No Data Layer Text.
|
|
63
|
+
* @param {Object} [props.options.theme] - Chart theme options. For specific information, refer to the {@link https://github.com/nhn/tui.chart|NestedPie Chart guide} on github.
|
|
64
|
+
* @param {Object} [props.options.theme.chart] - Chart font theme.
|
|
65
|
+
* @param {Object} [props.options.theme.noData] - No Data Layer Text theme.
|
|
66
|
+
* @param {Object} [props.options.theme.series] - Series theme.
|
|
67
|
+
* @param {Object} [props.options.theme.title] - Title theme.
|
|
68
|
+
* @param {Object} [props.options.theme.legend] - Legend theme.
|
|
69
|
+
* @param {Object} [props.options.theme.tooltip] - Tooltip theme.
|
|
70
|
+
* @param {Object} [props.options.theme.exportMenu] - ExportMenu theme.
|
|
71
|
+
* @extends Chart
|
|
72
|
+
*/
|
|
73
|
+
export default class NestedPieChart extends Chart {
|
|
74
|
+
constructor({ el, options, data: { series, categories } }) {
|
|
75
|
+
super({
|
|
76
|
+
el,
|
|
77
|
+
options,
|
|
78
|
+
series: { pie: series },
|
|
79
|
+
categories,
|
|
80
|
+
modules: [nestedPieSeriesData],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
initialize() {
|
|
84
|
+
var _a;
|
|
85
|
+
super.initialize();
|
|
86
|
+
this.componentManager.add(Background);
|
|
87
|
+
this.componentManager.add(Title);
|
|
88
|
+
this.componentManager.add(Legend);
|
|
89
|
+
(_a = this.store.initStoreState.series.pie, (_a !== null && _a !== void 0 ? _a : [])).forEach(({ name }) => {
|
|
90
|
+
this.componentManager.add(PieSeries, { alias: name });
|
|
91
|
+
});
|
|
92
|
+
this.componentManager.add(ExportMenu, { chartEl: this.el });
|
|
93
|
+
this.componentManager.add(HoveredSeries);
|
|
94
|
+
this.componentManager.add(SelectedSeries);
|
|
95
|
+
this.componentManager.add(DataLabels);
|
|
96
|
+
this.componentManager.add(Tooltip, { chartEl: this.el });
|
|
97
|
+
this.componentManager.add(NoDataText);
|
|
98
|
+
this.painter.addGroups([
|
|
99
|
+
basicBrush,
|
|
100
|
+
legendBrush,
|
|
101
|
+
labelBrush,
|
|
102
|
+
exportMenuBrush,
|
|
103
|
+
sectorBrush,
|
|
104
|
+
dataLabelBrush,
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Add series.
|
|
109
|
+
* @param {Object} data - Data to be added.
|
|
110
|
+
* @param {string} data.name - Series name.
|
|
111
|
+
* @param {Array<Object>} data.data - Array of data to be added.
|
|
112
|
+
* @param {Object} dataInfo - Which name of chart to add.
|
|
113
|
+
* @param {string} dataInfo.name - Chart series name.
|
|
114
|
+
* @api
|
|
115
|
+
* @example
|
|
116
|
+
* chart.addSeries(
|
|
117
|
+
* {
|
|
118
|
+
* name: 'newSeries',
|
|
119
|
+
* data: [
|
|
120
|
+
* { name: 'A', data: 10 },
|
|
121
|
+
* { name: 'B', data: 20 },
|
|
122
|
+
* ],
|
|
123
|
+
* },
|
|
124
|
+
* {
|
|
125
|
+
* name: 'series name'
|
|
126
|
+
* });
|
|
127
|
+
*/
|
|
128
|
+
addSeries(data, dataInfo) {
|
|
129
|
+
this.resetSeries();
|
|
130
|
+
this.store.dispatch('addSeries', Object.assign({ data }, dataInfo));
|
|
131
|
+
this.componentManager.add(PieSeries, { alias: data.name });
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Convert the chart data to new data.
|
|
135
|
+
* @param {Object} data - Data to be set
|
|
136
|
+
* @api
|
|
137
|
+
* @example
|
|
138
|
+
* chart.setData({
|
|
139
|
+
* categories: ['A', 'B'],
|
|
140
|
+
* series: [
|
|
141
|
+
* {
|
|
142
|
+
* name: 'browsers',
|
|
143
|
+
* data: [
|
|
144
|
+
* {
|
|
145
|
+
* name: 'Chrome',
|
|
146
|
+
* data: 50,
|
|
147
|
+
* },
|
|
148
|
+
* {
|
|
149
|
+
* name: 'Safari',
|
|
150
|
+
* data: 20,
|
|
151
|
+
* },
|
|
152
|
+
* ]
|
|
153
|
+
* },
|
|
154
|
+
* {
|
|
155
|
+
* name: 'versions',
|
|
156
|
+
* data: [
|
|
157
|
+
* {
|
|
158
|
+
* name: '1',
|
|
159
|
+
* data: 50,
|
|
160
|
+
* },
|
|
161
|
+
* {
|
|
162
|
+
* name: '2',
|
|
163
|
+
* data: 20,
|
|
164
|
+
* },
|
|
165
|
+
* ]
|
|
166
|
+
* }
|
|
167
|
+
* ]
|
|
168
|
+
* });
|
|
169
|
+
*/
|
|
170
|
+
setData(data) {
|
|
171
|
+
var _a;
|
|
172
|
+
this.componentManager.remove(PieSeries);
|
|
173
|
+
this.resetSeries();
|
|
174
|
+
this.store.dispatch('setData', { series: { pie: data.series } });
|
|
175
|
+
(_a = this.store.initStoreState.series.pie, (_a !== null && _a !== void 0 ? _a : [])).forEach(({ name }) => {
|
|
176
|
+
this.componentManager.add(PieSeries, { alias: name });
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Hide series data label.
|
|
181
|
+
* @api
|
|
182
|
+
* @example
|
|
183
|
+
* chart.hideSeriesDataLabel();
|
|
184
|
+
*/
|
|
185
|
+
hideSeriesDataLabel() {
|
|
186
|
+
this.store.dispatch('updateOptions', {
|
|
187
|
+
options: { series: { dataLabels: { visible: false } } },
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Show series data label.
|
|
192
|
+
* @api
|
|
193
|
+
* @example
|
|
194
|
+
* chart.showSeriesDataLabel();
|
|
195
|
+
*/
|
|
196
|
+
showSeriesDataLabel() {
|
|
197
|
+
this.store.dispatch('updateOptions', {
|
|
198
|
+
options: { series: { dataLabels: { visible: true } } },
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Convert the chart options to new options.
|
|
203
|
+
* @param {Object} options - Chart options.
|
|
204
|
+
* @api
|
|
205
|
+
* @example
|
|
206
|
+
* chart.setOptions({
|
|
207
|
+
* chart: {
|
|
208
|
+
* width: 500,
|
|
209
|
+
* height: 'auto',
|
|
210
|
+
* title: 'Energy Usage',
|
|
211
|
+
* },
|
|
212
|
+
* series: {
|
|
213
|
+
* alias2: {
|
|
214
|
+
* radiusRange: [20%, 50%],
|
|
215
|
+
* },
|
|
216
|
+
* },
|
|
217
|
+
* tooltip: {
|
|
218
|
+
* formatter: (value) => `${value}kWh`,
|
|
219
|
+
* },
|
|
220
|
+
* });
|
|
221
|
+
*/
|
|
222
|
+
setOptions(options) {
|
|
223
|
+
this.resetSeries();
|
|
224
|
+
this.dispatchOptionsEvent('initOptions', options);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Update chart options.
|
|
228
|
+
* @param {Object} options - Chart options.
|
|
229
|
+
* @api
|
|
230
|
+
* @example
|
|
231
|
+
* chart.updateOptions({
|
|
232
|
+
* chart: {
|
|
233
|
+
* height: 'auto',
|
|
234
|
+
* title: 'Energy Usage',
|
|
235
|
+
* },
|
|
236
|
+
* series: {
|
|
237
|
+
* alias1: {
|
|
238
|
+
* showDot: true,
|
|
239
|
+
* },
|
|
240
|
+
* },
|
|
241
|
+
* });
|
|
242
|
+
*/
|
|
243
|
+
updateOptions(options) {
|
|
244
|
+
this.resetSeries();
|
|
245
|
+
this.dispatchOptionsEvent('updateOptions', options);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Show tooltip.
|
|
249
|
+
* @param {Object} seriesInfo - Information of the series for the tooltip to be displayed.
|
|
250
|
+
* @param {number} seriesInfo.seriesIndex - Index of series.
|
|
251
|
+
* @param {number} seriesInfo.alias - alias name.
|
|
252
|
+
* @api
|
|
253
|
+
* @example
|
|
254
|
+
* chart.showTooltip({seriesIndex: 1, alias: 'name'});
|
|
255
|
+
*/
|
|
256
|
+
showTooltip(seriesInfo) {
|
|
257
|
+
this.eventBus.emit('showTooltip', Object.assign({}, seriesInfo));
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Hide tooltip.
|
|
261
|
+
* @api
|
|
262
|
+
* @example
|
|
263
|
+
* chart.hideTooltip();
|
|
264
|
+
*/
|
|
265
|
+
hideTooltip() {
|
|
266
|
+
this.eventBus.emit('hideTooltip');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import Chart from "./chart";
|
|
2
|
+
import { PieChartOptions, PieSeriesData, PieSeriesType } from "../../types/options";
|
|
3
|
+
import { PieChartProps, SelectSeriesInfo } from "../../types/charts";
|
|
4
|
+
/**
|
|
5
|
+
* @class
|
|
6
|
+
* @classdesc Pie Chart
|
|
7
|
+
* @param {Object} props
|
|
8
|
+
* @param {HTMLElement} props.el - The target element to create chart.
|
|
9
|
+
* @param {Object} props.data - Data for making Pie Chart.
|
|
10
|
+
* @param {Array<string>} [props.data.categories] - Categories.
|
|
11
|
+
* @param {Array<Object>} props.data.series - Series data.
|
|
12
|
+
* @param {string} props.data.series.name - Series name.
|
|
13
|
+
* @param {number} props.data.series.data - Series data.
|
|
14
|
+
* @param {Object} [props.options] - Options for making Pie Chart.
|
|
15
|
+
* @param {Object} [props.options.chart]
|
|
16
|
+
* @param {string|Object} [props.options.chart.title] - Chart title text or options.
|
|
17
|
+
* @param {string} [props.options.chart.title.text] - Chart title text.
|
|
18
|
+
* @param {number} [props.options.chart.title.offsetX] - Offset value to move title horizontally.
|
|
19
|
+
* @param {number} [props.options.chart.title.offsetY] - Offset value to move title vertically.
|
|
20
|
+
* @param {string} [props.options.chart.title.align] - Chart text align. 'left', 'right', 'center' is available.
|
|
21
|
+
* @param {boolean|Object} [props.options.chart.animation] - Whether to use animation and duration when rendering the initial chart.
|
|
22
|
+
* @param {number|string} [props.options.chart.width] - Chart width. 'auto' or if not write, the width of the parent container is followed. 'auto' or if not created, the width of the parent container is followed.
|
|
23
|
+
* @param {number|string} [props.options.chart.height] - Chart height. 'auto' or if not write, the width of the parent container is followed. 'auto' or if not created, the height of the parent container is followed.
|
|
24
|
+
* @param {Object} [props.options.series]
|
|
25
|
+
* @param {boolean} [props.options.series.selectable=false] - Whether to make selectable series or not.
|
|
26
|
+
* @param {Object} [props.options.series.dataLabels] - Set the visibility, location, and formatting of dataLabel. For specific information, refer to the {@link https://github.com/nhn/tui.chart|DataLabels guide} on github.
|
|
27
|
+
* @param {Array<number>|Array<string>} [props.options.series.radiusRange] - Specifies the radius of the circle drawn. It is specified by entering a number or percent string value in start and end.
|
|
28
|
+
* @param {Array<number>} [props.options.series.angleRange] - The range of angles to which the circle will be drawn. It is specified by putting number in start and end.
|
|
29
|
+
* @param {boolean} [props.options.series.clockwise] - Whether it will be drawn clockwise.
|
|
30
|
+
* @param {Object} [props.options.legend]
|
|
31
|
+
* @param {string} [props.options.legend.align] - Legend align. 'top', 'bottom', 'right', 'left' is available.
|
|
32
|
+
* @param {string} [props.options.legend.showCheckbox] - Whether to show checkbox.
|
|
33
|
+
* @param {boolean} [props.options.legend.visible] - Whether to show legend.
|
|
34
|
+
* @param {number} [props.options.legend.width] - Width of legend.
|
|
35
|
+
* @param {Object} [props.options.legend.item] - `width` and `overflow` options of the legend item. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Legend guide} on github.
|
|
36
|
+
* @param {Object} [props.options.exportMenu]
|
|
37
|
+
* @param {boolean} [props.options.exportMenu.visible] - Whether to show export menu.
|
|
38
|
+
* @param {string} [props.options.exportMenu.filename] - File name applied when downloading.
|
|
39
|
+
* @param {Object} [props.options.tooltip]
|
|
40
|
+
* @param {number} [props.options.tooltip.offsetX] - Offset value to move title horizontally.
|
|
41
|
+
* @param {number} [props.options.tooltip.offsetY] - Offset value to move title vertically.
|
|
42
|
+
* @param {Function} [props.options.tooltip.formatter] - Function to format data value.
|
|
43
|
+
* @param {Function} [props.options.tooltip.template] - Function to create custom template. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Tooltip guide} on github.
|
|
44
|
+
* @param {Object} [props.options.responsive] - Rules for changing chart options. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Responsive guide} on github.
|
|
45
|
+
* @param {boolean|Object} [props.options.responsive.animation] - Animation duration when the chart is modified.
|
|
46
|
+
* @param {Array<Object>} [props.options.responsive.rules] - Rules for the Chart to Respond.
|
|
47
|
+
* @param {Object} [props.options.lang] - Options for changing the text displayed on the chart or i18n languages.
|
|
48
|
+
* @param {Object} [props.options.lang.noData] - No Data Layer Text.
|
|
49
|
+
* @param {Object} [props.options.theme] - Chart theme options. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Pie Chart guide} on github.
|
|
50
|
+
* @param {Object} [props.options.theme.chart] - Chart font theme.
|
|
51
|
+
* @param {Object} [props.options.theme.noData] - No Data Layer Text theme.
|
|
52
|
+
* @param {Object} [props.options.theme.series] - Series theme.
|
|
53
|
+
* @param {Object} [props.options.theme.title] - Title theme.
|
|
54
|
+
* @param {Object} [props.options.theme.legend] - Legend theme.
|
|
55
|
+
* @param {Object} [props.options.theme.tooltip] - Tooltip theme.
|
|
56
|
+
* @param {Object} [props.options.theme.exportMenu] - ExportMenu theme.
|
|
57
|
+
* @extends Chart
|
|
58
|
+
*/
|
|
59
|
+
export default class PieChart extends Chart<PieChartOptions> {
|
|
60
|
+
constructor({ el, options, data }: PieChartProps);
|
|
61
|
+
protected initialize(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Add series.
|
|
64
|
+
* @param {Object} data - Data to be added.
|
|
65
|
+
* @param {string} data.name - Series name.
|
|
66
|
+
* @param {Array<Object>} data.data - Array of data to be added.
|
|
67
|
+
* @api
|
|
68
|
+
* @example
|
|
69
|
+
* chart.addSeries({
|
|
70
|
+
* name: 'newSeries',
|
|
71
|
+
* data: 10,
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
74
|
+
addSeries(data: PieSeriesType): void;
|
|
75
|
+
/**
|
|
76
|
+
* Convert the chart data to new data.
|
|
77
|
+
* @param {Object} data - Data to be set.
|
|
78
|
+
* @api
|
|
79
|
+
* @example
|
|
80
|
+
* chart.setData({
|
|
81
|
+
* categories: ['A'],
|
|
82
|
+
* series: [
|
|
83
|
+
* {name: 'a', data: 10},
|
|
84
|
+
* {name: 'b', data: 20},
|
|
85
|
+
* ]
|
|
86
|
+
* });
|
|
87
|
+
*/
|
|
88
|
+
setData(data: PieSeriesData): void;
|
|
89
|
+
/**
|
|
90
|
+
* Hide series data label.
|
|
91
|
+
* @api
|
|
92
|
+
* @example
|
|
93
|
+
* chart.hideSeriesDataLabel();
|
|
94
|
+
*/
|
|
95
|
+
hideSeriesDataLabel(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Show series data label.
|
|
98
|
+
* @api
|
|
99
|
+
* @example
|
|
100
|
+
* chart.showSeriesDataLabel();
|
|
101
|
+
*/
|
|
102
|
+
showSeriesDataLabel(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Convert the chart options to new options.
|
|
105
|
+
* @param {Object} options - Chart options.
|
|
106
|
+
* @api
|
|
107
|
+
* @example
|
|
108
|
+
* chart.setOptions({
|
|
109
|
+
* chart: {
|
|
110
|
+
* width: 500,
|
|
111
|
+
* height: 'auto',
|
|
112
|
+
* title: 'Energy Usage',
|
|
113
|
+
* },
|
|
114
|
+
* series: {
|
|
115
|
+
* selectable: true,
|
|
116
|
+
* },
|
|
117
|
+
* tooltip: {
|
|
118
|
+
* formatter: (value) => `${value}kWh`,
|
|
119
|
+
* },
|
|
120
|
+
* });
|
|
121
|
+
*/
|
|
122
|
+
setOptions(options: PieChartOptions): void;
|
|
123
|
+
/**
|
|
124
|
+
* Update chart options.
|
|
125
|
+
* @param {Object} options - Chart options.
|
|
126
|
+
* @api
|
|
127
|
+
* @example
|
|
128
|
+
* chart.updateOptions({
|
|
129
|
+
* chart: {
|
|
130
|
+
* height: 'auto',
|
|
131
|
+
* title: 'Energy Usage',
|
|
132
|
+
* },
|
|
133
|
+
* tooltip: {
|
|
134
|
+
* formatter: (value) => `${value}kWh`,
|
|
135
|
+
* },
|
|
136
|
+
* });
|
|
137
|
+
*/
|
|
138
|
+
updateOptions(options: PieChartOptions): void;
|
|
139
|
+
/**
|
|
140
|
+
* Show tooltip.
|
|
141
|
+
* @param {Object} seriesInfo - Information of the series for the tooltip to be displayed.
|
|
142
|
+
* @param {number} seriesInfo.seriesIndex - Index of series.
|
|
143
|
+
* @param {number} seriesInfo.alias - alias name.
|
|
144
|
+
* @api
|
|
145
|
+
* @example
|
|
146
|
+
* chart.showTooltip({seriesIndex: 1, alias: 'name'});
|
|
147
|
+
*/
|
|
148
|
+
showTooltip(seriesInfo: SelectSeriesInfo): void;
|
|
149
|
+
/**
|
|
150
|
+
* Hide tooltip.
|
|
151
|
+
* @api
|
|
152
|
+
* @example
|
|
153
|
+
* chart.hideTooltip();
|
|
154
|
+
*/
|
|
155
|
+
hideTooltip(): void;
|
|
156
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import Chart from "./chart";
|
|
2
|
+
import Tooltip from "../component/tooltip";
|
|
3
|
+
import Legend from "../component/legend";
|
|
4
|
+
import PieSeries from "../component/pieSeries";
|
|
5
|
+
import Title from "../component/title";
|
|
6
|
+
import ExportMenu from "../component/exportMenu";
|
|
7
|
+
import HoveredSeries from "../component/hoveredSeries";
|
|
8
|
+
import DataLabels from "../component/dataLabels";
|
|
9
|
+
import SelectedSeries from "../component/selectedSeries";
|
|
10
|
+
import Background from "../component/background";
|
|
11
|
+
import NoDataText from "../component/noDataText";
|
|
12
|
+
import * as basicBrush from "../brushes/basic";
|
|
13
|
+
import * as legendBrush from "../brushes/legend";
|
|
14
|
+
import * as labelBrush from "../brushes/label";
|
|
15
|
+
import * as exportMenuBrush from "../brushes/exportMenu";
|
|
16
|
+
import * as sectorBrush from "../brushes/sector";
|
|
17
|
+
import * as dataLabelBrush from "../brushes/dataLabel";
|
|
18
|
+
/**
|
|
19
|
+
* @class
|
|
20
|
+
* @classdesc Pie Chart
|
|
21
|
+
* @param {Object} props
|
|
22
|
+
* @param {HTMLElement} props.el - The target element to create chart.
|
|
23
|
+
* @param {Object} props.data - Data for making Pie Chart.
|
|
24
|
+
* @param {Array<string>} [props.data.categories] - Categories.
|
|
25
|
+
* @param {Array<Object>} props.data.series - Series data.
|
|
26
|
+
* @param {string} props.data.series.name - Series name.
|
|
27
|
+
* @param {number} props.data.series.data - Series data.
|
|
28
|
+
* @param {Object} [props.options] - Options for making Pie Chart.
|
|
29
|
+
* @param {Object} [props.options.chart]
|
|
30
|
+
* @param {string|Object} [props.options.chart.title] - Chart title text or options.
|
|
31
|
+
* @param {string} [props.options.chart.title.text] - Chart title text.
|
|
32
|
+
* @param {number} [props.options.chart.title.offsetX] - Offset value to move title horizontally.
|
|
33
|
+
* @param {number} [props.options.chart.title.offsetY] - Offset value to move title vertically.
|
|
34
|
+
* @param {string} [props.options.chart.title.align] - Chart text align. 'left', 'right', 'center' is available.
|
|
35
|
+
* @param {boolean|Object} [props.options.chart.animation] - Whether to use animation and duration when rendering the initial chart.
|
|
36
|
+
* @param {number|string} [props.options.chart.width] - Chart width. 'auto' or if not write, the width of the parent container is followed. 'auto' or if not created, the width of the parent container is followed.
|
|
37
|
+
* @param {number|string} [props.options.chart.height] - Chart height. 'auto' or if not write, the width of the parent container is followed. 'auto' or if not created, the height of the parent container is followed.
|
|
38
|
+
* @param {Object} [props.options.series]
|
|
39
|
+
* @param {boolean} [props.options.series.selectable=false] - Whether to make selectable series or not.
|
|
40
|
+
* @param {Object} [props.options.series.dataLabels] - Set the visibility, location, and formatting of dataLabel. For specific information, refer to the {@link https://github.com/nhn/tui.chart|DataLabels guide} on github.
|
|
41
|
+
* @param {Array<number>|Array<string>} [props.options.series.radiusRange] - Specifies the radius of the circle drawn. It is specified by entering a number or percent string value in start and end.
|
|
42
|
+
* @param {Array<number>} [props.options.series.angleRange] - The range of angles to which the circle will be drawn. It is specified by putting number in start and end.
|
|
43
|
+
* @param {boolean} [props.options.series.clockwise] - Whether it will be drawn clockwise.
|
|
44
|
+
* @param {Object} [props.options.legend]
|
|
45
|
+
* @param {string} [props.options.legend.align] - Legend align. 'top', 'bottom', 'right', 'left' is available.
|
|
46
|
+
* @param {string} [props.options.legend.showCheckbox] - Whether to show checkbox.
|
|
47
|
+
* @param {boolean} [props.options.legend.visible] - Whether to show legend.
|
|
48
|
+
* @param {number} [props.options.legend.width] - Width of legend.
|
|
49
|
+
* @param {Object} [props.options.legend.item] - `width` and `overflow` options of the legend item. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Legend guide} on github.
|
|
50
|
+
* @param {Object} [props.options.exportMenu]
|
|
51
|
+
* @param {boolean} [props.options.exportMenu.visible] - Whether to show export menu.
|
|
52
|
+
* @param {string} [props.options.exportMenu.filename] - File name applied when downloading.
|
|
53
|
+
* @param {Object} [props.options.tooltip]
|
|
54
|
+
* @param {number} [props.options.tooltip.offsetX] - Offset value to move title horizontally.
|
|
55
|
+
* @param {number} [props.options.tooltip.offsetY] - Offset value to move title vertically.
|
|
56
|
+
* @param {Function} [props.options.tooltip.formatter] - Function to format data value.
|
|
57
|
+
* @param {Function} [props.options.tooltip.template] - Function to create custom template. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Tooltip guide} on github.
|
|
58
|
+
* @param {Object} [props.options.responsive] - Rules for changing chart options. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Responsive guide} on github.
|
|
59
|
+
* @param {boolean|Object} [props.options.responsive.animation] - Animation duration when the chart is modified.
|
|
60
|
+
* @param {Array<Object>} [props.options.responsive.rules] - Rules for the Chart to Respond.
|
|
61
|
+
* @param {Object} [props.options.lang] - Options for changing the text displayed on the chart or i18n languages.
|
|
62
|
+
* @param {Object} [props.options.lang.noData] - No Data Layer Text.
|
|
63
|
+
* @param {Object} [props.options.theme] - Chart theme options. For specific information, refer to the {@link https://github.com/nhn/tui.chart|Pie Chart guide} on github.
|
|
64
|
+
* @param {Object} [props.options.theme.chart] - Chart font theme.
|
|
65
|
+
* @param {Object} [props.options.theme.noData] - No Data Layer Text theme.
|
|
66
|
+
* @param {Object} [props.options.theme.series] - Series theme.
|
|
67
|
+
* @param {Object} [props.options.theme.title] - Title theme.
|
|
68
|
+
* @param {Object} [props.options.theme.legend] - Legend theme.
|
|
69
|
+
* @param {Object} [props.options.theme.tooltip] - Tooltip theme.
|
|
70
|
+
* @param {Object} [props.options.theme.exportMenu] - ExportMenu theme.
|
|
71
|
+
* @extends Chart
|
|
72
|
+
*/
|
|
73
|
+
export default class PieChart extends Chart {
|
|
74
|
+
constructor({ el, options, data }) {
|
|
75
|
+
super({
|
|
76
|
+
el,
|
|
77
|
+
options,
|
|
78
|
+
series: {
|
|
79
|
+
pie: data.series,
|
|
80
|
+
},
|
|
81
|
+
categories: data.categories,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
initialize() {
|
|
85
|
+
super.initialize();
|
|
86
|
+
this.componentManager.add(Background);
|
|
87
|
+
this.componentManager.add(Title);
|
|
88
|
+
this.componentManager.add(Legend);
|
|
89
|
+
this.componentManager.add(PieSeries);
|
|
90
|
+
this.componentManager.add(ExportMenu, { chartEl: this.el });
|
|
91
|
+
this.componentManager.add(HoveredSeries);
|
|
92
|
+
this.componentManager.add(SelectedSeries);
|
|
93
|
+
this.componentManager.add(DataLabels);
|
|
94
|
+
this.componentManager.add(Tooltip, { chartEl: this.el });
|
|
95
|
+
this.componentManager.add(NoDataText);
|
|
96
|
+
this.painter.addGroups([
|
|
97
|
+
basicBrush,
|
|
98
|
+
legendBrush,
|
|
99
|
+
labelBrush,
|
|
100
|
+
exportMenuBrush,
|
|
101
|
+
sectorBrush,
|
|
102
|
+
dataLabelBrush,
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Add series.
|
|
107
|
+
* @param {Object} data - Data to be added.
|
|
108
|
+
* @param {string} data.name - Series name.
|
|
109
|
+
* @param {Array<Object>} data.data - Array of data to be added.
|
|
110
|
+
* @api
|
|
111
|
+
* @example
|
|
112
|
+
* chart.addSeries({
|
|
113
|
+
* name: 'newSeries',
|
|
114
|
+
* data: 10,
|
|
115
|
+
* });
|
|
116
|
+
*/
|
|
117
|
+
addSeries(data) {
|
|
118
|
+
this.resetSeries();
|
|
119
|
+
this.store.dispatch('addSeries', { data });
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Convert the chart data to new data.
|
|
123
|
+
* @param {Object} data - Data to be set.
|
|
124
|
+
* @api
|
|
125
|
+
* @example
|
|
126
|
+
* chart.setData({
|
|
127
|
+
* categories: ['A'],
|
|
128
|
+
* series: [
|
|
129
|
+
* {name: 'a', data: 10},
|
|
130
|
+
* {name: 'b', data: 20},
|
|
131
|
+
* ]
|
|
132
|
+
* });
|
|
133
|
+
*/
|
|
134
|
+
setData(data) {
|
|
135
|
+
const { categories, series } = data;
|
|
136
|
+
this.resetSeries();
|
|
137
|
+
this.store.dispatch('setData', { series: { pie: series }, categories });
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Hide series data label.
|
|
141
|
+
* @api
|
|
142
|
+
* @example
|
|
143
|
+
* chart.hideSeriesDataLabel();
|
|
144
|
+
*/
|
|
145
|
+
hideSeriesDataLabel() {
|
|
146
|
+
this.store.dispatch('updateOptions', {
|
|
147
|
+
options: { series: { dataLabels: { visible: false } } },
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Show series data label.
|
|
152
|
+
* @api
|
|
153
|
+
* @example
|
|
154
|
+
* chart.showSeriesDataLabel();
|
|
155
|
+
*/
|
|
156
|
+
showSeriesDataLabel() {
|
|
157
|
+
this.store.dispatch('updateOptions', {
|
|
158
|
+
options: { series: { dataLabels: { visible: true } } },
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Convert the chart options to new options.
|
|
163
|
+
* @param {Object} options - Chart options.
|
|
164
|
+
* @api
|
|
165
|
+
* @example
|
|
166
|
+
* chart.setOptions({
|
|
167
|
+
* chart: {
|
|
168
|
+
* width: 500,
|
|
169
|
+
* height: 'auto',
|
|
170
|
+
* title: 'Energy Usage',
|
|
171
|
+
* },
|
|
172
|
+
* series: {
|
|
173
|
+
* selectable: true,
|
|
174
|
+
* },
|
|
175
|
+
* tooltip: {
|
|
176
|
+
* formatter: (value) => `${value}kWh`,
|
|
177
|
+
* },
|
|
178
|
+
* });
|
|
179
|
+
*/
|
|
180
|
+
setOptions(options) {
|
|
181
|
+
this.resetSeries();
|
|
182
|
+
this.dispatchOptionsEvent('initOptions', options);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Update chart options.
|
|
186
|
+
* @param {Object} options - Chart options.
|
|
187
|
+
* @api
|
|
188
|
+
* @example
|
|
189
|
+
* chart.updateOptions({
|
|
190
|
+
* chart: {
|
|
191
|
+
* height: 'auto',
|
|
192
|
+
* title: 'Energy Usage',
|
|
193
|
+
* },
|
|
194
|
+
* tooltip: {
|
|
195
|
+
* formatter: (value) => `${value}kWh`,
|
|
196
|
+
* },
|
|
197
|
+
* });
|
|
198
|
+
*/
|
|
199
|
+
updateOptions(options) {
|
|
200
|
+
this.resetSeries();
|
|
201
|
+
this.dispatchOptionsEvent('updateOptions', options);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Show tooltip.
|
|
205
|
+
* @param {Object} seriesInfo - Information of the series for the tooltip to be displayed.
|
|
206
|
+
* @param {number} seriesInfo.seriesIndex - Index of series.
|
|
207
|
+
* @param {number} seriesInfo.alias - alias name.
|
|
208
|
+
* @api
|
|
209
|
+
* @example
|
|
210
|
+
* chart.showTooltip({seriesIndex: 1, alias: 'name'});
|
|
211
|
+
*/
|
|
212
|
+
showTooltip(seriesInfo) {
|
|
213
|
+
this.eventBus.emit('showTooltip', Object.assign(Object.assign({}, seriesInfo), { state: this.store.state }));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Hide tooltip.
|
|
217
|
+
* @api
|
|
218
|
+
* @example
|
|
219
|
+
* chart.hideTooltip();
|
|
220
|
+
*/
|
|
221
|
+
hideTooltip() {
|
|
222
|
+
this.eventBus.emit('hideTooltip');
|
|
223
|
+
}
|
|
224
|
+
}
|