@operato/scene-chartjs 9.1.1 → 10.0.0-beta.2
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/dist/chartjs.js +13 -18
- package/dist/chartjs.js.map +1 -1
- package/dist/config-converter.d.ts +5 -1
- package/dist/config-converter.js +248 -273
- package/dist/config-converter.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/ox-chart.d.ts +2 -2
- package/dist/ox-chart.js +81 -67
- package/dist/ox-chart.js.map +1 -1
- package/dist/plugins/chart-series-highlight.d.ts +0 -1
- package/dist/plugins/chart-series-highlight.js +13 -9
- package/dist/plugins/chart-series-highlight.js.map +1 -1
- package/dist/plugins/chartjs-plugin-data-binder.js +1 -1
- package/dist/plugins/chartjs-plugin-data-binder.js.map +1 -1
- package/dist/templates/horizontal-bar-chart.js +1 -1
- package/dist/templates/horizontal-bar-chart.js.map +1 -1
- package/package.json +18 -24
package/dist/config-converter.js
CHANGED
|
@@ -1,150 +1,169 @@
|
|
|
1
1
|
import { TinyColor } from '@ctrl/tinycolor';
|
|
2
2
|
import { format as formatText } from '@operato/utils/format.js';
|
|
3
|
+
/**
|
|
4
|
+
* v2 형식의 scene-chart config를 Chart.js v4 형식으로 변환한다.
|
|
5
|
+
* 기존 보드 설정(v2 형식)을 입력받아 v4 호환 config를 새 객체로 반환.
|
|
6
|
+
*/
|
|
3
7
|
export function convertConfigure(chart) {
|
|
4
8
|
if (!chart)
|
|
5
|
-
return;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
9
|
+
return chart;
|
|
10
|
+
const { type: chartType, data: fromData, options: fromOptions } = chart;
|
|
11
|
+
const options = fromOptions || {};
|
|
12
|
+
const datasets = fromData?.datasets || [];
|
|
13
|
+
const fontSize = Number(options.defaultFontSize) || undefined;
|
|
14
|
+
const fontFamily = options.defaultFontFamily;
|
|
15
|
+
const fontColor = options.defaultFontColor;
|
|
16
|
+
const theme = options.theme;
|
|
17
|
+
const multiAxis = options.multiAxis;
|
|
18
|
+
const stacked = options.stacked;
|
|
19
|
+
const xGridLine = options.xGridLine;
|
|
20
|
+
const yGridLine = options.yGridLine;
|
|
21
|
+
const y2ndGridLine = options.y2ndGridLine;
|
|
22
|
+
const showTooltip = options.tooltip !== false;
|
|
23
|
+
// backward compatible: ensure scales/scale exist
|
|
24
|
+
_ensureBackwardsCompatible(chartType, options);
|
|
25
|
+
const scales = options.scales || {};
|
|
26
|
+
const { xAxes = [], yAxes = [] } = scales;
|
|
27
|
+
// --- Build v4 scales object ---
|
|
28
|
+
const toScales = {};
|
|
29
|
+
const isCartesian = ['line', 'bar', 'horizontalBar'].includes(chartType);
|
|
30
|
+
if (isCartesian) {
|
|
31
|
+
// Determine actual xAxes/yAxes depending on horizontalBar swap
|
|
32
|
+
const actualXAxes = chartType === 'horizontalBar' ? yAxes : xAxes;
|
|
33
|
+
const actualYAxes = chartType === 'horizontalBar' ? xAxes : yAxes;
|
|
34
|
+
actualXAxes.forEach((xAxis, index) => {
|
|
35
|
+
const id = actualXAxes.length > 1 ? `x${index + 1}` : 'x';
|
|
36
|
+
toScales[id] = _buildScale({
|
|
37
|
+
axis: 'x',
|
|
38
|
+
id,
|
|
39
|
+
position: 'bottom',
|
|
40
|
+
display: xAxis.display !== false,
|
|
41
|
+
title: {
|
|
42
|
+
display: !!xAxis.axisTitle,
|
|
43
|
+
text: xAxis.axisTitle
|
|
44
|
+
},
|
|
45
|
+
grid: {
|
|
46
|
+
display: chartType === 'horizontalBar' ? yGridLine : xGridLine
|
|
47
|
+
},
|
|
48
|
+
ticks: xAxis.ticks,
|
|
49
|
+
stacked: stacked || false
|
|
50
|
+
}, { fontSize, fontFamily, fontColor, theme });
|
|
51
|
+
});
|
|
52
|
+
actualYAxes.forEach((yAxis, index) => {
|
|
53
|
+
const id = yAxis.id || (index === 0 ? 'left' : 'right');
|
|
54
|
+
const isSecondary = index > 0 || id === 'right';
|
|
55
|
+
const display = isSecondary ? (multiAxis || false) : (yAxis.display !== false);
|
|
56
|
+
toScales[id] = _buildScale({
|
|
57
|
+
axis: 'y',
|
|
58
|
+
id,
|
|
59
|
+
position: yAxis.position || id,
|
|
60
|
+
display,
|
|
61
|
+
title: {
|
|
62
|
+
display: !!yAxis.axisTitle,
|
|
63
|
+
text: yAxis.axisTitle
|
|
64
|
+
},
|
|
65
|
+
grid: {
|
|
66
|
+
display: isSecondary ? y2ndGridLine : yGridLine
|
|
67
|
+
},
|
|
68
|
+
ticks: yAxis.ticks,
|
|
69
|
+
stacked: stacked || false
|
|
70
|
+
}, { fontSize, fontFamily, fontColor, theme });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// radar/polarArea: handle scale (radial)
|
|
74
|
+
if (chartType === 'radar' || chartType === 'polarArea') {
|
|
75
|
+
const scale = options.scale || {};
|
|
76
|
+
toScales['r'] = {
|
|
77
|
+
type: 'radialLinear',
|
|
78
|
+
ticks: {
|
|
79
|
+
...(scale.ticks || {}),
|
|
80
|
+
backdropColor: options.fillStyle || '#00ff0000'
|
|
81
|
+
},
|
|
82
|
+
pointLabels: {
|
|
83
|
+
font: { size: fontSize, family: fontFamily },
|
|
84
|
+
...(fontColor ? { color: fontColor } : {})
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
if (fontColor) {
|
|
88
|
+
toScales['r'].ticks.color = fontColor;
|
|
45
89
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
90
|
+
}
|
|
91
|
+
// --- Build v4 datasets ---
|
|
92
|
+
// axis → dataset 속성 마이그레이션 (bar thickness 등)
|
|
93
|
+
let barCategoryPercentage;
|
|
94
|
+
let barPercentage;
|
|
95
|
+
let barThickness;
|
|
96
|
+
if (chartType === 'bar' || chartType === 'horizontalBar') {
|
|
97
|
+
const barAxis = chartType === 'bar' ? xAxes[0] : yAxes[0];
|
|
98
|
+
if (barAxis) {
|
|
99
|
+
barCategoryPercentage = barAxis.categorySpacing != null ? 1 - barAxis.categorySpacing : undefined;
|
|
100
|
+
barPercentage = barAxis.barSpacing != null ? 1 - barAxis.barSpacing : undefined;
|
|
101
|
+
barThickness = barAxis.barThickness;
|
|
50
102
|
}
|
|
51
103
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (filtered.length > 1) {
|
|
58
|
-
yStacked[0] = true;
|
|
59
|
-
return;
|
|
104
|
+
const toDatasets = datasets.map((dataset, index) => {
|
|
105
|
+
const series = { ...dataset };
|
|
106
|
+
// horizontalBar series type → bar
|
|
107
|
+
if (series.type === 'horizontalBar') {
|
|
108
|
+
series.type = 'bar';
|
|
60
109
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (filtered.length > 1) {
|
|
65
|
-
yStacked[1] = true;
|
|
66
|
-
return;
|
|
110
|
+
// multiAxis off: all series to left axis
|
|
111
|
+
if (!multiAxis && series.yAxisID === 'right') {
|
|
112
|
+
series.yAxisID = 'left';
|
|
67
113
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// 1-1. setup xAxes
|
|
83
|
-
for (let i in xAxes) {
|
|
84
|
-
let axis = xAxes[i];
|
|
85
|
-
_setStacked(axis, stacked);
|
|
86
|
-
_setScalesFont(axis, {
|
|
87
|
-
fontSize,
|
|
88
|
-
fontFamily
|
|
89
|
-
});
|
|
90
|
-
_setScalesAutoMinMax(axis);
|
|
91
|
-
_setScalesTickRotation(axis);
|
|
92
|
-
_setAxisTitle(axis);
|
|
93
|
-
_setScalesTheme(axis, theme, fontColor);
|
|
94
|
-
_appendTickCallback(axis.ticks);
|
|
95
|
-
axis.gridLines.display = options.xGridLine;
|
|
114
|
+
// bar spacing properties (moved from axis to dataset in v4)
|
|
115
|
+
if (chartType === 'bar' || chartType === 'horizontalBar') {
|
|
116
|
+
if (barCategoryPercentage != null)
|
|
117
|
+
series.categoryPercentage = barCategoryPercentage;
|
|
118
|
+
if (barPercentage != null)
|
|
119
|
+
series.barPercentage = barPercentage;
|
|
120
|
+
if (barThickness != null)
|
|
121
|
+
series.barThickness = barThickness;
|
|
122
|
+
}
|
|
123
|
+
// stack: v4 format
|
|
124
|
+
const isPieType = chartType === 'pie' || chartType === 'doughnut';
|
|
125
|
+
if (!isPieType) {
|
|
126
|
+
if (stacked && !dataset.stack) {
|
|
127
|
+
series.stack = '__all__';
|
|
96
128
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
//@ts-ignore
|
|
101
|
-
if (i == 1) {
|
|
102
|
-
_setMultiAxis(axis, multiAxis);
|
|
103
|
-
}
|
|
104
|
-
_setStacked(axis, yStacked[i]);
|
|
105
|
-
_setScalesFont(axis, {
|
|
106
|
-
fontSize,
|
|
107
|
-
fontFamily
|
|
108
|
-
});
|
|
109
|
-
_setScalesAutoMinMax(axis);
|
|
110
|
-
_setAxisTitle(axis);
|
|
111
|
-
_setScalesTheme(axis, theme, fontColor);
|
|
112
|
-
_appendTickCallback(axis.ticks);
|
|
113
|
-
//@ts-ignore
|
|
114
|
-
if (i == 0)
|
|
115
|
-
axis.gridLines.display = options.yGridLine;
|
|
116
|
-
//@ts-ignore
|
|
117
|
-
if (i == 1)
|
|
118
|
-
axis.gridLines.display = options.y2ndGridLine;
|
|
129
|
+
else {
|
|
130
|
+
const type = series.type || chartType;
|
|
131
|
+
series.stack = `__${type}_${series.yAxisID || 'left'}_${index}__`;
|
|
119
132
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
default:
|
|
125
|
-
scale = options.scale || {};
|
|
126
|
-
_setScalesFont(scale, {
|
|
127
|
-
fontSize,
|
|
128
|
-
fontFamily
|
|
129
|
-
});
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
// 2. setup legend
|
|
133
|
-
_setLegendFont(legend, {
|
|
134
|
-
fontSize,
|
|
135
|
-
fontFamily
|
|
133
|
+
}
|
|
134
|
+
// series visual setup
|
|
135
|
+
_setupSeriesVisuals(series, chartType);
|
|
136
|
+
return series;
|
|
136
137
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
138
|
+
// --- Build converted config ---
|
|
139
|
+
const converted = {
|
|
140
|
+
type: chartType === 'horizontalBar' ? 'bar' : chartType,
|
|
141
|
+
data: {
|
|
142
|
+
labels: fromData?.labels || [],
|
|
143
|
+
datasets: toDatasets,
|
|
144
|
+
labelDataKey: fromData?.labelDataKey
|
|
145
|
+
},
|
|
146
|
+
options: {
|
|
147
|
+
maintainAspectRatio: false,
|
|
148
|
+
animation: options.animation,
|
|
149
|
+
indexAxis: chartType === 'horizontalBar' ? 'y' : undefined,
|
|
150
|
+
scales: isCartesian || chartType === 'radar' || chartType === 'polarArea' ? toScales : undefined,
|
|
151
|
+
plugins: {
|
|
152
|
+
legend: _buildLegend(options.legend || {}, { fontSize, fontFamily, fontColor, theme }),
|
|
153
|
+
tooltip: showTooltip
|
|
154
|
+
? _buildTooltip({ fontSize, fontFamily })
|
|
155
|
+
: { enabled: false },
|
|
156
|
+
},
|
|
157
|
+
// preserve custom properties for datalabels font callback
|
|
158
|
+
defaultFontFamily: fontFamily,
|
|
159
|
+
defaultFontSize: fontSize,
|
|
160
|
+
defaultFontColor: fontColor
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return converted;
|
|
146
164
|
}
|
|
147
|
-
|
|
165
|
+
// --- Helper functions ---
|
|
166
|
+
function _ensureBackwardsCompatible(type, options) {
|
|
148
167
|
switch (type) {
|
|
149
168
|
case 'horizontalBar':
|
|
150
169
|
if (!options.scales)
|
|
@@ -152,16 +171,10 @@ function _configureBackwardsCompatible(type, options) {
|
|
|
152
171
|
break;
|
|
153
172
|
case 'radar':
|
|
154
173
|
case 'polarArea':
|
|
155
|
-
if (options.
|
|
156
|
-
options.scale
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
options.scale.pointLabels = { fontColor: options.defaultFontColor };
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
options.scale.ticks.backdropColor = options.fillStyle ? options.fillStyle : '#00ff0000';
|
|
174
|
+
if (!options.scale)
|
|
175
|
+
options.scale = {};
|
|
176
|
+
if (!options.scale.ticks)
|
|
177
|
+
options.scale.ticks = {};
|
|
165
178
|
break;
|
|
166
179
|
case 'line':
|
|
167
180
|
case 'bar':
|
|
@@ -170,23 +183,15 @@ function _configureBackwardsCompatible(type, options) {
|
|
|
170
183
|
if (!options.scales.yAxes)
|
|
171
184
|
options.scales.yAxes = [];
|
|
172
185
|
if (options.scales.yAxes.length === 1) {
|
|
173
|
-
|
|
174
|
-
yAxes.push({
|
|
186
|
+
options.scales.yAxes.push({
|
|
175
187
|
position: 'right',
|
|
176
188
|
id: 'right',
|
|
177
189
|
display: options.multiAxis || false,
|
|
178
190
|
gridLines: {
|
|
179
|
-
display: (
|
|
191
|
+
display: (options.scales.yAxes[0]?.gridLines?.display) || false
|
|
180
192
|
},
|
|
181
193
|
ticks: {
|
|
182
|
-
beginAtZero: false
|
|
183
|
-
callback: function (value, index, values) {
|
|
184
|
-
var returnValue = value;
|
|
185
|
-
if (typeof returnValue == 'number') {
|
|
186
|
-
returnValue = returnValue.toLocaleString();
|
|
187
|
-
}
|
|
188
|
-
return returnValue;
|
|
189
|
-
}
|
|
194
|
+
beginAtZero: false
|
|
190
195
|
}
|
|
191
196
|
});
|
|
192
197
|
}
|
|
@@ -200,89 +205,91 @@ function _configureBackwardsCompatible(type, options) {
|
|
|
200
205
|
break;
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
|
-
function
|
|
204
|
-
axis.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
axis.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
208
|
+
function _buildScale(axis, { fontSize, fontFamily, fontColor, theme }) {
|
|
209
|
+
const ticks = axis.ticks ? { ...axis.ticks } : {};
|
|
210
|
+
const baseColor = _getBaseColorFromTheme(theme);
|
|
211
|
+
// v4: min/max moved from ticks to scale level
|
|
212
|
+
const result = {
|
|
213
|
+
axis: axis.axis,
|
|
214
|
+
position: axis.position,
|
|
215
|
+
display: axis.display,
|
|
216
|
+
stacked: axis.stacked,
|
|
217
|
+
title: axis.title || {},
|
|
218
|
+
grid: {
|
|
219
|
+
display: axis.grid?.display,
|
|
220
|
+
tickColor: baseColor.clone().setAlpha(0.5).toString(),
|
|
221
|
+
color: baseColor.clone().setAlpha(0.1).toString()
|
|
222
|
+
},
|
|
223
|
+
ticks: {
|
|
224
|
+
display: ticks.display !== false,
|
|
225
|
+
color: fontColor || baseColor.clone().setAlpha(0.5).toString(),
|
|
226
|
+
font: { size: fontSize, family: fontFamily },
|
|
227
|
+
callback: function (value) {
|
|
228
|
+
if (!Number.isNaN(Number(value))) {
|
|
229
|
+
return Number(value).toLocaleString();
|
|
230
|
+
}
|
|
231
|
+
return value;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
225
234
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
let autoMin = axis.ticks.autoMin;
|
|
230
|
-
let autoMax = axis.ticks.autoMax;
|
|
231
|
-
if (autoMin === true) {
|
|
232
|
-
delete axis.ticks.min;
|
|
235
|
+
// autoMin/autoMax handling
|
|
236
|
+
if (ticks.autoMin !== true && ticks.min != null) {
|
|
237
|
+
result.min = ticks.min;
|
|
233
238
|
}
|
|
234
|
-
if (autoMax
|
|
235
|
-
|
|
239
|
+
if (ticks.autoMax !== true && ticks.max != null) {
|
|
240
|
+
result.max = ticks.max;
|
|
236
241
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
axis.ticks = axis.ticks ? axis.ticks : {};
|
|
240
|
-
// axis.ticks.maxRotation = 0
|
|
241
|
-
}
|
|
242
|
-
function _setScalesTheme(axis, theme, fontColor) {
|
|
243
|
-
var baseColor = _getBaseColorFromTheme(theme);
|
|
244
|
-
axis.gridLines = axis.gridLines ? axis.gridLines : {};
|
|
245
|
-
if (axis.gridLines) {
|
|
246
|
-
axis.gridLines.zeroLineColor = baseColor.clone().setAlpha(0.5).toString();
|
|
247
|
-
axis.gridLines.color = baseColor.clone().setAlpha(0.1).toString();
|
|
242
|
+
if (ticks.beginAtZero) {
|
|
243
|
+
result.beginAtZero = true;
|
|
248
244
|
}
|
|
249
|
-
|
|
250
|
-
axis.ticks.fontColor = fontColor ? fontColor : baseColor.clone().setAlpha(0.5).toString();
|
|
251
|
-
}
|
|
252
|
-
function _setLegendFont(legend, { fontFamily, fontSize }) {
|
|
253
|
-
legend.labels = legend.labels ? legend.labels : {};
|
|
254
|
-
legend.labels.fontSize = fontSize;
|
|
255
|
-
if (fontFamily)
|
|
256
|
-
legend.labels.fontFamily = fontFamily;
|
|
245
|
+
return result;
|
|
257
246
|
}
|
|
258
|
-
function
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
247
|
+
function _buildLegend(legend, { fontSize, fontFamily, fontColor, theme }) {
|
|
248
|
+
const baseColor = _getBaseColorFromTheme(theme);
|
|
249
|
+
const color = fontColor || baseColor.clone().setAlpha(0.5).toString();
|
|
250
|
+
return {
|
|
251
|
+
display: legend.display,
|
|
252
|
+
position: legend.position,
|
|
253
|
+
labels: {
|
|
254
|
+
boxWidth: 15,
|
|
255
|
+
color,
|
|
256
|
+
font: { size: fontSize, family: fontFamily }
|
|
257
|
+
}
|
|
258
|
+
};
|
|
262
259
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
260
|
+
function _buildTooltip({ fontSize, fontFamily }) {
|
|
261
|
+
return {
|
|
262
|
+
enabled: true,
|
|
263
|
+
mode: 'index',
|
|
264
|
+
intersect: false,
|
|
265
|
+
titleFont: { size: fontSize, family: fontFamily },
|
|
266
|
+
bodyFont: { size: fontSize, family: fontFamily },
|
|
267
|
+
footerFont: { size: fontSize, family: fontFamily },
|
|
268
|
+
callbacks: {
|
|
269
|
+
label: function (context) {
|
|
270
|
+
const dataset = context.dataset;
|
|
271
|
+
const value = context.parsed?.y ?? context.parsed ?? context.raw;
|
|
272
|
+
const label = dataset.label || context.label || '';
|
|
273
|
+
const format = dataset.valueFormat || '';
|
|
274
|
+
const prefix = dataset.valuePrefix || '';
|
|
275
|
+
const suffix = dataset.valueSuffix || '';
|
|
276
|
+
const stringValue = format ? formatText(format, Number(value)) : Number(value).toLocaleString();
|
|
277
|
+
return `${label}: ${prefix + stringValue + suffix}`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
278
281
|
}
|
|
279
|
-
function
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
function _setupSeriesVisuals(series, chartType) {
|
|
283
|
+
const type = series.type || chartType;
|
|
284
|
+
const color = (() => {
|
|
285
|
+
switch (type) {
|
|
286
|
+
case 'line':
|
|
287
|
+
case 'radar':
|
|
288
|
+
return series.color || series.borderColor;
|
|
289
|
+
default:
|
|
290
|
+
return series.color || series.backgroundColor;
|
|
291
|
+
}
|
|
292
|
+
})();
|
|
286
293
|
switch (type) {
|
|
287
294
|
case 'bar':
|
|
288
295
|
case 'horizontalBar':
|
|
@@ -290,57 +297,25 @@ function _setSeriesConfigures(series, chart) {
|
|
|
290
297
|
break;
|
|
291
298
|
case 'line':
|
|
292
299
|
case 'radar':
|
|
293
|
-
color = series.color ? series.color : series.borderColor;
|
|
294
300
|
series.pointBackgroundColor = series.pointBorderColor = series.borderColor = series.backgroundColor = color;
|
|
295
|
-
series.pointBorderWidth = series.borderWidth * 0.5;
|
|
301
|
+
series.pointBorderWidth = (series.borderWidth || 0) * 0.5;
|
|
296
302
|
series.pointHoverRadius = series.pointRadius;
|
|
297
303
|
if (series.fill == undefined)
|
|
298
304
|
series.fill = false;
|
|
305
|
+
// v2 lineTension → v4 tension
|
|
306
|
+
if (series.lineTension != null && series.tension == null) {
|
|
307
|
+
series.tension = series.lineTension;
|
|
308
|
+
}
|
|
299
309
|
break;
|
|
300
310
|
default:
|
|
301
311
|
series.borderColor = series.backgroundColor = color;
|
|
302
312
|
break;
|
|
303
313
|
}
|
|
304
|
-
series.
|
|
305
|
-
series.
|
|
306
|
-
series.
|
|
307
|
-
series.dataLabelRotation = dataLabelRotation;
|
|
314
|
+
series.dataLabelAnchor = series.dataLabelAnchor || 'center';
|
|
315
|
+
series.dataLabelOffset = series.dataLabelOffset || 0;
|
|
316
|
+
series.dataLabelRotation = series.dataLabelRotation || 0;
|
|
308
317
|
}
|
|
309
|
-
function
|
|
310
|
-
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
ticks.callback = function (value, index, values) {
|
|
314
|
-
var returnValue;
|
|
315
|
-
if (!Number.isNaN(Number(value))) {
|
|
316
|
-
returnValue = Number(value).toLocaleString();
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
returnValue = value;
|
|
320
|
-
}
|
|
321
|
-
if (returnValue)
|
|
322
|
-
return returnValue;
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
function _setTooltipFont(tooltips, { fontSize, fontFamily }) {
|
|
326
|
-
tooltips.titleFontSize = tooltips.bodyFontSize = tooltips.footerFontSize = fontSize;
|
|
327
|
-
if (fontFamily)
|
|
328
|
-
tooltips.titleFontFamily = tooltips.bodyFontFamily = tooltips.footerFontFamily = fontFamily;
|
|
329
|
-
}
|
|
330
|
-
function _setTooltipCallback(tooltips) {
|
|
331
|
-
tooltips.callbacks = tooltips.callbacks || {};
|
|
332
|
-
tooltips.intersect = false;
|
|
333
|
-
tooltips.mode = 'index';
|
|
334
|
-
tooltips.callbacks.label = function (tooltipItem, data) {
|
|
335
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
336
|
-
var value = (_b = (_a = data.datasets) === null || _a === void 0 ? void 0 : _a[tooltipItem.datasetIndex || 0].data) === null || _b === void 0 ? void 0 : _b[tooltipItem.index || 0];
|
|
337
|
-
var datasetLabel = (_c = data.datasets) === null || _c === void 0 ? void 0 : _c[tooltipItem.datasetIndex || 0].label;
|
|
338
|
-
var label = datasetLabel || ((_d = data.labels) === null || _d === void 0 ? void 0 : _d[tooltipItem.index || 0]);
|
|
339
|
-
var format = ((_e = data.datasets) === null || _e === void 0 ? void 0 : _e[tooltipItem.datasetIndex || 0].valueFormat) || '';
|
|
340
|
-
var prefix = ((_f = data.datasets) === null || _f === void 0 ? void 0 : _f[tooltipItem.datasetIndex || 0].valuePrefix) || '';
|
|
341
|
-
var suffix = ((_g = data.datasets) === null || _g === void 0 ? void 0 : _g[tooltipItem.datasetIndex || 0].valueSuffix) || '';
|
|
342
|
-
var stringValue = format ? formatText(format, Number(value)) : Number(value).toLocaleString();
|
|
343
|
-
return `${label}: ${prefix + stringValue + suffix}`;
|
|
344
|
-
};
|
|
318
|
+
function _getBaseColorFromTheme(theme) {
|
|
319
|
+
return new TinyColor(theme === 'light' ? '#fff' : '#000');
|
|
345
320
|
}
|
|
346
321
|
//# sourceMappingURL=config-converter.js.map
|