@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,405 @@
|
|
|
1
|
+
import { isFunction, includes, isBoolean, isString } from "./utils";
|
|
2
|
+
import { getTextWidth, getTextHeight } from "./calculator";
|
|
3
|
+
import { getRadialAnchorPosition, makeAnchorPositionParam, calculateDegreeToRadian, getRadialLabelAlign, } from "./sector";
|
|
4
|
+
import { getFont } from "./style";
|
|
5
|
+
export const RADIUS_PADDING = 30;
|
|
6
|
+
const CALLOUT_LENGTH = 20;
|
|
7
|
+
function getDefaultAnchor(type, withStack = false) {
|
|
8
|
+
let anchor = 'auto';
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 'point':
|
|
11
|
+
anchor = 'center';
|
|
12
|
+
break;
|
|
13
|
+
case 'rect':
|
|
14
|
+
anchor = !withStack ? 'auto' : 'center';
|
|
15
|
+
break;
|
|
16
|
+
case 'sector':
|
|
17
|
+
case 'treemapSeriesName':
|
|
18
|
+
anchor = 'center';
|
|
19
|
+
break;
|
|
20
|
+
case 'stackTotal':
|
|
21
|
+
anchor = 'auto';
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
return anchor;
|
|
25
|
+
}
|
|
26
|
+
function getAnchor(dataLabelOptions, type, withStack = false) {
|
|
27
|
+
return type !== 'stackTotal' &&
|
|
28
|
+
includes(['center', 'start', 'end', 'auto', 'outer'], dataLabelOptions.anchor)
|
|
29
|
+
? dataLabelOptions.anchor
|
|
30
|
+
: getDefaultAnchor(type, withStack);
|
|
31
|
+
}
|
|
32
|
+
export function getDefaultDataLabelsOptions(dataLabelOptions, type, withStack = false) {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const anchor = getAnchor(dataLabelOptions, type, withStack);
|
|
35
|
+
const { offsetX = 0, offsetY = 0 } = dataLabelOptions;
|
|
36
|
+
const formatter = isFunction(dataLabelOptions.formatter)
|
|
37
|
+
? dataLabelOptions.formatter
|
|
38
|
+
: (value) => String(value) || '';
|
|
39
|
+
const options = {
|
|
40
|
+
anchor,
|
|
41
|
+
offsetX,
|
|
42
|
+
offsetY,
|
|
43
|
+
formatter,
|
|
44
|
+
};
|
|
45
|
+
if (withStack) {
|
|
46
|
+
const stackTotal = dataLabelOptions.stackTotal;
|
|
47
|
+
options.stackTotal = {
|
|
48
|
+
visible: isBoolean((_a = stackTotal) === null || _a === void 0 ? void 0 : _a.visible) ? stackTotal.visible : true,
|
|
49
|
+
formatter: isFunction((_b = stackTotal) === null || _b === void 0 ? void 0 : _b.formatter) ? stackTotal.formatter : formatter,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (type === 'sector' && ((_c = dataLabelOptions.pieSeriesName) === null || _c === void 0 ? void 0 : _c.visible)) {
|
|
53
|
+
options.pieSeriesName = Object.assign({ anchor: 'center' }, dataLabelOptions.pieSeriesName);
|
|
54
|
+
}
|
|
55
|
+
return options;
|
|
56
|
+
}
|
|
57
|
+
export function makePointLabelInfo(point, dataLabelOptions, rect) {
|
|
58
|
+
const { width, height } = rect;
|
|
59
|
+
const { anchor, offsetX = 0, offsetY = 0, formatter } = dataLabelOptions;
|
|
60
|
+
const { name, theme } = point;
|
|
61
|
+
let textBaseline = 'middle';
|
|
62
|
+
if (anchor === 'end') {
|
|
63
|
+
textBaseline = 'bottom';
|
|
64
|
+
}
|
|
65
|
+
else if (anchor === 'start') {
|
|
66
|
+
textBaseline = 'top';
|
|
67
|
+
}
|
|
68
|
+
const xWithOffset = point.x + offsetX;
|
|
69
|
+
const yWithOffset = point.y + offsetY;
|
|
70
|
+
const x = xWithOffset < 0 || xWithOffset > width ? point.x : xWithOffset;
|
|
71
|
+
const y = yWithOffset < 0 || yWithOffset > height ? point.y : yWithOffset;
|
|
72
|
+
return {
|
|
73
|
+
type: 'point',
|
|
74
|
+
x,
|
|
75
|
+
y,
|
|
76
|
+
text: formatter(point.value, point.data),
|
|
77
|
+
textAlign: 'center',
|
|
78
|
+
textBaseline,
|
|
79
|
+
name,
|
|
80
|
+
theme,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function isHorizontal(direction) {
|
|
84
|
+
return includes(['left', 'right'], direction);
|
|
85
|
+
}
|
|
86
|
+
function makeHorizontalRectPosition(rect, anchor) {
|
|
87
|
+
const { x, y, width, height, direction } = rect;
|
|
88
|
+
const textBaseline = 'middle';
|
|
89
|
+
const posY = y + height / 2;
|
|
90
|
+
let textAlign = 'center';
|
|
91
|
+
let posX;
|
|
92
|
+
if (direction === 'right') {
|
|
93
|
+
switch (anchor) {
|
|
94
|
+
case 'start':
|
|
95
|
+
textAlign = 'left';
|
|
96
|
+
posX = x;
|
|
97
|
+
break;
|
|
98
|
+
case 'end':
|
|
99
|
+
textAlign = 'right';
|
|
100
|
+
posX = x + width;
|
|
101
|
+
break;
|
|
102
|
+
case 'center':
|
|
103
|
+
textAlign = 'center';
|
|
104
|
+
posX = x + width / 2;
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
textAlign = 'left';
|
|
108
|
+
posX = x + width;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
switch (anchor) {
|
|
113
|
+
case 'start':
|
|
114
|
+
textAlign = 'right';
|
|
115
|
+
posX = x + width;
|
|
116
|
+
break;
|
|
117
|
+
case 'end':
|
|
118
|
+
textAlign = 'left';
|
|
119
|
+
posX = x;
|
|
120
|
+
break;
|
|
121
|
+
case 'center':
|
|
122
|
+
textAlign = 'center';
|
|
123
|
+
posX = x + width / 2;
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
textAlign = 'right';
|
|
127
|
+
posX = x;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
x: posX,
|
|
132
|
+
y: posY,
|
|
133
|
+
textAlign,
|
|
134
|
+
textBaseline,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function makeVerticalRectPosition(rect, anchor) {
|
|
138
|
+
const { x, y, width, height, direction } = rect;
|
|
139
|
+
const textAlign = 'center';
|
|
140
|
+
const posX = x + width / 2;
|
|
141
|
+
let textBaseline = 'middle';
|
|
142
|
+
let posY = 0;
|
|
143
|
+
if (direction === 'top') {
|
|
144
|
+
switch (anchor) {
|
|
145
|
+
case 'end':
|
|
146
|
+
textBaseline = 'top';
|
|
147
|
+
posY = y;
|
|
148
|
+
break;
|
|
149
|
+
case 'start':
|
|
150
|
+
textBaseline = 'bottom';
|
|
151
|
+
posY = y + height;
|
|
152
|
+
break;
|
|
153
|
+
case 'center':
|
|
154
|
+
textBaseline = 'middle';
|
|
155
|
+
posY = y + height / 2;
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
textBaseline = 'bottom';
|
|
159
|
+
posY = y;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
switch (anchor) {
|
|
164
|
+
case 'end':
|
|
165
|
+
textBaseline = 'bottom';
|
|
166
|
+
posY = y + height;
|
|
167
|
+
break;
|
|
168
|
+
case 'start':
|
|
169
|
+
textBaseline = 'top';
|
|
170
|
+
posY = y;
|
|
171
|
+
break;
|
|
172
|
+
case 'center':
|
|
173
|
+
textBaseline = 'middle';
|
|
174
|
+
posY = y + height / 2;
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
textBaseline = 'top';
|
|
178
|
+
posY = y + height;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
x: posX,
|
|
184
|
+
y: posY,
|
|
185
|
+
textAlign,
|
|
186
|
+
textBaseline,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function adjustOverflowHorizontalRect(rect, dataLabelOptions, position) {
|
|
190
|
+
const { width, value, direction, plot, theme } = rect;
|
|
191
|
+
const { formatter } = dataLabelOptions;
|
|
192
|
+
const font = getFont(theme);
|
|
193
|
+
const text = isString(value) ? value : formatter(value);
|
|
194
|
+
const textWidth = getTextWidth(text, font);
|
|
195
|
+
let { x, textAlign } = position;
|
|
196
|
+
const isOverflow = (direction === 'left' && x - textWidth < 0) || x + textWidth > plot.size;
|
|
197
|
+
if (isOverflow) {
|
|
198
|
+
x = rect.x + width;
|
|
199
|
+
textAlign = 'right';
|
|
200
|
+
if (direction === 'left' && width >= textWidth) {
|
|
201
|
+
x = rect.x;
|
|
202
|
+
textAlign = 'left';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
x,
|
|
207
|
+
textAlign,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function adjustOverflowVerticalRect(rect, dataLabelOptions, position) {
|
|
211
|
+
const { height, direction, plot, theme, value } = rect;
|
|
212
|
+
const font = getFont(theme);
|
|
213
|
+
const plotSize = plot.size;
|
|
214
|
+
const textHeight = getTextHeight(`${value}`, font); // @TODO: formatter 값해서 넘기기
|
|
215
|
+
let { y, textBaseline } = position;
|
|
216
|
+
const isOverflow = (!(direction === 'bottom') && y - textHeight < 0) || y + textHeight > plotSize;
|
|
217
|
+
if (isOverflow) {
|
|
218
|
+
y = rect.y;
|
|
219
|
+
textBaseline = 'top';
|
|
220
|
+
if (y + textHeight > plotSize) {
|
|
221
|
+
y = rect.y;
|
|
222
|
+
textBaseline = 'bottom';
|
|
223
|
+
}
|
|
224
|
+
if (direction === 'bottom') {
|
|
225
|
+
y = rect.y + height;
|
|
226
|
+
textBaseline = 'bottom';
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
y,
|
|
231
|
+
textBaseline,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function makeHorizontalRectLabelInfo(rect, dataLabelOptions) {
|
|
235
|
+
const { anchor, offsetX = 0, offsetY = 0 } = dataLabelOptions;
|
|
236
|
+
const { direction, plot: { x: startOffsetX = 0, y: startOffsetY = 0 }, } = rect;
|
|
237
|
+
const position = makeHorizontalRectPosition(rect, anchor);
|
|
238
|
+
let { x: posX, y: posY, textAlign } = position;
|
|
239
|
+
if (anchor === 'auto') {
|
|
240
|
+
const adjustRect = adjustOverflowHorizontalRect(rect, dataLabelOptions, { x: posX, textAlign });
|
|
241
|
+
posX = adjustRect.x;
|
|
242
|
+
textAlign = adjustRect.textAlign;
|
|
243
|
+
}
|
|
244
|
+
posY += offsetY;
|
|
245
|
+
if (direction === 'left') {
|
|
246
|
+
posX = posX - offsetX;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
posX = posX + offsetX;
|
|
250
|
+
}
|
|
251
|
+
const padding = 10;
|
|
252
|
+
if (textAlign === 'right') {
|
|
253
|
+
posX -= padding;
|
|
254
|
+
}
|
|
255
|
+
else if (textAlign === 'left') {
|
|
256
|
+
posX += padding;
|
|
257
|
+
}
|
|
258
|
+
posX -= startOffsetX;
|
|
259
|
+
posY -= startOffsetY;
|
|
260
|
+
return {
|
|
261
|
+
x: posX,
|
|
262
|
+
y: posY,
|
|
263
|
+
textAlign,
|
|
264
|
+
textBaseline: position.textBaseline,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function makeVerticalRectLabelInfo(rect, dataLabelOptions) {
|
|
268
|
+
const { anchor, offsetX = 0, offsetY = 0 } = dataLabelOptions;
|
|
269
|
+
const { direction, plot: { x: startOffsetX = 0, y: startOffsetY = 0 }, } = rect;
|
|
270
|
+
const position = makeVerticalRectPosition(rect, anchor);
|
|
271
|
+
let { x: posX, y: posY, textBaseline } = position;
|
|
272
|
+
if (anchor === 'auto') {
|
|
273
|
+
const adjustRect = adjustOverflowVerticalRect(rect, dataLabelOptions, position);
|
|
274
|
+
posY = adjustRect.y;
|
|
275
|
+
textBaseline = adjustRect.textBaseline;
|
|
276
|
+
}
|
|
277
|
+
posX += offsetX;
|
|
278
|
+
if (direction === 'top') {
|
|
279
|
+
posY = posY + offsetY;
|
|
280
|
+
}
|
|
281
|
+
else if (direction === 'bottom') {
|
|
282
|
+
posY = posY - offsetY;
|
|
283
|
+
}
|
|
284
|
+
const padding = 5;
|
|
285
|
+
if (textBaseline === 'bottom') {
|
|
286
|
+
posY -= padding;
|
|
287
|
+
}
|
|
288
|
+
else if (textBaseline === 'top') {
|
|
289
|
+
posY += padding;
|
|
290
|
+
}
|
|
291
|
+
posX -= startOffsetX;
|
|
292
|
+
posY -= startOffsetY;
|
|
293
|
+
return {
|
|
294
|
+
x: posX,
|
|
295
|
+
y: posY,
|
|
296
|
+
textAlign: position.textAlign,
|
|
297
|
+
textBaseline,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
export function makeRectLabelInfo(rect, dataLabelOptions) {
|
|
301
|
+
const { type, value, direction, name, theme } = rect;
|
|
302
|
+
const horizontal = isHorizontal(direction);
|
|
303
|
+
const labelPosition = horizontal
|
|
304
|
+
? makeHorizontalRectLabelInfo(rect, dataLabelOptions)
|
|
305
|
+
: makeVerticalRectLabelInfo(rect, dataLabelOptions);
|
|
306
|
+
const formatter = type === 'stackTotal' ? dataLabelOptions.stackTotal.formatter : dataLabelOptions.formatter;
|
|
307
|
+
return Object.assign(Object.assign({ type }, labelPosition), { text: isString(value) ? value : formatter(value), name, seriesColor: rect.color, theme });
|
|
308
|
+
}
|
|
309
|
+
export function makeSectorLabelPosition(model, dataLabelOptions) {
|
|
310
|
+
const anchor = dataLabelOptions.anchor;
|
|
311
|
+
const position = getRadialAnchorPosition(makeAnchorPositionParam(anchor, Object.assign(Object.assign({}, model), { radius: Object.assign(Object.assign({}, model.radius), { outer: anchor === 'outer' ? model.radius.outer + RADIUS_PADDING : model.radius.outer }) })));
|
|
312
|
+
const textAlign = getRadialLabelAlign(model, anchor);
|
|
313
|
+
return Object.assign(Object.assign({}, position), { textAlign, textBaseline: hasSameAnchorPieDataLabel(dataLabelOptions) ? 'bottom' : 'middle' });
|
|
314
|
+
}
|
|
315
|
+
function makeSectorBarLabelPosition(model, dataLabelOptions) {
|
|
316
|
+
const { anchor } = dataLabelOptions;
|
|
317
|
+
const { clockwise, degree: { start, end }, radius: { inner, outer }, } = model;
|
|
318
|
+
let startAngle = start;
|
|
319
|
+
let endAngle = end;
|
|
320
|
+
let textAlign = 'center';
|
|
321
|
+
let rotationDegree = (start + end) / 2;
|
|
322
|
+
if (anchor === 'start') {
|
|
323
|
+
textAlign = clockwise ? 'left' : 'right';
|
|
324
|
+
endAngle = startAngle;
|
|
325
|
+
rotationDegree = start;
|
|
326
|
+
}
|
|
327
|
+
else if (anchor === 'end') {
|
|
328
|
+
textAlign = clockwise ? 'right' : 'left';
|
|
329
|
+
startAngle = endAngle;
|
|
330
|
+
rotationDegree = end;
|
|
331
|
+
}
|
|
332
|
+
const { x, y } = getRadialAnchorPosition(makeAnchorPositionParam(anchor, Object.assign(Object.assign({}, model), { degree: {
|
|
333
|
+
start: startAngle,
|
|
334
|
+
end: endAngle,
|
|
335
|
+
}, radius: {
|
|
336
|
+
inner: inner,
|
|
337
|
+
outer: outer,
|
|
338
|
+
} })));
|
|
339
|
+
return {
|
|
340
|
+
x,
|
|
341
|
+
y,
|
|
342
|
+
textAlign,
|
|
343
|
+
textBaseline: 'middle',
|
|
344
|
+
radian: calculateDegreeToRadian(rotationDegree, 0),
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
export function makeSectorBarLabelInfo(model, dataLabelOptions) {
|
|
348
|
+
const { formatter } = dataLabelOptions;
|
|
349
|
+
const labelPosition = makeSectorBarLabelPosition(model, dataLabelOptions);
|
|
350
|
+
const { value, name, theme: dataLabelTheme } = model;
|
|
351
|
+
const theme = Object.assign(Object.assign({}, dataLabelTheme), { color: dataLabelTheme.useSeriesColor ? model.color : dataLabelTheme.color });
|
|
352
|
+
return Object.assign(Object.assign({ type: 'sector' }, labelPosition), { text: formatter(value), name,
|
|
353
|
+
theme });
|
|
354
|
+
}
|
|
355
|
+
export function makeSectorLabelInfo(model, dataLabelOptions) {
|
|
356
|
+
const { formatter } = dataLabelOptions;
|
|
357
|
+
const labelPosition = makeSectorLabelPosition(model, dataLabelOptions);
|
|
358
|
+
const { value, name, theme: dataLabelTheme } = model;
|
|
359
|
+
const anchor = dataLabelOptions.anchor;
|
|
360
|
+
const theme = Object.assign(Object.assign({}, dataLabelTheme), { color: dataLabelTheme.useSeriesColor ? model.color : dataLabelTheme.color });
|
|
361
|
+
return Object.assign(Object.assign({ type: 'sector' }, labelPosition), { text: formatter(value), name, callout: hasSectorCallout(dataLabelOptions) ? getPieDataLabelCallout(model, anchor) : null, theme });
|
|
362
|
+
}
|
|
363
|
+
export function makePieSeriesNameLabelInfo(model, dataLabelOptions) {
|
|
364
|
+
var _a;
|
|
365
|
+
const seriesNameAnchor = (_a = dataLabelOptions.pieSeriesName) === null || _a === void 0 ? void 0 : _a.anchor;
|
|
366
|
+
const hasOuterAnchor = seriesNameAnchor === 'outer';
|
|
367
|
+
const position = getRadialAnchorPosition(makeAnchorPositionParam(seriesNameAnchor, Object.assign(Object.assign({}, model), { radius: Object.assign(Object.assign({}, model.radius), { outer: hasOuterAnchor ? model.radius.outer + RADIUS_PADDING : model.radius.outer }) })));
|
|
368
|
+
const textAlign = getRadialLabelAlign(model, seriesNameAnchor);
|
|
369
|
+
const pieSeriesNameTheme = model.theme.pieSeriesName;
|
|
370
|
+
const theme = Object.assign(Object.assign({}, pieSeriesNameTheme), { color: pieSeriesNameTheme.useSeriesColor ? model.color : pieSeriesNameTheme.color });
|
|
371
|
+
return Object.assign(Object.assign({ type: 'pieSeriesName' }, position), { text: model.name, callout: hasPieSeriesNameCallout(dataLabelOptions)
|
|
372
|
+
? getPieDataLabelCallout(model, seriesNameAnchor)
|
|
373
|
+
: null, textAlign, textBaseline: hasSameAnchorPieDataLabel(dataLabelOptions) ? 'top' : 'middle', theme });
|
|
374
|
+
}
|
|
375
|
+
export function getDataLabelsOptions(options, name) {
|
|
376
|
+
var _a, _b, _c, _d, _e;
|
|
377
|
+
return ((_c = (_b = (_a = options) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b[name]) === null || _c === void 0 ? void 0 : _c.dataLabels) || ((_e = (_d = options) === null || _d === void 0 ? void 0 : _d.series) === null || _e === void 0 ? void 0 : _e.dataLabels) || {};
|
|
378
|
+
}
|
|
379
|
+
export function makeLineLabelInfo(model, dataLabelOptions) {
|
|
380
|
+
const { value, textAlign, textBaseline } = model;
|
|
381
|
+
const { formatter } = dataLabelOptions;
|
|
382
|
+
return Object.assign(Object.assign({}, model), { x: model.x, y: (model.y + model.y2) / 2, textAlign: (textAlign !== null && textAlign !== void 0 ? textAlign : 'center'), textBaseline: (textBaseline !== null && textBaseline !== void 0 ? textBaseline : 'middle'), text: isString(value) ? value : formatter(value) });
|
|
383
|
+
}
|
|
384
|
+
function hasSameAnchorPieDataLabel(dataLabelOptions) {
|
|
385
|
+
var _a;
|
|
386
|
+
return dataLabelOptions.anchor === ((_a = dataLabelOptions.pieSeriesName) === null || _a === void 0 ? void 0 : _a.anchor);
|
|
387
|
+
}
|
|
388
|
+
function hasSectorCallout(dataLabelOptions) {
|
|
389
|
+
var _a;
|
|
390
|
+
return dataLabelOptions.anchor === 'outer' || ((_a = dataLabelOptions.pieSeriesName) === null || _a === void 0 ? void 0 : _a.anchor) !== 'outer';
|
|
391
|
+
}
|
|
392
|
+
function hasPieSeriesNameCallout(dataLabelOptions) {
|
|
393
|
+
var _a;
|
|
394
|
+
return dataLabelOptions.anchor !== 'outer' || ((_a = dataLabelOptions.pieSeriesName) === null || _a === void 0 ? void 0 : _a.anchor) === 'outer';
|
|
395
|
+
}
|
|
396
|
+
function getPieDataLabelCallout(model, anchor) {
|
|
397
|
+
if (anchor !== 'outer') {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
const { x, y } = getRadialAnchorPosition(makeAnchorPositionParam('outer', Object.assign(Object.assign({}, model), { radius: Object.assign(Object.assign({}, model.radius), { outer: model.radius.outer + CALLOUT_LENGTH }) })));
|
|
401
|
+
const { x: x2, y: y2 } = getRadialAnchorPosition(makeAnchorPositionParam('outer', Object.assign({}, model)));
|
|
402
|
+
const { callout } = model.theme;
|
|
403
|
+
const theme = Object.assign(Object.assign({}, callout), { lineColor: callout.useSeriesColor ? model.color : callout.lineColor });
|
|
404
|
+
return { x, y, x2, y2, theme };
|
|
405
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataToExport } from "../component/exportMenu";
|
|
2
|
+
export declare type SpreadSheetExtension = 'csv' | 'xls';
|
|
3
|
+
declare type ImageExtension = 'png' | 'jpeg';
|
|
4
|
+
declare type Extension = SpreadSheetExtension | ImageExtension;
|
|
5
|
+
export declare function execDownload(fileName: string, extension: Extension, content: string, contentType?: string): void;
|
|
6
|
+
export declare function downloadSpreadSheet(fileName: string, extension: SpreadSheetExtension, data: DataToExport): void;
|
|
7
|
+
export {};
|