@progress/kendo-charts 2.8.2 → 2.9.0-develop.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/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/chart/chart.js +31 -0
- package/dist/es/chart/theme/load-theme.js +100 -36
- package/dist/es/common/style-observer.js +43 -0
- package/dist/es2015/chart/chart.js +31 -0
- package/dist/es2015/chart/theme/load-theme.js +100 -36
- package/dist/es2015/common/style-observer.js +43 -0
- package/dist/npm/main.js +421 -280
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +1 -1
package/dist/es/chart/chart.js
CHANGED
|
@@ -32,6 +32,8 @@ import { DRAG_START, DRAG, DRAG_END, ZOOM_START, ZOOM, ZOOM_END, SELECT_START, S
|
|
|
32
32
|
import './animations';
|
|
33
33
|
import './register-charts';
|
|
34
34
|
import { parseDateCategory } from './utils';
|
|
35
|
+
import { setupStyleObserver } from '../common/style-observer';
|
|
36
|
+
import { chartCSSVariables } from './theme/load-theme';
|
|
35
37
|
|
|
36
38
|
const AXIS_NAMES = [ CATEGORY, VALUE, X, Y ];
|
|
37
39
|
|
|
@@ -73,10 +75,27 @@ class Chart {
|
|
|
73
75
|
this._redraw();
|
|
74
76
|
this._attachEvents();
|
|
75
77
|
this._restoreOverlayElement();
|
|
78
|
+
this._initStyleObserver();
|
|
76
79
|
}
|
|
77
80
|
});
|
|
78
81
|
}
|
|
79
82
|
|
|
83
|
+
_initStyleObserver() {
|
|
84
|
+
this._destroyStyleObserver();
|
|
85
|
+
if (this.options.observeStyles) {
|
|
86
|
+
this._stylesObserver = setupStyleObserver(this.element, () => {
|
|
87
|
+
this.trigger("styleChanged");
|
|
88
|
+
}, Object.values(chartCSSVariables));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
_destroyStyleObserver() {
|
|
93
|
+
if (this._stylesObserver) {
|
|
94
|
+
this._stylesObserver.disconnect();
|
|
95
|
+
this._stylesObserver = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
80
99
|
_initElement(element) {
|
|
81
100
|
this._setElementClass(element);
|
|
82
101
|
element.style.position = "relative";
|
|
@@ -1993,6 +2012,14 @@ class Chart {
|
|
|
1993
2012
|
}
|
|
1994
2013
|
}
|
|
1995
2014
|
|
|
2015
|
+
applyTheme(theme) {
|
|
2016
|
+
const options = Object.assign({}, this._originalOptions);
|
|
2017
|
+
requestAnimationFrame(() => {
|
|
2018
|
+
this.applyOptions(options, theme);
|
|
2019
|
+
this.noTransitionsRedraw();
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
|
|
1996
2023
|
applyOptions(options, theme) {
|
|
1997
2024
|
clearMissingValues(this._originalOptions, options);
|
|
1998
2025
|
this._originalOptions = deepExtend(this._originalOptions, options);
|
|
@@ -2013,6 +2040,7 @@ class Chart {
|
|
|
2013
2040
|
this.redraw();
|
|
2014
2041
|
this.updateMouseMoveHandler();
|
|
2015
2042
|
this._restoreOverlayElement();
|
|
2043
|
+
this._initStyleObserver();
|
|
2016
2044
|
}
|
|
2017
2045
|
|
|
2018
2046
|
setDirection(rtl) {
|
|
@@ -2063,6 +2091,8 @@ class Chart {
|
|
|
2063
2091
|
this._destroySurface();
|
|
2064
2092
|
|
|
2065
2093
|
this._clearRedrawTimeout();
|
|
2094
|
+
|
|
2095
|
+
this._destroyStyleObserver();
|
|
2066
2096
|
}
|
|
2067
2097
|
|
|
2068
2098
|
_destroySurface() {
|
|
@@ -2320,6 +2350,7 @@ setDefaultOptions(Chart, {
|
|
|
2320
2350
|
visible: false
|
|
2321
2351
|
},
|
|
2322
2352
|
transitions: true,
|
|
2353
|
+
observeStyles: false,
|
|
2323
2354
|
valueAxis: {
|
|
2324
2355
|
narrowRange: false
|
|
2325
2356
|
},
|
|
@@ -33,6 +33,11 @@ const getFont = (element, weightProp, sizeProp, familyProp) => {
|
|
|
33
33
|
return [styles.getPropertyValue(weightProp), styles.getPropertyValue(sizeProp), styles.getPropertyValue(familyProp) || styles.fontFamily].join(" ");
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
const seriesColorsVars = {};
|
|
37
|
+
for (let i = 1; i <= SERIES_COLORS; i++) {
|
|
38
|
+
seriesColorsVars[`series-color-${i}`] = `${seriesVar}${i}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
const getSeriesColors = (element) => {
|
|
37
42
|
const styles = elementStyles(element);
|
|
38
43
|
const result = [];
|
|
@@ -46,13 +51,61 @@ const getSeriesColors = (element) => {
|
|
|
46
51
|
return result;
|
|
47
52
|
};
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
// -----------------------------------------------------------------------------
|
|
55
|
+
// CSS Variable Groups (shared + component specific)
|
|
56
|
+
// -----------------------------------------------------------------------------
|
|
57
|
+
export const sharedVariables = {
|
|
58
|
+
text: "--kendo-chart-text",
|
|
59
|
+
chartBg: "--kendo-chart-bg",
|
|
60
|
+
fontWeight: "--kendo-font-weight",
|
|
61
|
+
fontFamily: "--kendo-font-family",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Chart-specific variables (in addition to shared)
|
|
65
|
+
const chartVariables = {
|
|
66
|
+
majorLines: "--kendo-chart-major-lines",
|
|
67
|
+
minorLines: "--kendo-chart-minor-lines",
|
|
68
|
+
areaOpacity: "--kendo-chart-area-opacity",
|
|
69
|
+
surface: "--kendo-color-surface",
|
|
70
|
+
primaryBg: "--kendo-chart-primary-bg",
|
|
71
|
+
crosshairBg: "--kendo-chart-crosshair-bg",
|
|
72
|
+
axisLabelFontSize: "--kendo-chart-label-font-size",
|
|
73
|
+
axisLabelFontWeight: "--kendo-font-weight",
|
|
74
|
+
axisLabelFontFamily: "--kendo-font-family",
|
|
75
|
+
chartFontSize: "--kendo-chart-font-size", // used by defaultFont / legend labels
|
|
76
|
+
paneTitleFontSize: "--kendo-chart-pane-title-font-size",
|
|
77
|
+
paneTitleFontWeight: "--kendo-chart-pane-title-font-weight",
|
|
78
|
+
titleFontSize: "--kendo-chart-title-font-size",
|
|
79
|
+
titleFontWeight: "--kendo-font-weight",
|
|
80
|
+
errorBarsBg: "--kendo-chart-error-bars-bg",
|
|
81
|
+
areaInactiveOpacity: "--kendo-chart-area-inactive-opacity",
|
|
82
|
+
lineInactiveOpacity: "--kendo-chart-line-inactive-opacity",
|
|
83
|
+
bulletTarget: "--kendo-chart-bullet-target",
|
|
84
|
+
notesBg: "--kendo-chart-notes-bg",
|
|
85
|
+
notesBorder: "--kendo-chart-notes-border",
|
|
86
|
+
notesLines: "--kendo-chart-notes-lines",
|
|
87
|
+
inactive: "--kendo-chart-inactive"
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Sankey-specific variables (in addition to shared)
|
|
91
|
+
const sankeyVariables = {
|
|
92
|
+
linksColor: "--kendo-color-subtle",
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Gauge-specific variables (in addition to shared)
|
|
96
|
+
const gaugeVariables = {
|
|
97
|
+
gaugePointer: "--kendo-chart-gauge-pointer",
|
|
98
|
+
gaugeTrack: "--kendo-chart-gauge-track",
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Font & color helpers using variable objects (avoid raw CSS strings)
|
|
102
|
+
const defaultFont = element => getFont(element, sharedVariables.fontWeight, chartVariables.chartFontSize, sharedVariables.fontFamily);
|
|
103
|
+
const paneTitleFont = (element) => getFont(element, chartVariables.paneTitleFontWeight, chartVariables.paneTitleFontSize, sharedVariables.fontFamily);
|
|
104
|
+
const normalTextColor = (element) => getProp(element, sharedVariables.text);
|
|
52
105
|
|
|
53
106
|
const title = (element) => ({
|
|
54
107
|
color: normalTextColor(element),
|
|
55
|
-
font: getFont(element,
|
|
108
|
+
font: getFont(element, sharedVariables.fontWeight, chartVariables.titleFontSize, sharedVariables.fontFamily),
|
|
56
109
|
});
|
|
57
110
|
|
|
58
111
|
const sankeyLegend = (element) => {
|
|
@@ -69,7 +122,7 @@ const sankeyLegend = (element) => {
|
|
|
69
122
|
};
|
|
70
123
|
|
|
71
124
|
const chartLegend = (element) => {
|
|
72
|
-
const inactiveColor = getProp(element,
|
|
125
|
+
const inactiveColor = getProp(element, chartVariables.inactive);
|
|
73
126
|
return Object.assign({}, {inactiveItems: {
|
|
74
127
|
labels: {
|
|
75
128
|
color: inactiveColor,
|
|
@@ -80,19 +133,24 @@ const chartLegend = (element) => {
|
|
|
80
133
|
}},
|
|
81
134
|
sankeyLegend(element));
|
|
82
135
|
};
|
|
136
|
+
// Export composed variable objects
|
|
137
|
+
export const chartCSSVariables = Object.assign({}, sharedVariables, chartVariables, seriesColorsVars);
|
|
138
|
+
export const sankeyCSSVariables = Object.assign({}, sharedVariables, sankeyVariables, seriesColorsVars);
|
|
139
|
+
export const gaugeCSSVariables = Object.assign({}, sharedVariables, gaugeVariables);
|
|
83
140
|
|
|
84
141
|
export const gaugeTheme = (element) => {
|
|
142
|
+
const vars = gaugeCSSVariables;
|
|
85
143
|
const textColorNormal = normalTextColor(element);
|
|
86
144
|
return {
|
|
87
145
|
pointer: {
|
|
88
|
-
color: getProp(element,
|
|
146
|
+
color: getProp(element, vars.gaugePointer)
|
|
89
147
|
},
|
|
90
148
|
scale: {
|
|
91
149
|
labels: {
|
|
92
150
|
color: textColorNormal
|
|
93
151
|
},
|
|
94
152
|
|
|
95
|
-
rangePlaceholderColor: getProp(element,
|
|
153
|
+
rangePlaceholderColor: getProp(element, vars.gaugeTrack),
|
|
96
154
|
|
|
97
155
|
minorTicks: {
|
|
98
156
|
color: textColorNormal
|
|
@@ -109,46 +167,52 @@ export const gaugeTheme = (element) => {
|
|
|
109
167
|
};
|
|
110
168
|
};
|
|
111
169
|
|
|
112
|
-
export const sankeyTheme = (element) =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
170
|
+
export const sankeyTheme = (element) => {
|
|
171
|
+
const vars = sankeyCSSVariables;
|
|
172
|
+
return {
|
|
173
|
+
labels: {
|
|
174
|
+
color: normalTextColor(element),
|
|
175
|
+
font: defaultFont(element),
|
|
176
|
+
stroke: {
|
|
177
|
+
color: getProp(element, vars.chartBg),
|
|
178
|
+
},
|
|
118
179
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
180
|
+
links: {
|
|
181
|
+
color: getProp(element, vars.linksColor),
|
|
182
|
+
},
|
|
183
|
+
nodeColors: getSeriesColors(element),
|
|
184
|
+
title: title(element),
|
|
185
|
+
legend: sankeyLegend(element),
|
|
186
|
+
};
|
|
187
|
+
};
|
|
127
188
|
|
|
128
189
|
const notes = (element) => ({
|
|
129
190
|
icon: {
|
|
130
|
-
background: getProp(element,
|
|
191
|
+
background: getProp(element, chartVariables.notesBg),
|
|
131
192
|
border: {
|
|
132
|
-
color: getProp(element,
|
|
193
|
+
color: getProp(element, chartVariables.notesBorder),
|
|
133
194
|
},
|
|
134
195
|
},
|
|
135
196
|
line: {
|
|
136
|
-
color: getProp(element,
|
|
197
|
+
color: getProp(element, chartVariables.notesLines),
|
|
137
198
|
},
|
|
138
199
|
label: {
|
|
139
200
|
font: defaultFont(element),
|
|
140
201
|
},
|
|
141
202
|
});
|
|
142
203
|
|
|
204
|
+
// (chartCSSVariables already exported above via composition)
|
|
205
|
+
|
|
143
206
|
export const chartTheme = (element) => {
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const
|
|
207
|
+
const vars = chartCSSVariables;
|
|
208
|
+
const majorLines = getProp(element, vars.majorLines);
|
|
209
|
+
const normalTextColor = getProp(element, vars.text);
|
|
210
|
+
const axisLabelFont = getFont(element, vars.axisLabelFontWeight, vars.axisLabelFontSize, vars.axisLabelFontFamily);
|
|
211
|
+
const chartBg = getProp(element, vars.chartBg);
|
|
148
212
|
const notesProps = notes(element);
|
|
149
|
-
const areaOpacity = getNumberProp(element,
|
|
150
|
-
const surfaceColor = getProp(element,
|
|
151
|
-
const primaryBg = getProp(element,
|
|
213
|
+
const areaOpacity = getNumberProp(element, vars.areaOpacity);
|
|
214
|
+
const surfaceColor = getProp(element, vars.surface);
|
|
215
|
+
const primaryBg = getProp(element, vars.primaryBg);
|
|
152
216
|
|
|
153
217
|
const boxPlot = () => ({
|
|
154
218
|
downColor: majorLines,
|
|
@@ -172,13 +236,13 @@ export const chartTheme = (element) => {
|
|
|
172
236
|
const area = () => ({
|
|
173
237
|
opacity: areaOpacity,
|
|
174
238
|
highlight: {
|
|
175
|
-
inactiveOpacity: getNumberProp(element,
|
|
239
|
+
inactiveOpacity: getNumberProp(element, vars.areaInactiveOpacity),
|
|
176
240
|
},
|
|
177
241
|
});
|
|
178
242
|
|
|
179
243
|
const line = () => ({
|
|
180
244
|
highlight: {
|
|
181
|
-
inactiveOpacity: getNumberProp(element,
|
|
245
|
+
inactiveOpacity: getNumberProp(element, vars.lineInactiveOpacity),
|
|
182
246
|
},
|
|
183
247
|
});
|
|
184
248
|
|
|
@@ -191,7 +255,7 @@ export const chartTheme = (element) => {
|
|
|
191
255
|
return {
|
|
192
256
|
axisDefaults: {
|
|
193
257
|
crosshair: {
|
|
194
|
-
color: getProp(element,
|
|
258
|
+
color: getProp(element, vars.crosshairBg),
|
|
195
259
|
},
|
|
196
260
|
labels: {
|
|
197
261
|
color: normalTextColor,
|
|
@@ -204,7 +268,7 @@ export const chartTheme = (element) => {
|
|
|
204
268
|
color: majorLines,
|
|
205
269
|
},
|
|
206
270
|
minorGridLines: {
|
|
207
|
-
color: getProp(element,
|
|
271
|
+
color: getProp(element, vars.minorLines),
|
|
208
272
|
},
|
|
209
273
|
notes: structuredClone(notesProps),
|
|
210
274
|
title: {
|
|
@@ -241,7 +305,7 @@ export const chartTheme = (element) => {
|
|
|
241
305
|
},
|
|
242
306
|
},
|
|
243
307
|
errorBars: {
|
|
244
|
-
color: getProp(element,
|
|
308
|
+
color: getProp(element, vars.errorBarsBg),
|
|
245
309
|
},
|
|
246
310
|
icon: {
|
|
247
311
|
border: {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export function setupStyleObserver(element, callback, properties) {
|
|
2
|
+
const curStyles = getComputedStyle(element);
|
|
3
|
+
const values = new Map();
|
|
4
|
+
properties.forEach(prop => {
|
|
5
|
+
values.set(prop, curStyles.getPropertyValue(prop));
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
let rafPending = false;
|
|
9
|
+
|
|
10
|
+
const check = () => {
|
|
11
|
+
if (!element.isConnected) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
let changed = false;
|
|
15
|
+
properties.forEach(prop => {
|
|
16
|
+
const newValue = curStyles.getPropertyValue(prop);
|
|
17
|
+
if (values.get(prop) !== newValue) {
|
|
18
|
+
values.set(prop, newValue);
|
|
19
|
+
changed = true;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if (changed) {
|
|
23
|
+
callback();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const interval = setInterval(() => {
|
|
28
|
+
if (!rafPending) {
|
|
29
|
+
rafPending = true;
|
|
30
|
+
requestAnimationFrame(() => {
|
|
31
|
+
rafPending = false;
|
|
32
|
+
check();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}, 500);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
disconnect: () => {
|
|
39
|
+
clearInterval(interval);
|
|
40
|
+
values.clear();
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -32,6 +32,8 @@ import { DRAG_START, DRAG, DRAG_END, ZOOM_START, ZOOM, ZOOM_END, SELECT_START, S
|
|
|
32
32
|
import './animations';
|
|
33
33
|
import './register-charts';
|
|
34
34
|
import { parseDateCategory } from './utils';
|
|
35
|
+
import { setupStyleObserver } from '../common/style-observer';
|
|
36
|
+
import { chartCSSVariables } from './theme/load-theme';
|
|
35
37
|
|
|
36
38
|
const AXIS_NAMES = [ CATEGORY, VALUE, X, Y ];
|
|
37
39
|
|
|
@@ -73,10 +75,27 @@ class Chart {
|
|
|
73
75
|
this._redraw();
|
|
74
76
|
this._attachEvents();
|
|
75
77
|
this._restoreOverlayElement();
|
|
78
|
+
this._initStyleObserver();
|
|
76
79
|
}
|
|
77
80
|
});
|
|
78
81
|
}
|
|
79
82
|
|
|
83
|
+
_initStyleObserver() {
|
|
84
|
+
this._destroyStyleObserver();
|
|
85
|
+
if (this.options.observeStyles) {
|
|
86
|
+
this._stylesObserver = setupStyleObserver(this.element, () => {
|
|
87
|
+
this.trigger("styleChanged");
|
|
88
|
+
}, Object.values(chartCSSVariables));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
_destroyStyleObserver() {
|
|
93
|
+
if (this._stylesObserver) {
|
|
94
|
+
this._stylesObserver.disconnect();
|
|
95
|
+
this._stylesObserver = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
80
99
|
_initElement(element) {
|
|
81
100
|
this._setElementClass(element);
|
|
82
101
|
element.style.position = "relative";
|
|
@@ -1993,6 +2012,14 @@ class Chart {
|
|
|
1993
2012
|
}
|
|
1994
2013
|
}
|
|
1995
2014
|
|
|
2015
|
+
applyTheme(theme) {
|
|
2016
|
+
const options = Object.assign({}, this._originalOptions);
|
|
2017
|
+
requestAnimationFrame(() => {
|
|
2018
|
+
this.applyOptions(options, theme);
|
|
2019
|
+
this.noTransitionsRedraw();
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
|
|
1996
2023
|
applyOptions(options, theme) {
|
|
1997
2024
|
clearMissingValues(this._originalOptions, options);
|
|
1998
2025
|
this._originalOptions = deepExtend(this._originalOptions, options);
|
|
@@ -2013,6 +2040,7 @@ class Chart {
|
|
|
2013
2040
|
this.redraw();
|
|
2014
2041
|
this.updateMouseMoveHandler();
|
|
2015
2042
|
this._restoreOverlayElement();
|
|
2043
|
+
this._initStyleObserver();
|
|
2016
2044
|
}
|
|
2017
2045
|
|
|
2018
2046
|
setDirection(rtl) {
|
|
@@ -2063,6 +2091,8 @@ class Chart {
|
|
|
2063
2091
|
this._destroySurface();
|
|
2064
2092
|
|
|
2065
2093
|
this._clearRedrawTimeout();
|
|
2094
|
+
|
|
2095
|
+
this._destroyStyleObserver();
|
|
2066
2096
|
}
|
|
2067
2097
|
|
|
2068
2098
|
_destroySurface() {
|
|
@@ -2320,6 +2350,7 @@ setDefaultOptions(Chart, {
|
|
|
2320
2350
|
visible: false
|
|
2321
2351
|
},
|
|
2322
2352
|
transitions: true,
|
|
2353
|
+
observeStyles: false,
|
|
2323
2354
|
valueAxis: {
|
|
2324
2355
|
narrowRange: false
|
|
2325
2356
|
},
|
|
@@ -33,6 +33,11 @@ const getFont = (element, weightProp, sizeProp, familyProp) => {
|
|
|
33
33
|
return [styles.getPropertyValue(weightProp), styles.getPropertyValue(sizeProp), styles.getPropertyValue(familyProp) || styles.fontFamily].join(" ");
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
const seriesColorsVars = {};
|
|
37
|
+
for (let i = 1; i <= SERIES_COLORS; i++) {
|
|
38
|
+
seriesColorsVars[`series-color-${i}`] = `${seriesVar}${i}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
const getSeriesColors = (element) => {
|
|
37
42
|
const styles = elementStyles(element);
|
|
38
43
|
const result = [];
|
|
@@ -46,13 +51,61 @@ const getSeriesColors = (element) => {
|
|
|
46
51
|
return result;
|
|
47
52
|
};
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
// -----------------------------------------------------------------------------
|
|
55
|
+
// CSS Variable Groups (shared + component specific)
|
|
56
|
+
// -----------------------------------------------------------------------------
|
|
57
|
+
export const sharedVariables = {
|
|
58
|
+
text: "--kendo-chart-text",
|
|
59
|
+
chartBg: "--kendo-chart-bg",
|
|
60
|
+
fontWeight: "--kendo-font-weight",
|
|
61
|
+
fontFamily: "--kendo-font-family",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Chart-specific variables (in addition to shared)
|
|
65
|
+
const chartVariables = {
|
|
66
|
+
majorLines: "--kendo-chart-major-lines",
|
|
67
|
+
minorLines: "--kendo-chart-minor-lines",
|
|
68
|
+
areaOpacity: "--kendo-chart-area-opacity",
|
|
69
|
+
surface: "--kendo-color-surface",
|
|
70
|
+
primaryBg: "--kendo-chart-primary-bg",
|
|
71
|
+
crosshairBg: "--kendo-chart-crosshair-bg",
|
|
72
|
+
axisLabelFontSize: "--kendo-chart-label-font-size",
|
|
73
|
+
axisLabelFontWeight: "--kendo-font-weight",
|
|
74
|
+
axisLabelFontFamily: "--kendo-font-family",
|
|
75
|
+
chartFontSize: "--kendo-chart-font-size", // used by defaultFont / legend labels
|
|
76
|
+
paneTitleFontSize: "--kendo-chart-pane-title-font-size",
|
|
77
|
+
paneTitleFontWeight: "--kendo-chart-pane-title-font-weight",
|
|
78
|
+
titleFontSize: "--kendo-chart-title-font-size",
|
|
79
|
+
titleFontWeight: "--kendo-font-weight",
|
|
80
|
+
errorBarsBg: "--kendo-chart-error-bars-bg",
|
|
81
|
+
areaInactiveOpacity: "--kendo-chart-area-inactive-opacity",
|
|
82
|
+
lineInactiveOpacity: "--kendo-chart-line-inactive-opacity",
|
|
83
|
+
bulletTarget: "--kendo-chart-bullet-target",
|
|
84
|
+
notesBg: "--kendo-chart-notes-bg",
|
|
85
|
+
notesBorder: "--kendo-chart-notes-border",
|
|
86
|
+
notesLines: "--kendo-chart-notes-lines",
|
|
87
|
+
inactive: "--kendo-chart-inactive"
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Sankey-specific variables (in addition to shared)
|
|
91
|
+
const sankeyVariables = {
|
|
92
|
+
linksColor: "--kendo-color-subtle",
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Gauge-specific variables (in addition to shared)
|
|
96
|
+
const gaugeVariables = {
|
|
97
|
+
gaugePointer: "--kendo-chart-gauge-pointer",
|
|
98
|
+
gaugeTrack: "--kendo-chart-gauge-track",
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Font & color helpers using variable objects (avoid raw CSS strings)
|
|
102
|
+
const defaultFont = element => getFont(element, sharedVariables.fontWeight, chartVariables.chartFontSize, sharedVariables.fontFamily);
|
|
103
|
+
const paneTitleFont = (element) => getFont(element, chartVariables.paneTitleFontWeight, chartVariables.paneTitleFontSize, sharedVariables.fontFamily);
|
|
104
|
+
const normalTextColor = (element) => getProp(element, sharedVariables.text);
|
|
52
105
|
|
|
53
106
|
const title = (element) => ({
|
|
54
107
|
color: normalTextColor(element),
|
|
55
|
-
font: getFont(element,
|
|
108
|
+
font: getFont(element, sharedVariables.fontWeight, chartVariables.titleFontSize, sharedVariables.fontFamily),
|
|
56
109
|
});
|
|
57
110
|
|
|
58
111
|
const sankeyLegend = (element) => {
|
|
@@ -69,7 +122,7 @@ const sankeyLegend = (element) => {
|
|
|
69
122
|
};
|
|
70
123
|
|
|
71
124
|
const chartLegend = (element) => {
|
|
72
|
-
const inactiveColor = getProp(element,
|
|
125
|
+
const inactiveColor = getProp(element, chartVariables.inactive);
|
|
73
126
|
return Object.assign({}, {inactiveItems: {
|
|
74
127
|
labels: {
|
|
75
128
|
color: inactiveColor,
|
|
@@ -80,19 +133,24 @@ const chartLegend = (element) => {
|
|
|
80
133
|
}},
|
|
81
134
|
sankeyLegend(element));
|
|
82
135
|
};
|
|
136
|
+
// Export composed variable objects
|
|
137
|
+
export const chartCSSVariables = Object.assign({}, sharedVariables, chartVariables, seriesColorsVars);
|
|
138
|
+
export const sankeyCSSVariables = Object.assign({}, sharedVariables, sankeyVariables, seriesColorsVars);
|
|
139
|
+
export const gaugeCSSVariables = Object.assign({}, sharedVariables, gaugeVariables);
|
|
83
140
|
|
|
84
141
|
export const gaugeTheme = (element) => {
|
|
142
|
+
const vars = gaugeCSSVariables;
|
|
85
143
|
const textColorNormal = normalTextColor(element);
|
|
86
144
|
return {
|
|
87
145
|
pointer: {
|
|
88
|
-
color: getProp(element,
|
|
146
|
+
color: getProp(element, vars.gaugePointer)
|
|
89
147
|
},
|
|
90
148
|
scale: {
|
|
91
149
|
labels: {
|
|
92
150
|
color: textColorNormal
|
|
93
151
|
},
|
|
94
152
|
|
|
95
|
-
rangePlaceholderColor: getProp(element,
|
|
153
|
+
rangePlaceholderColor: getProp(element, vars.gaugeTrack),
|
|
96
154
|
|
|
97
155
|
minorTicks: {
|
|
98
156
|
color: textColorNormal
|
|
@@ -109,46 +167,52 @@ export const gaugeTheme = (element) => {
|
|
|
109
167
|
};
|
|
110
168
|
};
|
|
111
169
|
|
|
112
|
-
export const sankeyTheme = (element) =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
170
|
+
export const sankeyTheme = (element) => {
|
|
171
|
+
const vars = sankeyCSSVariables;
|
|
172
|
+
return {
|
|
173
|
+
labels: {
|
|
174
|
+
color: normalTextColor(element),
|
|
175
|
+
font: defaultFont(element),
|
|
176
|
+
stroke: {
|
|
177
|
+
color: getProp(element, vars.chartBg),
|
|
178
|
+
},
|
|
118
179
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
180
|
+
links: {
|
|
181
|
+
color: getProp(element, vars.linksColor),
|
|
182
|
+
},
|
|
183
|
+
nodeColors: getSeriesColors(element),
|
|
184
|
+
title: title(element),
|
|
185
|
+
legend: sankeyLegend(element),
|
|
186
|
+
};
|
|
187
|
+
};
|
|
127
188
|
|
|
128
189
|
const notes = (element) => ({
|
|
129
190
|
icon: {
|
|
130
|
-
background: getProp(element,
|
|
191
|
+
background: getProp(element, chartVariables.notesBg),
|
|
131
192
|
border: {
|
|
132
|
-
color: getProp(element,
|
|
193
|
+
color: getProp(element, chartVariables.notesBorder),
|
|
133
194
|
},
|
|
134
195
|
},
|
|
135
196
|
line: {
|
|
136
|
-
color: getProp(element,
|
|
197
|
+
color: getProp(element, chartVariables.notesLines),
|
|
137
198
|
},
|
|
138
199
|
label: {
|
|
139
200
|
font: defaultFont(element),
|
|
140
201
|
},
|
|
141
202
|
});
|
|
142
203
|
|
|
204
|
+
// (chartCSSVariables already exported above via composition)
|
|
205
|
+
|
|
143
206
|
export const chartTheme = (element) => {
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const
|
|
207
|
+
const vars = chartCSSVariables;
|
|
208
|
+
const majorLines = getProp(element, vars.majorLines);
|
|
209
|
+
const normalTextColor = getProp(element, vars.text);
|
|
210
|
+
const axisLabelFont = getFont(element, vars.axisLabelFontWeight, vars.axisLabelFontSize, vars.axisLabelFontFamily);
|
|
211
|
+
const chartBg = getProp(element, vars.chartBg);
|
|
148
212
|
const notesProps = notes(element);
|
|
149
|
-
const areaOpacity = getNumberProp(element,
|
|
150
|
-
const surfaceColor = getProp(element,
|
|
151
|
-
const primaryBg = getProp(element,
|
|
213
|
+
const areaOpacity = getNumberProp(element, vars.areaOpacity);
|
|
214
|
+
const surfaceColor = getProp(element, vars.surface);
|
|
215
|
+
const primaryBg = getProp(element, vars.primaryBg);
|
|
152
216
|
|
|
153
217
|
const boxPlot = () => ({
|
|
154
218
|
downColor: majorLines,
|
|
@@ -172,13 +236,13 @@ export const chartTheme = (element) => {
|
|
|
172
236
|
const area = () => ({
|
|
173
237
|
opacity: areaOpacity,
|
|
174
238
|
highlight: {
|
|
175
|
-
inactiveOpacity: getNumberProp(element,
|
|
239
|
+
inactiveOpacity: getNumberProp(element, vars.areaInactiveOpacity),
|
|
176
240
|
},
|
|
177
241
|
});
|
|
178
242
|
|
|
179
243
|
const line = () => ({
|
|
180
244
|
highlight: {
|
|
181
|
-
inactiveOpacity: getNumberProp(element,
|
|
245
|
+
inactiveOpacity: getNumberProp(element, vars.lineInactiveOpacity),
|
|
182
246
|
},
|
|
183
247
|
});
|
|
184
248
|
|
|
@@ -191,7 +255,7 @@ export const chartTheme = (element) => {
|
|
|
191
255
|
return {
|
|
192
256
|
axisDefaults: {
|
|
193
257
|
crosshair: {
|
|
194
|
-
color: getProp(element,
|
|
258
|
+
color: getProp(element, vars.crosshairBg),
|
|
195
259
|
},
|
|
196
260
|
labels: {
|
|
197
261
|
color: normalTextColor,
|
|
@@ -204,7 +268,7 @@ export const chartTheme = (element) => {
|
|
|
204
268
|
color: majorLines,
|
|
205
269
|
},
|
|
206
270
|
minorGridLines: {
|
|
207
|
-
color: getProp(element,
|
|
271
|
+
color: getProp(element, vars.minorLines),
|
|
208
272
|
},
|
|
209
273
|
notes: structuredClone(notesProps),
|
|
210
274
|
title: {
|
|
@@ -241,7 +305,7 @@ export const chartTheme = (element) => {
|
|
|
241
305
|
},
|
|
242
306
|
},
|
|
243
307
|
errorBars: {
|
|
244
|
-
color: getProp(element,
|
|
308
|
+
color: getProp(element, vars.errorBarsBg),
|
|
245
309
|
},
|
|
246
310
|
icon: {
|
|
247
311
|
border: {
|