billboard.js 4.0.3 → 4.1.0-next.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/README.md +82 -7
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +1848 -494
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +19 -24
- package/dist/billboard.pkgd.js +1844 -679
- package/dist/billboard.pkgd.min.js +24 -29
- package/dist/billboard.react.js +205 -0
- package/dist/billboard.react.min.js +9 -0
- package/dist/billboard.worker.js +10 -0
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +5 -3
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +6 -3
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +6 -3
- package/dist/plugin/billboardjs-plugin-stanford.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-tableview.js +59 -27
- package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +75 -55
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +5 -3
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +6 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +6 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +59 -27
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +11 -11
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +68 -3557
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +8 -8
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/Chart/Chart.js +134 -152
- package/dist-esm/Chart/api/axis.js +217 -237
- package/dist-esm/Chart/api/category.js +54 -54
- package/dist-esm/Chart/api/chart.js +172 -215
- package/dist-esm/Chart/api/color.js +21 -21
- package/dist-esm/Chart/api/data.js +172 -173
- package/dist-esm/Chart/api/export.js +242 -262
- package/dist-esm/Chart/api/flow.js +198 -254
- package/dist-esm/Chart/api/focus.js +136 -143
- package/dist-esm/Chart/api/grid.js +191 -190
- package/dist-esm/Chart/api/group.js +31 -34
- package/dist-esm/Chart/api/legend.js +54 -63
- package/dist-esm/Chart/api/load.js +237 -257
- package/dist-esm/Chart/api/regions.js +148 -168
- package/dist-esm/Chart/api/selection.js +181 -139
- package/dist-esm/Chart/api/show.js +133 -147
- package/dist-esm/Chart/api/stubs.js +43 -42
- package/dist-esm/Chart/api/subchart.js +155 -172
- package/dist-esm/Chart/api/tooltip.js +132 -177
- package/dist-esm/Chart/api/x.js +67 -71
- package/dist-esm/Chart/api/zoom.js +183 -220
- package/dist-esm/ChartInternal/Axis/Axis.js +1059 -1266
- package/dist-esm/ChartInternal/Axis/AxisRenderer.js +408 -540
- package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +113 -149
- package/dist-esm/ChartInternal/ChartInternal.js +573 -749
- package/dist-esm/ChartInternal/data/convert.helper.js +133 -159
- package/dist-esm/ChartInternal/data/convert.js +200 -229
- package/dist-esm/ChartInternal/data/data.js +967 -1153
- package/dist-esm/ChartInternal/data/load.js +145 -197
- package/dist-esm/ChartInternal/interactions/drag.js +86 -122
- package/dist-esm/ChartInternal/interactions/eventrect.js +455 -621
- package/dist-esm/ChartInternal/interactions/flow.js +151 -215
- package/dist-esm/ChartInternal/interactions/interaction.js +214 -252
- package/dist-esm/ChartInternal/interactions/subchart.js +425 -300
- package/dist-esm/ChartInternal/interactions/zoom.js +321 -440
- package/dist-esm/ChartInternal/internals/category.js +18 -18
- package/dist-esm/ChartInternal/internals/class.js +89 -99
- package/dist-esm/ChartInternal/internals/clip.js +88 -119
- package/dist-esm/ChartInternal/internals/color.js +233 -288
- package/dist-esm/ChartInternal/internals/domain.js +452 -588
- package/dist-esm/ChartInternal/internals/format.js +64 -77
- package/dist-esm/ChartInternal/internals/grid.js +333 -457
- package/dist-esm/ChartInternal/internals/legend.js +675 -927
- package/dist-esm/ChartInternal/internals/redraw.js +200 -289
- package/dist-esm/ChartInternal/internals/region.js +106 -159
- package/dist-esm/ChartInternal/internals/scale.js +186 -215
- package/dist-esm/ChartInternal/internals/selection.js +132 -159
- package/dist-esm/ChartInternal/internals/size.axis.js +92 -139
- package/dist-esm/ChartInternal/internals/size.js +286 -394
- package/dist-esm/ChartInternal/internals/style.js +39 -41
- package/dist-esm/ChartInternal/internals/subchart.util.js +49 -0
- package/dist-esm/ChartInternal/internals/text.arc.js +155 -219
- package/dist-esm/ChartInternal/internals/text.js +368 -528
- package/dist-esm/ChartInternal/internals/text.util.js +179 -239
- package/dist-esm/ChartInternal/internals/title.js +96 -121
- package/dist-esm/ChartInternal/internals/tooltip.js +450 -586
- package/dist-esm/ChartInternal/internals/transform.js +79 -97
- package/dist-esm/ChartInternal/internals/type.js +285 -236
- package/dist-esm/ChartInternal/shape/arc.js +825 -1112
- package/dist-esm/ChartInternal/shape/area.js +73 -94
- package/dist-esm/ChartInternal/shape/bar.js +227 -288
- package/dist-esm/ChartInternal/shape/bubble.js +9 -8
- package/dist-esm/ChartInternal/shape/candlestick.js +110 -138
- package/dist-esm/ChartInternal/shape/core/barRadius.js +197 -133
- package/dist-esm/ChartInternal/shape/core/bubble.js +64 -73
- package/dist-esm/ChartInternal/shape/core/candlestick.js +93 -86
- package/dist-esm/ChartInternal/shape/core/dataRegion.js +68 -75
- package/dist-esm/ChartInternal/shape/core/geometry.js +112 -112
- package/dist-esm/ChartInternal/shape/core/path.js +142 -115
- package/dist-esm/ChartInternal/shape/core/point.js +105 -125
- package/dist-esm/ChartInternal/shape/core/treemap.js +83 -88
- package/dist-esm/ChartInternal/shape/funnel.js +310 -338
- package/dist-esm/ChartInternal/shape/gauge.js +71 -103
- package/dist-esm/ChartInternal/shape/line.js +208 -278
- package/dist-esm/ChartInternal/shape/point.js +310 -425
- package/dist-esm/ChartInternal/shape/polar.js +84 -109
- package/dist-esm/ChartInternal/shape/radar.js +228 -318
- package/dist-esm/ChartInternal/shape/shape.js +782 -843
- package/dist-esm/ChartInternal/shape/treemap.js +152 -190
- package/dist-esm/canvas/CanvasAxisRenderer.js +1180 -1328
- package/dist-esm/canvas/CanvasEngine.js +148 -166
- package/dist-esm/canvas/CanvasPainter.js +395 -411
- package/dist-esm/canvas/CanvasRenderer.js +1584 -1834
- package/dist-esm/canvas/CanvasTheme.js +899 -802
- package/dist-esm/canvas/HitDetector.js +394 -463
- package/dist-esm/canvas/axisTicks.js +672 -786
- package/dist-esm/canvas/classes.js +19 -17
- package/dist-esm/canvas/color.js +40 -59
- package/dist-esm/canvas/geometry.js +38 -38
- package/dist-esm/canvas/labels.js +318 -371
- package/dist-esm/canvas/pointPattern.js +578 -580
- package/dist-esm/canvas/util.js +242 -262
- package/dist-esm/config/Options/Options.js +29 -32
- package/dist-esm/config/Options/axis/axis.js +101 -101
- package/dist-esm/config/Options/axis/x.js +759 -755
- package/dist-esm/config/Options/axis/y.js +525 -522
- package/dist-esm/config/Options/axis/y2.js +501 -485
- package/dist-esm/config/Options/common/boost.js +93 -32
- package/dist-esm/config/Options/common/color.js +88 -87
- package/dist-esm/config/Options/common/grid.js +74 -73
- package/dist-esm/config/Options/common/legend.js +180 -179
- package/dist-esm/config/Options/common/main.js +474 -473
- package/dist-esm/config/Options/common/point.js +160 -159
- package/dist-esm/config/Options/common/title.js +47 -46
- package/dist-esm/config/Options/common/tooltip.js +253 -252
- package/dist-esm/config/Options/data/axis.js +173 -172
- package/dist-esm/config/Options/data/data.js +958 -957
- package/dist-esm/config/Options/data/selection.js +131 -130
- package/dist-esm/config/Options/interaction/interaction.js +53 -52
- package/dist-esm/config/Options/interaction/subchart.js +164 -73
- package/dist-esm/config/Options/interaction/zoom.js +86 -85
- package/dist-esm/config/Options/shape/arc.js +150 -149
- package/dist-esm/config/Options/shape/area.js +69 -68
- package/dist-esm/config/Options/shape/bar.js +147 -146
- package/dist-esm/config/Options/shape/bubble.js +35 -34
- package/dist-esm/config/Options/shape/candlestick.js +61 -60
- package/dist-esm/config/Options/shape/donut.js +181 -180
- package/dist-esm/config/Options/shape/funnel.js +49 -48
- package/dist-esm/config/Options/shape/gauge.js +237 -236
- package/dist-esm/config/Options/shape/line.js +58 -57
- package/dist-esm/config/Options/shape/pie.js +185 -184
- package/dist-esm/config/Options/shape/polar.js +167 -166
- package/dist-esm/config/Options/shape/radar.js +76 -75
- package/dist-esm/config/Options/shape/scatter.js +36 -36
- package/dist-esm/config/Options/shape/spline.js +46 -46
- package/dist-esm/config/Options/shape/treemap.js +80 -79
- package/dist-esm/config/Store/Element.js +64 -62
- package/dist-esm/config/Store/State.js +189 -200
- package/dist-esm/config/Store/Store.js +25 -26
- package/dist-esm/config/classes.js +157 -155
- package/dist-esm/config/config.js +26 -35
- package/dist-esm/config/const.js +120 -128
- package/dist-esm/config/resolver/axis.core.js +25 -25
- package/dist-esm/config/resolver/axis.js +26 -27
- package/dist-esm/config/resolver/canvas.js +2071 -2472
- package/dist-esm/config/resolver/canvasShape.js +201 -177
- package/dist-esm/config/resolver/category.js +26 -27
- package/dist-esm/config/resolver/export.js +24 -26
- package/dist-esm/config/resolver/flow.js +29 -31
- package/dist-esm/config/resolver/grid.js +34 -35
- package/dist-esm/config/resolver/interaction/selection.js +17 -17
- package/dist-esm/config/resolver/interaction/subchart.js +17 -17
- package/dist-esm/config/resolver/interaction/zoom.js +17 -17
- package/dist-esm/config/resolver/regions.js +30 -31
- package/dist-esm/config/resolver/shape/arc.helpers.js +19 -19
- package/dist-esm/config/resolver/shape/area.js +17 -17
- package/dist-esm/config/resolver/shape/axis.helpers.js +28 -25
- package/dist-esm/config/resolver/shape/bar.js +13 -13
- package/dist-esm/config/resolver/shape/bubble.js +18 -14
- package/dist-esm/config/resolver/shape/candlestick.js +13 -13
- package/dist-esm/config/resolver/shape/donut.js +11 -11
- package/dist-esm/config/resolver/shape/funnel.js +11 -11
- package/dist-esm/config/resolver/shape/gauge.js +12 -12
- package/dist-esm/config/resolver/shape/line.js +10 -10
- package/dist-esm/config/resolver/shape/pie.js +11 -11
- package/dist-esm/config/resolver/shape/polar.js +12 -12
- package/dist-esm/config/resolver/shape/radar.js +22 -14
- package/dist-esm/config/resolver/shape/scatter.js +13 -13
- package/dist-esm/config/resolver/shape/treemap.js +11 -11
- package/dist-esm/core.js +208 -211
- package/dist-esm/index.canvas.js +14 -13
- package/dist-esm/index.esm.js +25 -24
- package/dist-esm/module/Cache.js +117 -129
- package/dist-esm/module/browser.js +30 -35
- package/dist-esm/module/dsv.js +107 -127
- package/dist-esm/module/error.js +45 -52
- package/dist-esm/module/generator.js +75 -83
- package/dist-esm/module/sanitize.js +302 -399
- package/dist-esm/module/util/brush.js +27 -38
- package/dist-esm/module/util/dom.js +288 -348
- package/dist-esm/module/util/object.js +277 -341
- package/dist-esm/module/util/type-checks.js +21 -25
- package/dist-esm/module/worker.js +312 -130
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +185 -198
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +442 -450
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +813 -950
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +708 -788
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +344 -301
- package/dist-esm/react/index.js +157 -0
- package/package.json +28 -8
- package/src/Chart/api/selection.ts +130 -5
- package/src/ChartInternal/Axis/Axis.ts +164 -65
- package/src/ChartInternal/Axis/AxisRenderer.ts +41 -8
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/data/convert.ts +54 -4
- package/src/ChartInternal/data/data.ts +4 -1
- package/src/ChartInternal/interactions/eventrect.ts +8 -2
- package/src/ChartInternal/interactions/subchart.ts +437 -66
- package/src/ChartInternal/internals/color.ts +2 -2
- package/src/ChartInternal/internals/domain.ts +15 -3
- package/src/ChartInternal/internals/grid.ts +21 -1
- package/src/ChartInternal/internals/scale.ts +9 -2
- package/src/ChartInternal/internals/selection.ts +1 -1
- package/src/ChartInternal/internals/subchart.util.ts +55 -0
- package/src/ChartInternal/internals/text.arc.ts +3 -1
- package/src/ChartInternal/internals/text.ts +18 -5
- package/src/ChartInternal/internals/transform.ts +8 -2
- package/src/ChartInternal/internals/type.ts +105 -1
- package/src/ChartInternal/shape/IShape.ts +6 -3
- package/src/ChartInternal/shape/bar.ts +62 -31
- package/src/ChartInternal/shape/core/barRadius.ts +129 -0
- package/src/ChartInternal/shape/core/candlestick.ts +1 -1
- package/src/ChartInternal/shape/core/path.ts +76 -9
- package/src/ChartInternal/shape/funnel.ts +2 -3
- package/src/ChartInternal/shape/point.ts +2 -2
- package/src/ChartInternal/shape/shape.ts +149 -17
- package/src/Plugin/stanford/index.ts +0 -4
- package/src/Plugin/tableview/index.ts +85 -3
- package/src/Plugin/textoverlap/index.ts +9 -15
- package/src/canvas/CanvasAxisRenderer.ts +184 -36
- package/src/canvas/CanvasRenderer.ts +247 -160
- package/src/canvas/CanvasTheme.ts +212 -0
- package/src/canvas/axisTicks.ts +122 -40
- package/src/config/Options/axis/y2.ts +13 -0
- package/src/config/Options/common/boost.ts +64 -4
- package/src/config/Options/common/color.ts +2 -2
- package/src/config/Options/interaction/subchart.ts +98 -1
- package/src/config/Options/shape/gauge.ts +1 -1
- package/src/config/Options/shape/treemap.ts +2 -2
- package/src/config/Store/Element.ts +3 -1
- package/src/config/Store/State.ts +1 -0
- package/src/config/classes.ts +1 -0
- package/src/config/resolver/canvas.ts +92 -10
- package/src/module/util/type-checks.ts +3 -1
- package/src/module/voronoi.ts +119 -0
- package/src/module/worker.entry.ts +61 -0
- package/src/module/worker.ts +346 -63
- package/src/react/index.ts +193 -0
- package/types/options.d.ts +206 -3
- package/types/react/index.d.ts +27 -0
|
@@ -5,872 +5,969 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.
|
|
8
|
+
* @version 4.1.0-next.2
|
|
9
9
|
*/
|
|
10
|
-
import { document as doc, window as win } from
|
|
11
|
-
import { mergeObj } from
|
|
12
|
-
|
|
10
|
+
import { document as doc, window as win } from "../module/browser.js";
|
|
11
|
+
import { mergeObj } from "../module/util/object.js";
|
|
12
|
+
//#region src/canvas/CanvasTheme.ts
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
15
|
+
* billboard.js project is licensed under the MIT license
|
|
16
|
+
*/
|
|
17
17
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
* Parse CSS numeric value.
|
|
20
|
+
* @param {string|number} value CSS value
|
|
21
|
+
* @param {number} fallback Fallback value
|
|
22
|
+
* @returns {number} Parsed number
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
25
|
function toNumber(value, fallback) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const parsed = typeof value === "number" ? value : parseFloat(value ?? "");
|
|
27
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
* Resolve effective SVG paint opacity from element opacity and fill-opacity.
|
|
31
|
+
* @param {object} value Computed opacity values
|
|
32
|
+
* @param {number} fallback Fallback opacity
|
|
33
|
+
* @returns {number} Effective opacity
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
36
|
function toPaintOpacity(value, fallback) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const result = opacity * fillOpacity;
|
|
40
|
-
return Number.isFinite(result) ? result : fallback;
|
|
37
|
+
const result = toNumber(value.opacity, 1) * toNumber(value["fill-opacity"], 1);
|
|
38
|
+
return Number.isFinite(result) ? result : fallback;
|
|
41
39
|
}
|
|
42
40
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
* Parse CSS color value.
|
|
42
|
+
* @param {string} value CSS color value
|
|
43
|
+
* @param {string} fallback Fallback value
|
|
44
|
+
* @returns {string} CSS color
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
49
47
|
function toColor(value, fallback) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
color :
|
|
53
|
-
fallback;
|
|
48
|
+
const color = value?.trim();
|
|
49
|
+
return color && !/^(none|transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i.test(color) ? color : fallback;
|
|
54
50
|
}
|
|
55
51
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
* Parse CSS color value only when it is different from an ignored baseline.
|
|
53
|
+
* @param {string} value CSS color value
|
|
54
|
+
* @param {string} ignored Ignored baseline color
|
|
55
|
+
* @returns {string|undefined} CSS color
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
62
58
|
function toOptionalColor(value, ignored) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
const color = toColor(value, "");
|
|
60
|
+
const ignoredColor = ignored ? toColor(ignored, "") : "";
|
|
61
|
+
return color && color !== ignoredColor ? color : void 0;
|
|
66
62
|
}
|
|
67
63
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
* Parse CSS numeric value only when it is different from an ignored baseline.
|
|
65
|
+
* @param {string|number} value CSS value
|
|
66
|
+
* @param {number} ignored Ignored baseline value
|
|
67
|
+
* @returns {number|undefined} Parsed number
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
74
70
|
function toOptionalNumber(value, ignored) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
(!Number.isFinite(ignoredParsed) || parsed !== ignoredParsed) ?
|
|
79
|
-
parsed :
|
|
80
|
-
undefined;
|
|
71
|
+
const parsed = typeof value === "number" ? value : parseFloat(value ?? "");
|
|
72
|
+
const ignoredParsed = typeof ignored === "number" ? ignored : parseFloat(ignored ?? "");
|
|
73
|
+
return Number.isFinite(parsed) && (!Number.isFinite(ignoredParsed) || parsed !== ignoredParsed) ? parsed : void 0;
|
|
81
74
|
}
|
|
82
75
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
* Parse CSS dash array value.
|
|
77
|
+
* @param {string|Array} value CSS stroke-dasharray value
|
|
78
|
+
* @returns {Array} Dash array
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
88
81
|
function toDashArray(value) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
return (value || "")
|
|
93
|
-
.split(/[,\s]+/)
|
|
94
|
-
.map(v => parseFloat(v))
|
|
95
|
-
.filter(v => Number.isFinite(v) && v > 0);
|
|
82
|
+
if (Array.isArray(value)) return value.filter((v) => Number.isFinite(v) && v > 0);
|
|
83
|
+
return (value || "").split(/[,\s]+/).map((v) => parseFloat(v)).filter((v) => Number.isFinite(v) && v > 0);
|
|
96
84
|
}
|
|
97
85
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
86
|
+
* Get CSS font shorthand usable by canvas.
|
|
87
|
+
* @param {CSSStyleDeclaration} style Computed style
|
|
88
|
+
* @param {string} fallback Fallback value
|
|
89
|
+
* @returns {string} Font shorthand
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
104
92
|
function toFont(style, fallback) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
fontWeight && !/^(normal|400)$/.test(fontWeight) ? fontWeight : "",
|
|
123
|
-
size,
|
|
124
|
-
fontFamily
|
|
125
|
-
].filter(Boolean).join(" ");
|
|
93
|
+
const font = style.getPropertyValue("font").trim();
|
|
94
|
+
if (font) return font;
|
|
95
|
+
const fontSize = style.getPropertyValue("font-size").trim();
|
|
96
|
+
const fontFamily = style.getPropertyValue("font-family").trim();
|
|
97
|
+
if (!fontSize || !fontFamily) return fallback;
|
|
98
|
+
const fontStyle = style.getPropertyValue("font-style").trim();
|
|
99
|
+
const fontVariant = style.getPropertyValue("font-variant").trim();
|
|
100
|
+
const fontWeight = style.getPropertyValue("font-weight").trim();
|
|
101
|
+
const lineHeight = style.getPropertyValue("line-height").trim();
|
|
102
|
+
const size = lineHeight && lineHeight !== "normal" ? `${fontSize}/${lineHeight}` : fontSize;
|
|
103
|
+
return [
|
|
104
|
+
fontStyle && fontStyle !== "normal" ? fontStyle : "",
|
|
105
|
+
fontVariant && fontVariant !== "normal" ? fontVariant : "",
|
|
106
|
+
fontWeight && !/^(normal|400)$/.test(fontWeight) ? fontWeight : "",
|
|
107
|
+
size,
|
|
108
|
+
fontFamily
|
|
109
|
+
].filter(Boolean).join(" ");
|
|
126
110
|
}
|
|
127
111
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
112
|
+
* Get style declaration value by CSS property name.
|
|
113
|
+
* @param {object} style Style declaration object
|
|
114
|
+
* @param {string} prop CSS property name
|
|
115
|
+
* @returns {string|number|Array|undefined} Style value
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
134
118
|
function getStyleValue(style, prop) {
|
|
135
|
-
|
|
136
|
-
|
|
119
|
+
const camelProp = prop.replace(/-([a-z])/g, (all, chr) => chr.toUpperCase());
|
|
120
|
+
return style[prop] ?? style[camelProp];
|
|
137
121
|
}
|
|
138
122
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
123
|
+
* Read color from selector style declaration.
|
|
124
|
+
* @param {object} style Style declaration object
|
|
125
|
+
* @param {string} prop CSS property name
|
|
126
|
+
* @returns {string|undefined} Color value
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
145
129
|
function readColorValue(style, prop) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return color || undefined;
|
|
130
|
+
const value = getStyleValue(style, prop);
|
|
131
|
+
return (value == null ? "" : toColor(String(value), "")) || void 0;
|
|
149
132
|
}
|
|
150
133
|
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
134
|
+
* Read numeric value from selector style declaration.
|
|
135
|
+
* @param {object} style Style declaration object
|
|
136
|
+
* @param {string} prop CSS property name
|
|
137
|
+
* @returns {number|undefined} Numeric value
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
157
140
|
function readNumberValue(style, prop) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
141
|
+
const value = getStyleValue(style, prop);
|
|
142
|
+
const parsed = typeof value === "number" ? value : parseFloat(String(value ?? ""));
|
|
143
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
161
144
|
}
|
|
162
145
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
146
|
+
* Read paint opacity from selector style declaration.
|
|
147
|
+
* @param {object} style Style declaration object
|
|
148
|
+
* @returns {number|undefined} Paint opacity
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
168
151
|
function readPaintOpacityValue(style) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
undefined :
|
|
173
|
-
(opacity ?? 1) * (fillOpacity ?? 1);
|
|
152
|
+
const opacity = readNumberValue(style, "opacity");
|
|
153
|
+
const fillOpacity = readNumberValue(style, "fill-opacity");
|
|
154
|
+
return opacity === void 0 && fillOpacity === void 0 ? void 0 : (opacity ?? 1) * (fillOpacity ?? 1);
|
|
174
155
|
}
|
|
175
156
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
157
|
+
* Read dash array from selector style declaration.
|
|
158
|
+
* @param {object} style Style declaration object
|
|
159
|
+
* @returns {Array|undefined} Dash array
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
181
162
|
function readDashArrayValue(style) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
163
|
+
const value = getStyleValue(style, "stroke-dasharray");
|
|
164
|
+
const dashArray = value == null ? [] : toDashArray(value);
|
|
165
|
+
return dashArray.length ? dashArray : void 0;
|
|
185
166
|
}
|
|
186
167
|
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
168
|
+
* Read font shorthand from selector style declaration.
|
|
169
|
+
* @param {object} style Style declaration object
|
|
170
|
+
* @returns {string|undefined} Font shorthand
|
|
171
|
+
* @private
|
|
172
|
+
*/
|
|
192
173
|
function readFontValue(style) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
fontStyle && fontStyle !== "normal" ? fontStyle : "",
|
|
213
|
-
fontVariant && fontVariant !== "normal" ? fontVariant : "",
|
|
214
|
-
fontWeight && !/^(normal|400)$/.test(fontWeight) ? fontWeight : "",
|
|
215
|
-
lineHeight && lineHeight !== "normal" ? `${size}/${lineHeight}` : size,
|
|
216
|
-
family
|
|
217
|
-
].filter(Boolean).join(" ");
|
|
174
|
+
const font = getStyleValue(style, "font");
|
|
175
|
+
if (font != null && String(font).trim()) return String(font).trim();
|
|
176
|
+
const fontSize = getStyleValue(style, "font-size");
|
|
177
|
+
const fontFamily = getStyleValue(style, "font-family");
|
|
178
|
+
if (fontSize == null || fontFamily == null) return;
|
|
179
|
+
const size = String(fontSize).trim();
|
|
180
|
+
const family = String(fontFamily).trim();
|
|
181
|
+
if (!size || !family) return;
|
|
182
|
+
const fontStyle = String(getStyleValue(style, "font-style") ?? "").trim();
|
|
183
|
+
const fontVariant = String(getStyleValue(style, "font-variant") ?? "").trim();
|
|
184
|
+
const fontWeight = String(getStyleValue(style, "font-weight") ?? "").trim();
|
|
185
|
+
const lineHeight = String(getStyleValue(style, "line-height") ?? "").trim();
|
|
186
|
+
return [
|
|
187
|
+
fontStyle && fontStyle !== "normal" ? fontStyle : "",
|
|
188
|
+
fontVariant && fontVariant !== "normal" ? fontVariant : "",
|
|
189
|
+
fontWeight && !/^(normal|400)$/.test(fontWeight) ? fontWeight : "",
|
|
190
|
+
lineHeight && lineHeight !== "normal" ? `${size}/${lineHeight}` : size,
|
|
191
|
+
family
|
|
192
|
+
].filter(Boolean).join(" ");
|
|
218
193
|
}
|
|
219
194
|
/**
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
195
|
+
* Merge selector style values to a canvas theme section.
|
|
196
|
+
* @param {object} target Theme override target
|
|
197
|
+
* @param {string} section Theme section name
|
|
198
|
+
* @param {object} values Theme section values
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
226
201
|
function mergeThemeSection(target, section, values) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
target[section] = mergeObj(target[section] ?? {}, override);
|
|
233
|
-
}
|
|
202
|
+
const override = Object.keys(values).reduce((acc, key) => {
|
|
203
|
+
values[key] !== void 0 && (acc[key] = values[key]);
|
|
204
|
+
return acc;
|
|
205
|
+
}, {});
|
|
206
|
+
if (Object.keys(override).length) target[section] = mergeObj(target[section] ?? {}, override);
|
|
234
207
|
}
|
|
235
208
|
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
209
|
+
* Normalize a supported SVG selector for canvas theme matching.
|
|
210
|
+
* @param {string} selector SVG selector
|
|
211
|
+
* @returns {Array} Normalized selector list
|
|
212
|
+
* @private
|
|
213
|
+
*/
|
|
241
214
|
function normalizeThemeSelectors(selector) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
215
|
+
return selector.split(",").map((value) => value.trim().replace(/\s*>\s*/g, " ").replace(/\s+/g, " ").replace(/^(?:svg)?\.bb\s+/, "").replace(/(^|\s)(?:g|path|rect|line|text|circle)\./g, "$1.")).filter(Boolean);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get own keys from a style object whose values are set.
|
|
219
|
+
* @param {object} values Style values
|
|
220
|
+
* @returns {Array} Defined keys
|
|
221
|
+
* @private
|
|
222
|
+
*/
|
|
223
|
+
function getDefinedKeys(values) {
|
|
224
|
+
return Object.keys(values).filter((key) => values[key] !== void 0);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Copy the defined entries of an object into a target of the same shape.
|
|
228
|
+
* @param {object} target Object to copy into
|
|
229
|
+
* @param {object} source Object to copy from
|
|
230
|
+
* @param {Set} skip Keys to leave untouched
|
|
231
|
+
* @returns {object} The target object
|
|
232
|
+
* @private
|
|
233
|
+
*/
|
|
234
|
+
function assignDefined(target, source, skip) {
|
|
235
|
+
getDefinedKeys(source).forEach((key) => {
|
|
236
|
+
if (!skip?.has(key)) target[key] = source[key];
|
|
237
|
+
});
|
|
238
|
+
return target;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Check whether a selector is simple enough for virtual optional grid line matching.
|
|
242
|
+
* @param {string} selector Normalized SVG selector
|
|
243
|
+
* @returns {boolean} Whether selector can be matched
|
|
244
|
+
* @private
|
|
245
|
+
*/
|
|
246
|
+
function isSimpleGridLineSelector(selector) {
|
|
247
|
+
const tokens = selector.split(" ");
|
|
248
|
+
return tokens.every((token, index) => token === "line" || token === "text" ? index === tokens.length - 1 : /^(\.[A-Za-z_-][\w-]*)+$/.test(token));
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get optional grid line selector target.
|
|
252
|
+
* @param {string} selector Normalized SVG selector
|
|
253
|
+
* @returns {string|null} Selector target
|
|
254
|
+
* @private
|
|
255
|
+
*/
|
|
256
|
+
function getGridLineSelectorTarget(selector) {
|
|
257
|
+
const tokens = selector.split(" ");
|
|
258
|
+
const target = tokens[tokens.length - 1];
|
|
259
|
+
return target === "line" || target === "text" ? target : null;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Split custom class value.
|
|
263
|
+
* @param {string} className Custom class value
|
|
264
|
+
* @returns {Array} Class names
|
|
265
|
+
* @private
|
|
266
|
+
*/
|
|
267
|
+
function getClassNames(className) {
|
|
268
|
+
return (className || "").split(/\s+/).filter(Boolean);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Read optional grid line or label style from selector style declaration.
|
|
272
|
+
* @param {object} style Style declaration object
|
|
273
|
+
* @param {string} target Selector target
|
|
274
|
+
* @returns {object} Grid line style
|
|
275
|
+
* @private
|
|
276
|
+
*/
|
|
277
|
+
function getGridLineSelectorStyle(style, target) {
|
|
278
|
+
return assignDefined({}, target === "text" ? {
|
|
279
|
+
labelColor: readColorValue(style, "fill"),
|
|
280
|
+
labelFont: readFontValue(style)
|
|
281
|
+
} : {
|
|
282
|
+
lineColor: readColorValue(style, "stroke"),
|
|
283
|
+
lineWidth: readNumberValue(style, "stroke-width"),
|
|
284
|
+
dashArray: readDashArrayValue(style)
|
|
285
|
+
});
|
|
249
286
|
}
|
|
250
287
|
/**
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
288
|
+
* Convert selector based optional grid line overrides to ordered matcher entries.
|
|
289
|
+
* @param {object} selectors Selector style declarations
|
|
290
|
+
* @returns {Array} Optional grid line selector overrides
|
|
291
|
+
* @private
|
|
292
|
+
*/
|
|
293
|
+
function getGridLineSelectorOverrides(selectors) {
|
|
294
|
+
const overrides = [];
|
|
295
|
+
Object.keys(selectors ?? {}).forEach((selector) => {
|
|
296
|
+
normalizeThemeSelectors(selector).forEach((normalizedSelector) => {
|
|
297
|
+
const target = getGridLineSelectorTarget(normalizedSelector) || "line";
|
|
298
|
+
const style = getGridLineSelectorStyle(selectors[selector], target);
|
|
299
|
+
if (isSimpleGridLineSelector(normalizedSelector) && getDefinedKeys(style).length) overrides.push({
|
|
300
|
+
selector: normalizedSelector,
|
|
301
|
+
target,
|
|
302
|
+
style
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
return overrides;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Check whether a virtual optional grid line selector matches a grid line config.
|
|
310
|
+
* @param {string} selector Normalized SVG selector
|
|
311
|
+
* @param {string} axis Grid axis
|
|
312
|
+
* @param {string} className Grid line custom class
|
|
313
|
+
* @param {string} target Draw target
|
|
314
|
+
* @returns {boolean} Whether selector matches
|
|
315
|
+
* @private
|
|
316
|
+
*/
|
|
317
|
+
function matchesGridLineSelector(selector, axis, className, target) {
|
|
318
|
+
if (!isSimpleGridLineSelector(selector)) return false;
|
|
319
|
+
const selectorTarget = getGridLineSelectorTarget(selector);
|
|
320
|
+
if (selectorTarget && selectorTarget !== target) return false;
|
|
321
|
+
else if (!selectorTarget && target === "text") return false;
|
|
322
|
+
const customClasses = getClassNames(className);
|
|
323
|
+
const axisLineClass = `bb-${axis}grid-line`;
|
|
324
|
+
const availableClasses = /* @__PURE__ */ new Set([
|
|
325
|
+
"bb-grid",
|
|
326
|
+
"bb-grid-lines",
|
|
327
|
+
`bb-${axis}grid-lines`,
|
|
328
|
+
axisLineClass,
|
|
329
|
+
...customClasses
|
|
330
|
+
]);
|
|
331
|
+
const selectorClasses = (selector.match(/\.[A-Za-z_-][\w-]*/g) || []).map((match) => match.slice(1));
|
|
332
|
+
return !!selectorClasses.length && selectorClasses.every((cls) => availableClasses.has(cls)) && (selectorClasses.includes(axisLineClass) || customClasses.some((cls) => selectorClasses.includes(cls)));
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Apply one selector style declaration to canvas theme override.
|
|
336
|
+
* @param {object} target Theme override target
|
|
337
|
+
* @param {string} selector SVG selector
|
|
338
|
+
* @param {object} style Style declaration object
|
|
339
|
+
* @private
|
|
340
|
+
*/
|
|
257
341
|
function applySelectorStyle(target, selector, style) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
mergeThemeSection(target, "label", {
|
|
489
|
-
color: readColorValue(style, "fill"),
|
|
490
|
-
font: readFontValue(style)
|
|
491
|
-
});
|
|
492
|
-
break;
|
|
493
|
-
case ".bb-title":
|
|
494
|
-
mergeThemeSection(target, "title", {
|
|
495
|
-
color: readColorValue(style, "fill"),
|
|
496
|
-
font: readFontValue(style)
|
|
497
|
-
});
|
|
498
|
-
break;
|
|
499
|
-
}
|
|
342
|
+
switch (selector) {
|
|
343
|
+
case ".bb-axis path.domain":
|
|
344
|
+
case ".bb-axis .domain":
|
|
345
|
+
case ".bb-axis-x path.domain":
|
|
346
|
+
case ".bb-axis-x .domain":
|
|
347
|
+
case ".bb-axis-y path.domain":
|
|
348
|
+
case ".bb-axis-y .domain":
|
|
349
|
+
case ".bb-axis-y2 path.domain":
|
|
350
|
+
case ".bb-axis-y2 .domain":
|
|
351
|
+
mergeThemeSection(target, "axis", {
|
|
352
|
+
lineColor: readColorValue(style, "stroke"),
|
|
353
|
+
lineWidth: readNumberValue(style, "stroke-width")
|
|
354
|
+
});
|
|
355
|
+
break;
|
|
356
|
+
case ".bb-axis line":
|
|
357
|
+
case ".bb-axis .tick line":
|
|
358
|
+
case ".bb-axis-x line":
|
|
359
|
+
case ".bb-axis-x .tick line":
|
|
360
|
+
case ".bb-axis-y line":
|
|
361
|
+
case ".bb-axis-y .tick line":
|
|
362
|
+
case ".bb-axis-y2 line":
|
|
363
|
+
case ".bb-axis-y2 .tick line":
|
|
364
|
+
mergeThemeSection(target, "axis", {
|
|
365
|
+
tickColor: readColorValue(style, "stroke"),
|
|
366
|
+
tickWidth: readNumberValue(style, "stroke-width")
|
|
367
|
+
});
|
|
368
|
+
break;
|
|
369
|
+
case ".bb-axis text":
|
|
370
|
+
case ".bb-axis .tick text": {
|
|
371
|
+
const font = readFontValue(style);
|
|
372
|
+
mergeThemeSection(target, "axis", {
|
|
373
|
+
labelColor: readColorValue(style, "fill"),
|
|
374
|
+
xTickFont: font,
|
|
375
|
+
yTickFont: font,
|
|
376
|
+
y2TickFont: font
|
|
377
|
+
});
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
case ".bb-axis-x text":
|
|
381
|
+
case ".bb-axis-x .tick text":
|
|
382
|
+
mergeThemeSection(target, "axis", {
|
|
383
|
+
labelColor: readColorValue(style, "fill"),
|
|
384
|
+
xTickFont: readFontValue(style)
|
|
385
|
+
});
|
|
386
|
+
break;
|
|
387
|
+
case ".bb-axis-y text":
|
|
388
|
+
case ".bb-axis-y .tick text":
|
|
389
|
+
mergeThemeSection(target, "axis", {
|
|
390
|
+
labelColor: readColorValue(style, "fill"),
|
|
391
|
+
yTickFont: readFontValue(style)
|
|
392
|
+
});
|
|
393
|
+
break;
|
|
394
|
+
case ".bb-axis-y2 text":
|
|
395
|
+
case ".bb-axis-y2 .tick text":
|
|
396
|
+
mergeThemeSection(target, "axis", {
|
|
397
|
+
labelColor: readColorValue(style, "fill"),
|
|
398
|
+
y2TickFont: readFontValue(style)
|
|
399
|
+
});
|
|
400
|
+
break;
|
|
401
|
+
case ".tick._active_ text":
|
|
402
|
+
case ".bb-axis .tick._active_ text":
|
|
403
|
+
case ".bb-axis-x .tick._active_ text":
|
|
404
|
+
mergeThemeSection(target, "axis", { activeLabelColor: readColorValue(style, "fill") });
|
|
405
|
+
break;
|
|
406
|
+
case ".bb-axis-x-label":
|
|
407
|
+
case ".bb-axis-x .bb-axis-x-label":
|
|
408
|
+
mergeThemeSection(target, "axis", {
|
|
409
|
+
labelFont: readFontValue(style),
|
|
410
|
+
xLabelColor: readColorValue(style, "fill")
|
|
411
|
+
});
|
|
412
|
+
break;
|
|
413
|
+
case ".bb-axis-y-label":
|
|
414
|
+
case ".bb-axis-y .bb-axis-y-label":
|
|
415
|
+
mergeThemeSection(target, "axis", {
|
|
416
|
+
labelFont: readFontValue(style),
|
|
417
|
+
yLabelColor: readColorValue(style, "fill")
|
|
418
|
+
});
|
|
419
|
+
break;
|
|
420
|
+
case ".bb-axis-y2-label":
|
|
421
|
+
case ".bb-axis-y2 .bb-axis-y2-label":
|
|
422
|
+
mergeThemeSection(target, "axis", {
|
|
423
|
+
labelFont: readFontValue(style),
|
|
424
|
+
y2LabelColor: readColorValue(style, "fill")
|
|
425
|
+
});
|
|
426
|
+
break;
|
|
427
|
+
case ".bb-grid line":
|
|
428
|
+
case ".bb-grid .bb-xgrid":
|
|
429
|
+
case ".bb-grid .bb-ygrid":
|
|
430
|
+
case ".bb-xgrid":
|
|
431
|
+
case ".bb-ygrid":
|
|
432
|
+
mergeThemeSection(target, "grid", {
|
|
433
|
+
lineColor: readColorValue(style, "stroke"),
|
|
434
|
+
lineWidth: readNumberValue(style, "stroke-width"),
|
|
435
|
+
dashArray: readDashArrayValue(style)
|
|
436
|
+
});
|
|
437
|
+
break;
|
|
438
|
+
case ".bb-grid text":
|
|
439
|
+
mergeThemeSection(target, "grid", {
|
|
440
|
+
labelColor: readColorValue(style, "fill"),
|
|
441
|
+
labelFont: readFontValue(style)
|
|
442
|
+
});
|
|
443
|
+
break;
|
|
444
|
+
case ".bb-xgrid-focus line":
|
|
445
|
+
case ".bb-grid .bb-xgrid-focus line":
|
|
446
|
+
case ".bb-grid .bb-xgrid-focus":
|
|
447
|
+
mergeThemeSection(target, "focusGrid", {
|
|
448
|
+
lineColor: readColorValue(style, "stroke"),
|
|
449
|
+
lineWidth: readNumberValue(style, "stroke-width"),
|
|
450
|
+
dashArray: readDashArrayValue(style)
|
|
451
|
+
});
|
|
452
|
+
break;
|
|
453
|
+
case ".bb-region rect":
|
|
454
|
+
case ".bb-region":
|
|
455
|
+
mergeThemeSection(target, "region", {
|
|
456
|
+
fill: readColorValue(style, "fill"),
|
|
457
|
+
opacity: readPaintOpacityValue(style)
|
|
458
|
+
});
|
|
459
|
+
break;
|
|
460
|
+
case ".bb-region text":
|
|
461
|
+
mergeThemeSection(target, "region", {
|
|
462
|
+
labelColor: readColorValue(style, "fill"),
|
|
463
|
+
labelFont: readFontValue(style)
|
|
464
|
+
});
|
|
465
|
+
break;
|
|
466
|
+
case ".bb-bar":
|
|
467
|
+
mergeThemeSection(target, "shape", {
|
|
468
|
+
barOpacity: readPaintOpacityValue(style),
|
|
469
|
+
barStrokeColor: readColorValue(style, "stroke"),
|
|
470
|
+
barLineWidth: readNumberValue(style, "stroke-width")
|
|
471
|
+
});
|
|
472
|
+
break;
|
|
473
|
+
case ".bb-bar._expanded_":
|
|
474
|
+
mergeThemeSection(target, "shape", { barExpandedOpacity: readPaintOpacityValue(style) });
|
|
475
|
+
break;
|
|
476
|
+
case ".bb-candlestick":
|
|
477
|
+
mergeThemeSection(target, "shape", {
|
|
478
|
+
candlestickStrokeColor: readColorValue(style, "stroke"),
|
|
479
|
+
candlestickLineWidth: readNumberValue(style, "stroke-width")
|
|
480
|
+
});
|
|
481
|
+
break;
|
|
482
|
+
case ".bb-candlestick._expanded_":
|
|
483
|
+
mergeThemeSection(target, "shape", { candlestickExpandedOpacity: readPaintOpacityValue(style) });
|
|
484
|
+
break;
|
|
485
|
+
case ".bb-line":
|
|
486
|
+
mergeThemeSection(target, "shape", {
|
|
487
|
+
barConnectLineColor: readColorValue(style, "stroke"),
|
|
488
|
+
barConnectLineWidth: readNumberValue(style, "stroke-width"),
|
|
489
|
+
lineWidth: readNumberValue(style, "stroke-width")
|
|
490
|
+
});
|
|
491
|
+
break;
|
|
492
|
+
case ".bb-target.bb-focused .bb-line":
|
|
493
|
+
case ".bb-target.bb-focused path.bb-line":
|
|
494
|
+
mergeThemeSection(target, "shape", { lineFocusedWidth: readNumberValue(style, "stroke-width") });
|
|
495
|
+
break;
|
|
496
|
+
case ".bb-target.bb-defocused":
|
|
497
|
+
mergeThemeSection(target, "shape", { targetDefocusedOpacity: readNumberValue(style, "opacity") });
|
|
498
|
+
break;
|
|
499
|
+
case ".bb-area":
|
|
500
|
+
mergeThemeSection(target, "shape", { areaOpacity: readPaintOpacityValue(style) });
|
|
501
|
+
break;
|
|
502
|
+
case ".bb-circle":
|
|
503
|
+
mergeThemeSection(target, "shape", {
|
|
504
|
+
pointFillColor: readColorValue(style, "fill"),
|
|
505
|
+
pointStrokeColor: readColorValue(style, "stroke"),
|
|
506
|
+
pointLineWidth: readNumberValue(style, "stroke-width")
|
|
507
|
+
});
|
|
508
|
+
break;
|
|
509
|
+
case ".bb-selected-circle":
|
|
510
|
+
mergeThemeSection(target, "selectedPoint", {
|
|
511
|
+
fill: readColorValue(style, "fill"),
|
|
512
|
+
stroke: readColorValue(style, "stroke"),
|
|
513
|
+
lineWidth: readNumberValue(style, "stroke-width")
|
|
514
|
+
});
|
|
515
|
+
break;
|
|
516
|
+
case ".bb-circle._expanded_":
|
|
517
|
+
mergeThemeSection(target, "focusPoint", {
|
|
518
|
+
fill: readColorValue(style, "fill"),
|
|
519
|
+
stroke: readColorValue(style, "stroke"),
|
|
520
|
+
lineWidth: readNumberValue(style, "stroke-width")
|
|
521
|
+
});
|
|
522
|
+
break;
|
|
523
|
+
case ".bb-zoom-brush":
|
|
524
|
+
mergeThemeSection(target, "zoomBrush", {
|
|
525
|
+
fill: readColorValue(style, "fill"),
|
|
526
|
+
opacity: readPaintOpacityValue(style)
|
|
527
|
+
});
|
|
528
|
+
break;
|
|
529
|
+
case ".bb-brush .extent":
|
|
530
|
+
case ".bb-brush .selection":
|
|
531
|
+
mergeThemeSection(target, "subchartBrush", {
|
|
532
|
+
fill: readColorValue(style, "fill"),
|
|
533
|
+
opacity: readPaintOpacityValue(style)
|
|
534
|
+
});
|
|
535
|
+
break;
|
|
536
|
+
case ".bb-brush .handle--custom":
|
|
537
|
+
mergeThemeSection(target, "subchartBrush", {
|
|
538
|
+
handleFill: readColorValue(style, "fill"),
|
|
539
|
+
handleOpacity: readPaintOpacityValue(style),
|
|
540
|
+
handleStroke: readColorValue(style, "stroke"),
|
|
541
|
+
handleLineWidth: readNumberValue(style, "stroke-width")
|
|
542
|
+
});
|
|
543
|
+
break;
|
|
544
|
+
case ".bb-chart-treemaps rect":
|
|
545
|
+
case ".bb-chart-treemaps":
|
|
546
|
+
mergeThemeSection(target, "treemap", {
|
|
547
|
+
stroke: readColorValue(style, "stroke"),
|
|
548
|
+
lineWidth: readNumberValue(style, "stroke-width")
|
|
549
|
+
});
|
|
550
|
+
break;
|
|
551
|
+
case ".bb-text.bb-empty":
|
|
552
|
+
case ".bb-text .bb-empty":
|
|
553
|
+
case ".bb-empty":
|
|
554
|
+
mergeThemeSection(target, "emptyLabel", {
|
|
555
|
+
color: readColorValue(style, "fill"),
|
|
556
|
+
font: readFontValue(style)
|
|
557
|
+
});
|
|
558
|
+
break;
|
|
559
|
+
case ".bb-text":
|
|
560
|
+
mergeThemeSection(target, "label", {
|
|
561
|
+
color: readColorValue(style, "fill"),
|
|
562
|
+
font: readFontValue(style)
|
|
563
|
+
});
|
|
564
|
+
break;
|
|
565
|
+
case ".bb-title":
|
|
566
|
+
mergeThemeSection(target, "title", {
|
|
567
|
+
color: readColorValue(style, "fill"),
|
|
568
|
+
font: readFontValue(style)
|
|
569
|
+
});
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
500
572
|
}
|
|
501
573
|
/**
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
574
|
+
* Convert selector based canvas theme overrides to renderer theme slots.
|
|
575
|
+
* @param {object} selectors Selector style declarations
|
|
576
|
+
* @returns {object} Canvas theme override
|
|
577
|
+
* @private
|
|
578
|
+
*/
|
|
507
579
|
function getSelectorThemeOverride(selectors) {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
580
|
+
const override = {};
|
|
581
|
+
Object.keys(selectors ?? {}).forEach((selector) => {
|
|
582
|
+
normalizeThemeSelectors(selector).forEach((normalizedSelector) => {
|
|
583
|
+
applySelectorStyle(override, normalizedSelector, selectors[selector]);
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
return override;
|
|
515
587
|
}
|
|
516
588
|
/**
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
589
|
+
* Resolve user canvas theme override.
|
|
590
|
+
* @param {object} userOverride Canvas theme override
|
|
591
|
+
* @returns {object} Canvas theme override
|
|
592
|
+
* @private
|
|
593
|
+
*/
|
|
522
594
|
function getThemeOverride(userOverride) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
const { selectors, ...styleOverride } = userOverride;
|
|
527
|
-
return mergeObj({}, getSelectorThemeOverride(selectors), styleOverride);
|
|
595
|
+
if (!userOverride) return {};
|
|
596
|
+
const { selectors, ...styleOverride } = userOverride;
|
|
597
|
+
return mergeObj({}, getSelectorThemeOverride(selectors), styleOverride);
|
|
528
598
|
}
|
|
529
599
|
/**
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
600
|
+
* Build a stable enough cache key for theme reloads.
|
|
601
|
+
* @param {HTMLElement} container Chart container
|
|
602
|
+
* @param {object} userOverride Canvas theme override
|
|
603
|
+
* @returns {string|null} Cache key
|
|
604
|
+
* @private
|
|
605
|
+
*/
|
|
536
606
|
function getThemeCacheKey(container, userOverride) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}
|
|
607
|
+
try {
|
|
608
|
+
return JSON.stringify({
|
|
609
|
+
className: container.className,
|
|
610
|
+
style: container.getAttribute("style") || "",
|
|
611
|
+
override: userOverride || null
|
|
612
|
+
});
|
|
613
|
+
} catch {
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
547
616
|
}
|
|
548
617
|
/**
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
style.textContent = `
|
|
618
|
+
* Resolve canvas drawing styles from the existing SVG CSS theme.
|
|
619
|
+
* @private
|
|
620
|
+
*/
|
|
621
|
+
var CanvasTheme = class {
|
|
622
|
+
style;
|
|
623
|
+
cacheContainer = null;
|
|
624
|
+
cacheKey = null;
|
|
625
|
+
gridLineSelectorOverrides = [];
|
|
626
|
+
directGridOverrideKeys = /* @__PURE__ */ new Set();
|
|
627
|
+
/**
|
|
628
|
+
* Read theme values from temporary SVG probes.
|
|
629
|
+
* @param {HTMLElement} container Chart container
|
|
630
|
+
* @param {object} userOverride Canvas theme override
|
|
631
|
+
* @private
|
|
632
|
+
*/
|
|
633
|
+
load(container, userOverride) {
|
|
634
|
+
const svg = doc.createElementNS(SVG_NS, "svg");
|
|
635
|
+
this.gridLineSelectorOverrides = getGridLineSelectorOverrides(userOverride?.selectors);
|
|
636
|
+
this.directGridOverrideKeys = new Set(Object.keys(userOverride?.grid ?? {}));
|
|
637
|
+
svg.setAttribute("class", "bb");
|
|
638
|
+
svg.style.cssText = "position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;overflow:hidden";
|
|
639
|
+
container.appendChild(svg);
|
|
640
|
+
const read = (el, props) => {
|
|
641
|
+
const style = win.getComputedStyle(el);
|
|
642
|
+
const values = {};
|
|
643
|
+
for (const prop of props) values[prop] = prop === "font" ? toFont(style, "") : style.getPropertyValue(prop).trim();
|
|
644
|
+
return values;
|
|
645
|
+
};
|
|
646
|
+
const probe = (tag, cls, props) => {
|
|
647
|
+
const el = doc.createElementNS(SVG_NS, tag);
|
|
648
|
+
el.setAttribute("class", cls);
|
|
649
|
+
svg.appendChild(el);
|
|
650
|
+
const value = read(el, props);
|
|
651
|
+
svg.removeChild(el);
|
|
652
|
+
return value;
|
|
653
|
+
};
|
|
654
|
+
const probeIn = (parentCls, tag, cls, props) => {
|
|
655
|
+
const parent = doc.createElementNS(SVG_NS, "g");
|
|
656
|
+
const el = doc.createElementNS(SVG_NS, tag);
|
|
657
|
+
parent.setAttribute("class", parentCls);
|
|
658
|
+
cls && el.setAttribute("class", cls);
|
|
659
|
+
parent.appendChild(el);
|
|
660
|
+
svg.appendChild(parent);
|
|
661
|
+
const value = read(el, props);
|
|
662
|
+
svg.removeChild(parent);
|
|
663
|
+
return value;
|
|
664
|
+
};
|
|
665
|
+
const probeInNested = (parentCls, groupCls, tag, cls, props) => {
|
|
666
|
+
const parent = doc.createElementNS(SVG_NS, "g");
|
|
667
|
+
const group = doc.createElementNS(SVG_NS, "g");
|
|
668
|
+
const el = doc.createElementNS(SVG_NS, tag);
|
|
669
|
+
parent.setAttribute("class", parentCls);
|
|
670
|
+
group.setAttribute("class", groupCls);
|
|
671
|
+
cls && el.setAttribute("class", cls);
|
|
672
|
+
group.appendChild(el);
|
|
673
|
+
parent.appendChild(group);
|
|
674
|
+
svg.appendChild(parent);
|
|
675
|
+
const value = read(el, props);
|
|
676
|
+
svg.removeChild(parent);
|
|
677
|
+
return value;
|
|
678
|
+
};
|
|
679
|
+
const probeTick = (axisCls, tag, props, tickCls = "") => {
|
|
680
|
+
const axis = doc.createElementNS(SVG_NS, "g");
|
|
681
|
+
const tick = doc.createElementNS(SVG_NS, "g");
|
|
682
|
+
const el = doc.createElementNS(SVG_NS, tag);
|
|
683
|
+
axis.setAttribute("class", `bb-axis ${axisCls}`);
|
|
684
|
+
tick.setAttribute("class", ["tick", tickCls].filter(Boolean).join(" "));
|
|
685
|
+
el.textContent = tag === "text" ? "0" : "";
|
|
686
|
+
tick.appendChild(el);
|
|
687
|
+
axis.appendChild(tick);
|
|
688
|
+
svg.appendChild(axis);
|
|
689
|
+
const value = read(el, props);
|
|
690
|
+
svg.removeChild(axis);
|
|
691
|
+
return value;
|
|
692
|
+
};
|
|
693
|
+
const targetPointPaint = "rgb(1, 2, 3)";
|
|
694
|
+
const probeTargetPoint = (cls, props) => {
|
|
695
|
+
const style = doc.createElement("style");
|
|
696
|
+
style.textContent = `
|
|
629
697
|
.bb-shapes-canvas-probe .bb-circle {
|
|
630
698
|
fill: ${targetPointPaint};
|
|
631
699
|
stroke: ${targetPointPaint};
|
|
632
700
|
}
|
|
633
701
|
`;
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
}
|
|
875
|
-
|
|
702
|
+
doc.head.appendChild(style);
|
|
703
|
+
try {
|
|
704
|
+
return probeIn("bb-shapes bb-shapes-canvas-probe", "circle", cls, props);
|
|
705
|
+
} finally {
|
|
706
|
+
style.remove();
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
const axisLine = probeIn("bb-axis bb-axis-x", "path", "domain", ["stroke", "stroke-width"]);
|
|
710
|
+
const tickLine = probeTick("bb-axis-x", "line", ["stroke", "stroke-width"]);
|
|
711
|
+
const xAxisText = probeTick("bb-axis-x", "text", ["fill", "font"]);
|
|
712
|
+
const activeAxisText = probeTick("bb-axis-x", "text", ["fill"], "_active_");
|
|
713
|
+
const axisText = probeTick("bb-axis-y", "text", ["fill", "font"]);
|
|
714
|
+
const y2AxisText = probeTick("bb-axis-y2", "text", ["fill", "font"]);
|
|
715
|
+
const xAxisLabel = probeIn("bb-axis bb-axis-x", "text", "bb-axis-x-label", ["fill", "font"]);
|
|
716
|
+
const yAxisLabel = probeIn("bb-axis bb-axis-y", "text", "bb-axis-y-label", ["fill", "font"]);
|
|
717
|
+
const y2AxisLabel = probeIn("bb-axis bb-axis-y2", "text", "bb-axis-y2-label", ["fill", "font"]);
|
|
718
|
+
const plainCircle = probe("circle", "", [
|
|
719
|
+
"fill",
|
|
720
|
+
"stroke",
|
|
721
|
+
"stroke-width"
|
|
722
|
+
]);
|
|
723
|
+
const gridLine = probeIn("bb-grid", "line", "bb-ygrid", [
|
|
724
|
+
"stroke",
|
|
725
|
+
"stroke-width",
|
|
726
|
+
"stroke-dasharray"
|
|
727
|
+
]);
|
|
728
|
+
const gridText = probeIn("bb-grid", "text", "", ["fill", "font"]);
|
|
729
|
+
const focusGridLine = probeInNested("bb-grid", "bb-xgrid-focus", "line", "bb-xgrid-focus", [
|
|
730
|
+
"stroke",
|
|
731
|
+
"stroke-width",
|
|
732
|
+
"stroke-dasharray"
|
|
733
|
+
]);
|
|
734
|
+
const emptyLabel = probe("text", "bb-text bb-empty", ["fill", "font"]);
|
|
735
|
+
const regionRect = probeIn("bb-region", "rect", "", ["fill", "fill-opacity"]);
|
|
736
|
+
const regionLabel = probeIn("bb-region", "text", "", ["fill", "font"]);
|
|
737
|
+
const bar = probe("path", "bb-bar", [
|
|
738
|
+
"opacity",
|
|
739
|
+
"fill-opacity",
|
|
740
|
+
"stroke",
|
|
741
|
+
"stroke-width"
|
|
742
|
+
]);
|
|
743
|
+
const barExpanded = probe("path", "bb-bar _expanded_", ["opacity", "fill-opacity"]);
|
|
744
|
+
const candlestick = probe("path", "bb-candlestick", ["stroke", "stroke-width"]);
|
|
745
|
+
const candlestickExpanded = probe("path", "bb-candlestick _expanded_", ["opacity", "fill-opacity"]);
|
|
746
|
+
const line = probe("path", "bb-line", ["stroke-width"]);
|
|
747
|
+
const focusedLine = probeIn("bb-target bb-focused", "path", "bb-line", ["stroke-width"]);
|
|
748
|
+
const defocusedTarget = probe("g", "bb-target bb-defocused", ["opacity"]);
|
|
749
|
+
const area = probe("path", "bb-area", ["opacity", "fill-opacity"]);
|
|
750
|
+
const point = probe("circle", "bb-circle", [
|
|
751
|
+
"fill",
|
|
752
|
+
"stroke",
|
|
753
|
+
"stroke-width"
|
|
754
|
+
]);
|
|
755
|
+
const selectedPoint = probe("circle", "bb-selected-circle", [
|
|
756
|
+
"fill",
|
|
757
|
+
"stroke",
|
|
758
|
+
"stroke-width"
|
|
759
|
+
]);
|
|
760
|
+
const focusPoint = probeTargetPoint("bb-circle _expanded_", [
|
|
761
|
+
"fill",
|
|
762
|
+
"stroke",
|
|
763
|
+
"stroke-width"
|
|
764
|
+
]);
|
|
765
|
+
const zoomBrush = probe("rect", "bb-zoom-brush", [
|
|
766
|
+
"fill",
|
|
767
|
+
"fill-opacity",
|
|
768
|
+
"opacity"
|
|
769
|
+
]);
|
|
770
|
+
const subchartBrushExtent = probeIn("bb-brush", "rect", "extent", [
|
|
771
|
+
"fill",
|
|
772
|
+
"fill-opacity",
|
|
773
|
+
"opacity"
|
|
774
|
+
]);
|
|
775
|
+
const subchartBrushSelection = probeIn("bb-brush", "rect", "selection", [
|
|
776
|
+
"fill",
|
|
777
|
+
"fill-opacity",
|
|
778
|
+
"opacity"
|
|
779
|
+
]);
|
|
780
|
+
const subchartBrushHandle = probeIn("bb-brush", "path", "handle--custom", [
|
|
781
|
+
"fill",
|
|
782
|
+
"fill-opacity",
|
|
783
|
+
"opacity",
|
|
784
|
+
"stroke",
|
|
785
|
+
"stroke-width"
|
|
786
|
+
]);
|
|
787
|
+
const treemap = probeIn("bb-chart-treemaps", "rect", "", ["stroke", "stroke-width"]);
|
|
788
|
+
const label = probe("text", "bb-text", ["fill", "font"]);
|
|
789
|
+
const title = probeIn("", "text", "bb-title", ["fill", "font"]);
|
|
790
|
+
const zoomBrushFill = toColor(zoomBrush.fill, "#000");
|
|
791
|
+
const zoomBrushOpacity = toNumber(zoomBrush["fill-opacity"] || zoomBrush.opacity, .1);
|
|
792
|
+
const subchartBrushFill = toColor(subchartBrushSelection.fill, toColor(subchartBrushExtent.fill, zoomBrushFill));
|
|
793
|
+
const subchartBrushOpacity = toOptionalNumber(subchartBrushSelection["fill-opacity"], 1) ?? toOptionalNumber(subchartBrushSelection.opacity, 1) ?? toOptionalNumber(subchartBrushExtent["fill-opacity"], 1) ?? toOptionalNumber(subchartBrushExtent.opacity, 1) ?? zoomBrushOpacity;
|
|
794
|
+
const subchartBrushHandleStroke = toColor(subchartBrushHandle.stroke, "transparent");
|
|
795
|
+
const defaultStyle = {
|
|
796
|
+
axis: {
|
|
797
|
+
lineColor: toColor(axisLine.stroke, "#000"),
|
|
798
|
+
lineWidth: toNumber(axisLine["stroke-width"], 1),
|
|
799
|
+
tickColor: toColor(tickLine.stroke, toColor(axisLine.stroke, "#000")),
|
|
800
|
+
tickWidth: toNumber(tickLine["stroke-width"], toNumber(axisLine["stroke-width"], 1)),
|
|
801
|
+
labelFont: yAxisLabel.font || axisText.font || "10px sans-serif",
|
|
802
|
+
xTickFont: xAxisText.font || axisText.font || "10px sans-serif",
|
|
803
|
+
yTickFont: axisText.font || "10px sans-serif",
|
|
804
|
+
y2TickFont: y2AxisText.font || axisText.font || "10px sans-serif",
|
|
805
|
+
labelColor: toColor(axisText.fill, "#000"),
|
|
806
|
+
xLabelColor: toColor(xAxisLabel.fill, toColor(xAxisText.fill, "#000")),
|
|
807
|
+
yLabelColor: toColor(yAxisLabel.fill, toColor(axisText.fill, "#000")),
|
|
808
|
+
y2LabelColor: toColor(y2AxisLabel.fill, toColor(yAxisLabel.fill, toColor(axisText.fill, "#000"))),
|
|
809
|
+
activeLabelColor: toOptionalColor(activeAxisText.fill, xAxisText.fill) || toColor(axisText.fill, "#000")
|
|
810
|
+
},
|
|
811
|
+
grid: {
|
|
812
|
+
lineColor: toColor(gridLine.stroke, "#aaa"),
|
|
813
|
+
lineWidth: toNumber(gridLine["stroke-width"], 1),
|
|
814
|
+
dashArray: toDashArray(gridLine["stroke-dasharray"]),
|
|
815
|
+
labelFont: gridText.font || axisText.font || "10px sans-serif",
|
|
816
|
+
labelColor: toColor(gridText.fill, "#aaa")
|
|
817
|
+
},
|
|
818
|
+
focusGrid: {
|
|
819
|
+
lineColor: toColor(focusGridLine.stroke, toColor(gridLine.stroke, "#aaa")),
|
|
820
|
+
lineWidth: toNumber(focusGridLine["stroke-width"], toNumber(gridLine["stroke-width"], 1)),
|
|
821
|
+
dashArray: toDashArray(focusGridLine["stroke-dasharray"] || gridLine["stroke-dasharray"])
|
|
822
|
+
},
|
|
823
|
+
emptyLabel: {
|
|
824
|
+
font: emptyLabel.font || label.font || axisText.font || "20px sans-serif",
|
|
825
|
+
color: toColor(emptyLabel.fill, "#808080")
|
|
826
|
+
},
|
|
827
|
+
region: {
|
|
828
|
+
fill: toColor(regionRect.fill, "steelblue"),
|
|
829
|
+
opacity: toNumber(regionRect["fill-opacity"], .1),
|
|
830
|
+
labelFont: regionLabel.font || axisText.font || "10px sans-serif",
|
|
831
|
+
labelColor: toColor(regionLabel.fill, "#000")
|
|
832
|
+
},
|
|
833
|
+
shape: {
|
|
834
|
+
barOpacity: toPaintOpacity(bar, 1),
|
|
835
|
+
barExpandedOpacity: toNumber(toPaintOpacity(barExpanded, toPaintOpacity(bar, 1)), toPaintOpacity(bar, 1)),
|
|
836
|
+
barStrokeColor: toColor(bar.stroke, "#000"),
|
|
837
|
+
barLineWidth: toNumber(bar["stroke-width"], 0),
|
|
838
|
+
barConnectLineColor: toColor(line.stroke, "#000"),
|
|
839
|
+
barConnectLineWidth: toNumber(line["stroke-width"], 1),
|
|
840
|
+
candlestickStrokeColor: toColor(candlestick.stroke, "#000"),
|
|
841
|
+
candlestickLineWidth: toNumber(candlestick["stroke-width"], 1),
|
|
842
|
+
candlestickExpandedOpacity: toNumber(toPaintOpacity(candlestickExpanded, 1), 1),
|
|
843
|
+
lineWidth: toNumber(line["stroke-width"], 1),
|
|
844
|
+
lineFocusedWidth: toNumber(focusedLine["stroke-width"], 2),
|
|
845
|
+
areaOpacity: toPaintOpacity(area, .2),
|
|
846
|
+
targetDefocusedOpacity: toNumber(defocusedTarget.opacity, .3),
|
|
847
|
+
pointFillColor: toOptionalColor(point.fill, plainCircle.fill),
|
|
848
|
+
pointStrokeColor: toOptionalColor(point.stroke, plainCircle.stroke),
|
|
849
|
+
pointLineWidth: toOptionalNumber(point["stroke-width"], plainCircle["stroke-width"])
|
|
850
|
+
},
|
|
851
|
+
selectedPoint: {
|
|
852
|
+
fill: toColor(selectedPoint.fill, "#fff"),
|
|
853
|
+
stroke: toOptionalColor(selectedPoint.stroke),
|
|
854
|
+
lineWidth: toNumber(selectedPoint["stroke-width"], 2)
|
|
855
|
+
},
|
|
856
|
+
focusPoint: {
|
|
857
|
+
fill: toOptionalColor(focusPoint.fill, targetPointPaint),
|
|
858
|
+
stroke: toOptionalColor(focusPoint.stroke, targetPointPaint),
|
|
859
|
+
lineWidth: toNumber(focusPoint["stroke-width"], 1)
|
|
860
|
+
},
|
|
861
|
+
zoomBrush: {
|
|
862
|
+
fill: zoomBrushFill,
|
|
863
|
+
opacity: zoomBrushOpacity
|
|
864
|
+
},
|
|
865
|
+
subchartBrush: {
|
|
866
|
+
fill: subchartBrushFill,
|
|
867
|
+
opacity: subchartBrushOpacity,
|
|
868
|
+
handleFill: toColor(subchartBrushHandle.fill, "transparent"),
|
|
869
|
+
handleOpacity: toPaintOpacity(subchartBrushHandle, 1),
|
|
870
|
+
handleStroke: subchartBrushHandleStroke,
|
|
871
|
+
handleLineWidth: toNumber(subchartBrushHandle["stroke-width"], subchartBrushHandleStroke === "transparent" ? 0 : 1)
|
|
872
|
+
},
|
|
873
|
+
treemap: {
|
|
874
|
+
stroke: toColor(treemap.stroke, "#fff"),
|
|
875
|
+
lineWidth: toNumber(treemap["stroke-width"], 1)
|
|
876
|
+
},
|
|
877
|
+
label: {
|
|
878
|
+
font: label.font || axisText.font || "10px sans-serif",
|
|
879
|
+
color: toColor(label.fill, "#000")
|
|
880
|
+
},
|
|
881
|
+
title: {
|
|
882
|
+
font: title.font || label.font || axisText.font || "14px sans-serif",
|
|
883
|
+
color: toColor(title.fill, "#000")
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
const style = mergeObj(defaultStyle, getThemeOverride(userOverride));
|
|
887
|
+
const userAxisOverride = userOverride?.axis;
|
|
888
|
+
const hasUserAxisLabelColor = !!userAxisOverride && Object.prototype.hasOwnProperty.call(userAxisOverride, "labelColor");
|
|
889
|
+
const hasUserAxisLabelFont = !!userAxisOverride && Object.prototype.hasOwnProperty.call(userAxisOverride, "labelFont");
|
|
890
|
+
style.axis.lineWidth = toNumber(style.axis.lineWidth, defaultStyle.axis.lineWidth);
|
|
891
|
+
style.axis.tickWidth = toNumber(style.axis.tickWidth, style.axis.lineWidth);
|
|
892
|
+
if (hasUserAxisLabelFont) {
|
|
893
|
+
const axisOverride = userAxisOverride;
|
|
894
|
+
const labelFont = style.axis.labelFont;
|
|
895
|
+
axisOverride.xTickFont === void 0 && (style.axis.xTickFont = labelFont);
|
|
896
|
+
axisOverride.yTickFont === void 0 && (style.axis.yTickFont = labelFont);
|
|
897
|
+
axisOverride.y2TickFont === void 0 && (style.axis.y2TickFont = labelFont);
|
|
898
|
+
}
|
|
899
|
+
style.axis.labelFont = style.axis.labelFont || defaultStyle.axis.labelFont;
|
|
900
|
+
style.axis.xTickFont = style.axis.xTickFont || style.axis.labelFont;
|
|
901
|
+
style.axis.yTickFont = style.axis.yTickFont || style.axis.labelFont;
|
|
902
|
+
style.axis.y2TickFont = style.axis.y2TickFont || style.axis.yTickFont;
|
|
903
|
+
style.axis.labelColor = toColor(style.axis.labelColor, defaultStyle.axis.labelColor);
|
|
904
|
+
if (hasUserAxisLabelColor) {
|
|
905
|
+
const labelColor = style.axis.labelColor;
|
|
906
|
+
userAxisOverride.xLabelColor === void 0 && (style.axis.xLabelColor = labelColor);
|
|
907
|
+
userAxisOverride.yLabelColor === void 0 && (style.axis.yLabelColor = labelColor);
|
|
908
|
+
userAxisOverride.y2LabelColor === void 0 && (style.axis.y2LabelColor = labelColor);
|
|
909
|
+
}
|
|
910
|
+
style.axis.xLabelColor = toColor(style.axis.xLabelColor, style.axis.labelColor);
|
|
911
|
+
style.axis.yLabelColor = toColor(style.axis.yLabelColor, style.axis.labelColor);
|
|
912
|
+
style.axis.y2LabelColor = toColor(style.axis.y2LabelColor, style.axis.yLabelColor);
|
|
913
|
+
style.axis.activeLabelColor = toColor(style.axis.activeLabelColor, style.axis.labelColor);
|
|
914
|
+
style.grid.lineWidth = toNumber(style.grid.lineWidth, defaultStyle.grid.lineWidth);
|
|
915
|
+
style.grid.dashArray = toDashArray(style.grid.dashArray);
|
|
916
|
+
style.focusGrid.lineWidth = toNumber(style.focusGrid.lineWidth, defaultStyle.focusGrid.lineWidth);
|
|
917
|
+
style.focusGrid.dashArray = toDashArray(style.focusGrid.dashArray);
|
|
918
|
+
style.region.opacity = toNumber(style.region.opacity, defaultStyle.region.opacity);
|
|
919
|
+
style.shape.barOpacity = toNumber(style.shape.barOpacity, defaultStyle.shape.barOpacity);
|
|
920
|
+
style.shape.barExpandedOpacity = toNumber(style.shape.barExpandedOpacity, style.shape.barOpacity);
|
|
921
|
+
style.shape.barLineWidth = toNumber(style.shape.barLineWidth, defaultStyle.shape.barLineWidth);
|
|
922
|
+
style.shape.barConnectLineWidth = toNumber(style.shape.barConnectLineWidth, defaultStyle.shape.barConnectLineWidth);
|
|
923
|
+
style.shape.candlestickLineWidth = toNumber(style.shape.candlestickLineWidth, defaultStyle.shape.candlestickLineWidth);
|
|
924
|
+
style.shape.candlestickStrokeColor = toColor(style.shape.candlestickStrokeColor, defaultStyle.shape.candlestickStrokeColor);
|
|
925
|
+
style.shape.candlestickExpandedOpacity = toNumber(style.shape.candlestickExpandedOpacity, defaultStyle.shape.candlestickExpandedOpacity);
|
|
926
|
+
style.shape.lineWidth = toNumber(style.shape.lineWidth, defaultStyle.shape.lineWidth);
|
|
927
|
+
style.shape.lineFocusedWidth = toNumber(style.shape.lineFocusedWidth, defaultStyle.shape.lineFocusedWidth);
|
|
928
|
+
style.shape.areaOpacity = toNumber(style.shape.areaOpacity, defaultStyle.shape.areaOpacity);
|
|
929
|
+
style.shape.targetDefocusedOpacity = toNumber(style.shape.targetDefocusedOpacity, defaultStyle.shape.targetDefocusedOpacity);
|
|
930
|
+
style.shape.pointLineWidth = toOptionalNumber(style.shape.pointLineWidth);
|
|
931
|
+
style.selectedPoint.lineWidth = toNumber(style.selectedPoint.lineWidth, defaultStyle.selectedPoint.lineWidth);
|
|
932
|
+
style.focusPoint.lineWidth = toNumber(style.focusPoint.lineWidth, defaultStyle.focusPoint.lineWidth);
|
|
933
|
+
style.zoomBrush.opacity = toNumber(style.zoomBrush.opacity, defaultStyle.zoomBrush.opacity);
|
|
934
|
+
style.subchartBrush.opacity = toNumber(style.subchartBrush.opacity, defaultStyle.subchartBrush.opacity);
|
|
935
|
+
style.subchartBrush.handleOpacity = toNumber(style.subchartBrush.handleOpacity, defaultStyle.subchartBrush.handleOpacity);
|
|
936
|
+
style.subchartBrush.handleLineWidth = toNumber(style.subchartBrush.handleLineWidth, defaultStyle.subchartBrush.handleLineWidth);
|
|
937
|
+
style.treemap.lineWidth = toNumber(style.treemap.lineWidth, defaultStyle.treemap.lineWidth);
|
|
938
|
+
this.style = style;
|
|
939
|
+
this.cacheContainer = container;
|
|
940
|
+
this.cacheKey = getThemeCacheKey(container, userOverride);
|
|
941
|
+
svg.remove();
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Reload theme values after resize or option changes.
|
|
945
|
+
* @param {HTMLElement} container Chart container
|
|
946
|
+
* @param {object} userOverride Canvas theme override
|
|
947
|
+
* @private
|
|
948
|
+
*/
|
|
949
|
+
reload(container, userOverride) {
|
|
950
|
+
const key = getThemeCacheKey(container, userOverride);
|
|
951
|
+
if (key !== null && this.style && this.cacheContainer === container && this.cacheKey === key) return;
|
|
952
|
+
this.load(container, userOverride);
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Resolve selector based style for one configured optional grid line.
|
|
956
|
+
* @param {string} axis Grid axis
|
|
957
|
+
* @param {object} line Grid line options
|
|
958
|
+
* @param {string} line.class Grid line custom class
|
|
959
|
+
* @param {string} target Draw target
|
|
960
|
+
* @returns {object|undefined} Grid line style override
|
|
961
|
+
* @private
|
|
962
|
+
*/
|
|
963
|
+
getGridLineStyle(axis, line = {}, target = "line") {
|
|
964
|
+
const style = {};
|
|
965
|
+
for (const override of this.gridLineSelectorOverrides) {
|
|
966
|
+
if (!matchesGridLineSelector(override.selector, axis, line.class, target)) continue;
|
|
967
|
+
assignDefined(style, override.style, this.directGridOverrideKeys);
|
|
968
|
+
}
|
|
969
|
+
return getDefinedKeys(style).length ? style : void 0;
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
//#endregion
|
|
876
973
|
export { CanvasTheme as default };
|