billboard.js 4.0.3 → 4.1.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -7
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +1841 -491
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +19 -24
- package/dist/billboard.pkgd.js +1837 -676
- 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 +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +3 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +3 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +57 -27
- package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +72 -54
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +3 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +57 -27
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +11 -11
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +65 -3556
- 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 +6 -0
- 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/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,306 +5,431 @@
|
|
|
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.1
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
|
|
10
|
+
import { SUBCHART_BRUSH_HANDLE_PATH } from "../../config/const.js";
|
|
11
|
+
import { window as win } from "../../module/browser.js";
|
|
12
|
+
import { isArray } from "../../module/util/type-checks.js";
|
|
13
|
+
import { capitalize } from "../../module/util/object.js";
|
|
14
|
+
import { emulateEvent, getBoundingRect, getPointer } from "../../module/util/dom.js";
|
|
15
|
+
import { brushEmpty } from "../../module/util/brush.js";
|
|
16
|
+
import classes_default from "../../config/classes.js";
|
|
17
|
+
import { getMainCoordFromSubchartCoord, isContinuousGridFocusEnabled } from "../internals/subchart.util.js";
|
|
18
|
+
import { select } from "d3-selection";
|
|
19
|
+
import { brushSelection, brushX, brushY } from "d3-brush";
|
|
20
|
+
//#region src/ChartInternal/interactions/subchart.ts
|
|
18
21
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
22
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
23
|
+
* billboard.js project is licensed under the MIT license
|
|
24
|
+
*/
|
|
25
|
+
const SUBCHART_TYPES = [
|
|
26
|
+
"bar",
|
|
27
|
+
"line",
|
|
28
|
+
"bubble",
|
|
29
|
+
"candlestick",
|
|
30
|
+
"scatter"
|
|
31
|
+
];
|
|
32
|
+
const FOCUS_GRID_STYLE_PROPS = [
|
|
33
|
+
"opacity",
|
|
34
|
+
"stroke",
|
|
35
|
+
"stroke-dasharray",
|
|
36
|
+
"stroke-dashoffset",
|
|
37
|
+
"stroke-linecap",
|
|
38
|
+
"stroke-linejoin",
|
|
39
|
+
"stroke-miterlimit",
|
|
40
|
+
"stroke-opacity",
|
|
41
|
+
"stroke-width"
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Copy main focus grid computed styles to the subchart focus grid line.
|
|
45
|
+
* @param {object} $$ ChartInternal instance
|
|
46
|
+
* @param {object} line Subchart focus grid line selection
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
function syncSubchartGridFocusStyle($$, line) {
|
|
50
|
+
const source = $$.$el.grid?.main?.select(`line.${classes_default.xgridFocus}`).node();
|
|
51
|
+
if (!source || !win.getComputedStyle) return;
|
|
52
|
+
const style = win.getComputedStyle(source);
|
|
53
|
+
FOCUS_GRID_STYLE_PROPS.forEach((prop) => {
|
|
54
|
+
const value = style.getPropertyValue(prop);
|
|
55
|
+
value && line.style(prop, value);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Convert an SVG attr value to finite number with fallback.
|
|
60
|
+
* @param {string|null} value Attribute value
|
|
61
|
+
* @param {number} fallback Fallback value
|
|
62
|
+
* @returns {number} Numeric value
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
function getFiniteAttr(value, fallback) {
|
|
66
|
+
const parsed = Number(value);
|
|
67
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Show a single clipped-free x focus grid line spanning main chart and subchart.
|
|
71
|
+
* @param {object} $$ ChartInternal instance
|
|
72
|
+
* @returns {boolean} Whether continuous focus line was rendered
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
function showContinuousSubchartGridFocus($$) {
|
|
76
|
+
if (!isContinuousGridFocusEnabled($$)) return false;
|
|
77
|
+
const { config, state, $el } = $$;
|
|
78
|
+
const mainLine = $el.grid?.main?.select(`line.${classes_default.xgridFocus}:not(.${classes_default.xgridFocusContinuous})`);
|
|
79
|
+
const line = $el.main.select(`line.${classes_default.xgridFocusContinuous}`);
|
|
80
|
+
if (!mainLine?.node() || !line.node()) return false;
|
|
81
|
+
const x2 = state.margin2.left - state.margin.left + state.width2;
|
|
82
|
+
const y2 = state.margin2.top - state.margin.top + state.height2;
|
|
83
|
+
syncSubchartGridFocusStyle($$, line);
|
|
84
|
+
config.axis_rotated ? line.attr("x1", getFiniteAttr(mainLine.attr("x1"), 0)).attr("x2", x2).attr("y1", getFiniteAttr(mainLine.attr("y1"), -10)).attr("y2", getFiniteAttr(mainLine.attr("y2"), -10)) : line.attr("x1", getFiniteAttr(mainLine.attr("x1"), -10)).attr("x2", getFiniteAttr(mainLine.attr("x2"), -10)).attr("y1", getFiniteAttr(mainLine.attr("y1"), 0)).attr("y2", y2);
|
|
85
|
+
line.style("visibility", null);
|
|
86
|
+
mainLine.style("visibility", "hidden");
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Hide continuous subchart focus grid line.
|
|
91
|
+
* @param {object} $$ ChartInternal instance
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
function hideContinuousSubchartGridFocus($$) {
|
|
95
|
+
$$.$el.main?.select(`line.${classes_default.xgridFocusContinuous}`).style("visibility", "hidden");
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get main chart pointer coordinates that correspond to a subchart pointer event.
|
|
99
|
+
* @param {object} $$ ChartInternal instance
|
|
100
|
+
* @param {Event} event Input event
|
|
101
|
+
* @param {SVGElement} context Subchart event rect
|
|
102
|
+
* @returns {Array|null} Main chart local coordinates
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
function getMainPointFromSubchartEvent($$, event, context) {
|
|
106
|
+
const { config, state } = $$;
|
|
107
|
+
const [x, y] = getPointer(event, context);
|
|
108
|
+
const mainCoord = getMainCoordFromSubchartCoord($$, config.axis_rotated ? y : x);
|
|
109
|
+
if (mainCoord === null) return null;
|
|
110
|
+
return config.axis_rotated ? [state.width / 2, mainCoord] : [mainCoord, state.height / 2];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Dispatch a subchart pointer event through the main chart event rect.
|
|
114
|
+
* @param {object} $$ ChartInternal instance
|
|
115
|
+
* @param {string} type Event type
|
|
116
|
+
* @param {Event} event Input event
|
|
117
|
+
* @param {SVGElement} context Subchart event rect
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
function dispatchSubchartEvent($$, type, event, context) {
|
|
121
|
+
const mainEventRect = $$.$el.eventRect?.node?.();
|
|
122
|
+
if (!mainEventRect) return;
|
|
123
|
+
const point = getMainPointFromSubchartEvent($$, event, context) || [0, 0];
|
|
124
|
+
const rect = getBoundingRect(mainEventRect, true);
|
|
125
|
+
const clientX = rect.left + point[0];
|
|
126
|
+
const clientY = rect.top + point[1];
|
|
127
|
+
const params = {
|
|
128
|
+
bubbles: true,
|
|
129
|
+
cancelable: true,
|
|
130
|
+
screenX: clientX,
|
|
131
|
+
screenY: clientY,
|
|
132
|
+
clientX,
|
|
133
|
+
clientY
|
|
134
|
+
};
|
|
135
|
+
/^touch/.test(type) ? emulateEvent.touch(mainEventRect, type, params) : emulateEvent.mouse(mainEventRect, type, params);
|
|
136
|
+
}
|
|
137
|
+
var subchart_default = {
|
|
138
|
+
/**
|
|
139
|
+
* Whether subchart brush interaction is enabled.
|
|
140
|
+
* @returns {boolean}
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
isSubchartBrushEnabled() {
|
|
144
|
+
const { config } = this;
|
|
145
|
+
return config.subchart_show && config.subchart_brush_enabled !== false;
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* Bind event rect handlers for subchart hover interactions.
|
|
149
|
+
* @param {d3Selection} eventRect Subchart event rect selection
|
|
150
|
+
* @private
|
|
151
|
+
*/
|
|
152
|
+
bindSubchartEventRect(eventRect) {
|
|
153
|
+
const $$ = this;
|
|
154
|
+
const { config, state } = $$;
|
|
155
|
+
eventRect.on("mouseover mousemove mouseout touchstart touchmove touchend", null);
|
|
156
|
+
if (!config.interaction_enabled) return;
|
|
157
|
+
if (state.inputType === "mouse") eventRect.on("mouseover mousemove", function(event) {
|
|
158
|
+
if ($$.isSubchartBrushEnabled()) return;
|
|
159
|
+
dispatchSubchartEvent($$, event.type, event, this);
|
|
160
|
+
}).on("mouseout", function(event) {
|
|
161
|
+
if ($$.isSubchartBrushEnabled()) return;
|
|
162
|
+
dispatchSubchartEvent($$, "mouseout", event, this);
|
|
163
|
+
});
|
|
164
|
+
else if (state.inputType === "touch") eventRect.on("touchstart touchmove touchend", function(event) {
|
|
165
|
+
if ($$.isSubchartBrushEnabled() || event.touches?.length > 1) return;
|
|
166
|
+
dispatchSubchartEvent($$, event.type, event, this);
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* Initialize the brush.
|
|
171
|
+
* @private
|
|
172
|
+
*/
|
|
173
|
+
initBrush() {
|
|
174
|
+
const $$ = this;
|
|
175
|
+
const { config, scale, $el: { subchart }, state } = $$;
|
|
176
|
+
const isRotated = config.axis_rotated;
|
|
177
|
+
const height = config.subchart_size_height;
|
|
178
|
+
let lastDomain;
|
|
179
|
+
let lastSelection;
|
|
180
|
+
let timeout;
|
|
181
|
+
$$.brush = (isRotated ? brushY() : brushX()).handleSize(5);
|
|
182
|
+
$$.brush.on("start brush end", (event) => {
|
|
183
|
+
const { selection, sourceEvent, target, type } = event;
|
|
184
|
+
if (type === "start") {
|
|
185
|
+
$$.state.inputType === "touch" && $$.hideTooltip();
|
|
186
|
+
lastSelection = sourceEvent ? selection : null;
|
|
187
|
+
}
|
|
188
|
+
if (/(start|brush)/.test(type)) {
|
|
189
|
+
type === "brush" && sourceEvent && state.domain && lastSelection?.forEach((v, i) => {
|
|
190
|
+
if (v !== selection[i]) state.domain[i] = scale.x.orgDomain()[i];
|
|
191
|
+
});
|
|
192
|
+
$$.redrawForBrush(type !== "start");
|
|
193
|
+
}
|
|
194
|
+
if (type === "end") lastDomain = scale.x.orgDomain();
|
|
195
|
+
if (target?.handle) if (selection === null) $$.brush.handle.attr("display", "none");
|
|
196
|
+
else $$.brush.handle.attr("display", null).attr("transform", (d, i) => {
|
|
197
|
+
const pos = [selection[i], height / 2];
|
|
198
|
+
return `translate(${isRotated ? pos.reverse() : pos})`;
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
$$.brush.updateResize = function() {
|
|
202
|
+
timeout && clearTimeout(timeout);
|
|
203
|
+
timeout = setTimeout(() => {
|
|
204
|
+
const selection = this.getSelection();
|
|
205
|
+
lastDomain && brushSelection(selection.node()) && this.move(selection, lastDomain.map(scale.subX.orgScale()));
|
|
206
|
+
}, 0);
|
|
207
|
+
};
|
|
208
|
+
$$.brush.update = function() {
|
|
209
|
+
if (this.extent()()[1].filter((v) => isNaN(v)).length === 0) subchart.main?.select(`.${classes_default.brush}`).call(this);
|
|
210
|
+
return this;
|
|
211
|
+
};
|
|
212
|
+
$$.brush.scale = function(scale) {
|
|
213
|
+
const h = config.subchart_size_height;
|
|
214
|
+
let extent = $$.axis.getExtent();
|
|
215
|
+
if (!extent && scale.range) extent = [[0, 0], [scale.range()[1], h]];
|
|
216
|
+
else if (isArray(extent)) extent = extent.map((v, i) => [v, i > 0 ? h : i]);
|
|
217
|
+
isRotated && extent[1].reverse();
|
|
218
|
+
this.extent(extent);
|
|
219
|
+
this.update();
|
|
220
|
+
};
|
|
221
|
+
$$.brush.getSelection = () => subchart.main ? subchart.main.select(`.${classes_default.brush}`) : select([]);
|
|
222
|
+
},
|
|
223
|
+
/**
|
|
224
|
+
* Initialize the subchart.
|
|
225
|
+
* @private
|
|
226
|
+
*/
|
|
227
|
+
initSubchart() {
|
|
228
|
+
const $$ = this;
|
|
229
|
+
const { config, state: { clip, hasAxis }, $el: { defs, svg, subchart, axis } } = $$;
|
|
230
|
+
if (!hasAxis) return;
|
|
231
|
+
const visibility = config.subchart_show ? null : "hidden";
|
|
232
|
+
const clipId = `${clip.id}-subchart`;
|
|
233
|
+
const clipPath = $$.getClipPath(clipId);
|
|
234
|
+
clip.idSubchart = clipId;
|
|
235
|
+
$$.appendClip(defs, clipId);
|
|
236
|
+
$$.initBrush();
|
|
237
|
+
subchart.main = svg.append("g").classed(classes_default.subchart, true).attr("transform", $$.getTranslate("context"));
|
|
238
|
+
const { main } = subchart;
|
|
239
|
+
main.style("visibility", visibility);
|
|
240
|
+
main.append("g").attr("clip-path", clipPath).attr("class", classes_default.chart);
|
|
241
|
+
$$.withSubchartTypeContext(() => {
|
|
242
|
+
SUBCHART_TYPES.forEach((v) => {
|
|
243
|
+
const type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
|
|
244
|
+
if ($$.hasType(v) || $$.hasTypeOf(type)) {
|
|
245
|
+
const chart = main.select(`.${classes_default.chart}`);
|
|
246
|
+
const chartClassName = classes_default[`chart${type}s`];
|
|
247
|
+
if (chart.select(`.${chartClassName}`).empty()) chart.append("g").attr("class", chartClassName);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
const brush = main.append("g").attr("clip-path", clipPath).attr("class", classes_default.brush).style("pointer-events", $$.isSubchartBrushEnabled() ? null : "none").call($$.brush);
|
|
252
|
+
config.subchart_showHandle && $$.addBrushHandle(brush);
|
|
253
|
+
subchart.eventRect = main.append("g").attr("clip-path", clipPath).attr("class", `${classes_default.eventRects} ${classes_default.eventRects}-subchart`).style("fill-opacity", "0").style("pointer-events", $$.isSubchartBrushEnabled() ? "none" : "all").append("rect").attr("class", `${classes_default.eventRect} ${classes_default.eventRect}-subchart`).attr("width", $$.state.width2).attr("height", $$.state.height2);
|
|
254
|
+
$$.bindSubchartEventRect(subchart.eventRect);
|
|
255
|
+
main.append("g").attr("clip-path", clipPath).attr("class", classes_default.xgridFocus).append("line").attr("class", classes_default.xgridFocus).style("visibility", "hidden");
|
|
256
|
+
axis.subX = main.append("g").attr("class", classes_default.axisX).attr("transform", $$.getTranslate("subX")).attr("clip-path", config.axis_rotated ? "" : clip.pathXAxis).style("visibility", config.subchart_axis_x_show ? visibility : "hidden");
|
|
257
|
+
axis.subY = main.append("g").attr("class", classes_default.axisY).attr("transform", $$.getTranslate("subY")).style("visibility", config.subchart_axis_y_show ? visibility : "hidden");
|
|
258
|
+
axis.subY2 = main.append("g").attr("class", classes_default.axisY2).attr("transform", $$.getTranslate("subY2")).style("visibility", config.subchart_axis_y2_show ? visibility : "hidden");
|
|
259
|
+
},
|
|
260
|
+
/**
|
|
261
|
+
* Add brush handle
|
|
262
|
+
* Enabled when: subchart.showHandle=true
|
|
263
|
+
* @param {d3Selection} brush Brush selection
|
|
264
|
+
* @private
|
|
265
|
+
*/
|
|
266
|
+
addBrushHandle(brush) {
|
|
267
|
+
const $$ = this;
|
|
268
|
+
const { config } = $$;
|
|
269
|
+
const isRotated = config.axis_rotated;
|
|
270
|
+
const initRange = config.subchart_init_range;
|
|
271
|
+
const customHandleClass = "handle--custom";
|
|
272
|
+
const path = SUBCHART_BRUSH_HANDLE_PATH[isRotated ? "y" : "x"];
|
|
273
|
+
$$.brush.handle = brush.selectAll(`.${customHandleClass}`).data(isRotated ? [{ type: "n" }, { type: "s" }] : [{ type: "w" }, { type: "e" }]).enter().append("path").attr("class", customHandleClass).attr("cursor", `${isRotated ? "ns" : "ew"}-resize`).attr("d", (d) => path[/[se]/.test(d.type) ? "end" : "start"]).attr("display", initRange ? null : "none");
|
|
274
|
+
},
|
|
275
|
+
/**
|
|
276
|
+
* Update sub chart
|
|
277
|
+
* @param {object} targets $$.data.targets
|
|
278
|
+
* @private
|
|
279
|
+
*/
|
|
280
|
+
updateTargetsForSubchart(targets) {
|
|
281
|
+
const $$ = this;
|
|
282
|
+
const { config, state, $el: { subchart: { main } } } = $$;
|
|
283
|
+
if (config.subchart_show) {
|
|
284
|
+
$$.withSubchartTypeContext(() => {
|
|
285
|
+
SUBCHART_TYPES.filter((v) => $$.hasType(v) || $$.hasTypeOf(capitalize(v))).forEach((v) => {
|
|
286
|
+
const isPointType = /^(bubble|scatter)$/.test(v);
|
|
287
|
+
const name = capitalize(isPointType ? "circle" : v);
|
|
288
|
+
const chartClass = $$.getChartClass(name, true);
|
|
289
|
+
const shapeClass = $$.getClass(isPointType ? "circles" : `${v}s`, true);
|
|
290
|
+
const shapeChart = main.select(`.${classes_default[`chart${`${name}s`}`]}`);
|
|
291
|
+
if (isPointType) {
|
|
292
|
+
const circle = shapeChart.selectAll(`.${classes_default.circles}`).data(targets.filter($$[`is${capitalize(v)}Type`].bind($$))).attr("class", shapeClass);
|
|
293
|
+
circle.exit().remove();
|
|
294
|
+
circle.enter().append("g").attr("class", shapeClass);
|
|
295
|
+
} else {
|
|
296
|
+
const shapeUpdate = shapeChart.selectAll(`.${classes_default[`chart${name}`]}`).attr("class", chartClass).data(targets.filter($$[`is${name}Type`].bind($$)));
|
|
297
|
+
const shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
|
|
298
|
+
shapeUpdate.exit().remove();
|
|
299
|
+
v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", true));
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
main.selectAll(`.${classes_default.brush} rect`).attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? state.width2 : state.height2);
|
|
304
|
+
$$.$el.subchart.eventRect?.attr("width", state.width2).attr("height", state.height2).style("pointer-events", $$.isSubchartBrushEnabled() ? "none" : "all");
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
/**
|
|
308
|
+
* Update subchart y domains using subchart type options.
|
|
309
|
+
* @param {object} targets Targets to show
|
|
310
|
+
* @private
|
|
311
|
+
*/
|
|
312
|
+
updateSubchartYDomain(targets) {
|
|
313
|
+
const $$ = this;
|
|
314
|
+
const { scale } = $$;
|
|
315
|
+
const targetsToShow = targets || $$.filterTargetsToShow($$.data.targets);
|
|
316
|
+
scale.subY?.domain($$.getYDomain(targetsToShow, "y"));
|
|
317
|
+
scale.subY2?.domain($$.getYDomain(targetsToShow, "y2"));
|
|
318
|
+
},
|
|
319
|
+
/**
|
|
320
|
+
* Redraw subchart.
|
|
321
|
+
* @private
|
|
322
|
+
* @param {boolean} withSubchart whether or not to show subchart
|
|
323
|
+
* @param {number} duration duration
|
|
324
|
+
*/
|
|
325
|
+
redrawSubchart(withSubchart, duration) {
|
|
326
|
+
const $$ = this;
|
|
327
|
+
const { config, $el: { subchart: { main } }, state } = $$;
|
|
328
|
+
const withTransition = !!duration;
|
|
329
|
+
main.style("visibility", config.subchart_show ? null : "hidden");
|
|
330
|
+
main.select(`.${classes_default.brush}`).style("pointer-events", $$.isSubchartBrushEnabled() ? null : "none");
|
|
331
|
+
$$.$el.subchart.eventRect?.style("pointer-events", $$.isSubchartBrushEnabled() ? "none" : "all");
|
|
332
|
+
$$.$el.axis.subY?.style("visibility", config.subchart_axis_y_show ? null : "hidden");
|
|
333
|
+
$$.$el.axis.subY2?.style("visibility", config.subchart_axis_y2_show ? null : "hidden");
|
|
334
|
+
if (config.subchart_show) {
|
|
335
|
+
if (state.event?.type === "zoom") $$.brush.update();
|
|
336
|
+
if (withSubchart) {
|
|
337
|
+
const initRange = config.subchart_init_range;
|
|
338
|
+
!brushEmpty($$) && $$.brush.update();
|
|
339
|
+
$$.withSubchartTypeContext(() => {
|
|
340
|
+
const targetsToShow = state._targetsToShow || $$.filterTargetsToShow($$.data.targets);
|
|
341
|
+
$$.updateSubchartYDomain(targetsToShow);
|
|
342
|
+
const subchartShape = $$.getDrawShape();
|
|
343
|
+
Object.keys(subchartShape.type).forEach((v) => {
|
|
344
|
+
const name = capitalize(v);
|
|
345
|
+
const drawFn = $$[`generateDraw${name}`](subchartShape.indices[v], true);
|
|
346
|
+
$$[`update${name}`](withTransition, true);
|
|
347
|
+
$$[`redraw${name}`](drawFn, withTransition, true);
|
|
348
|
+
});
|
|
349
|
+
if ($$.hasType("bubble") || $$.hasType("scatter")) {
|
|
350
|
+
const { cx } = subchartShape.pos;
|
|
351
|
+
const cy = $$.updateCircleY(true);
|
|
352
|
+
$$.updateCircle(true);
|
|
353
|
+
$$.redrawCircle(cx, cy, withTransition, void 0, true);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
if (!state.rendered && initRange) {
|
|
357
|
+
state.domain = initRange;
|
|
358
|
+
$$.brush.move($$.brush.getSelection(), initRange.map($$.scale.x));
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
/**
|
|
364
|
+
* Show a focus grid line on subchart following main chart focus.
|
|
365
|
+
* @param {Array} data Selected data
|
|
366
|
+
* @private
|
|
367
|
+
*/
|
|
368
|
+
showSubchartGridFocus(data) {
|
|
369
|
+
const $$ = this;
|
|
370
|
+
const { config, state, $el: { subchart: { main } } } = $$;
|
|
371
|
+
if (!main || !config.subchart_show || $$.isSubchartBrushEnabled() || config.grid_focus_show === false || config.subchart_grid_focus === false || !config.tooltip_show || config.axis_tooltip) return;
|
|
372
|
+
const focus = (Array.isArray(data) ? data : [data]).find((d) => d && $$.getBaseValue(d) != null);
|
|
373
|
+
if (!focus) {
|
|
374
|
+
$$.hideSubchartGridFocus();
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const pos = $$.scale.subX(focus.x);
|
|
378
|
+
if (!Number.isFinite(pos)) {
|
|
379
|
+
$$.hideSubchartGridFocus();
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const line = main.select(`g.${classes_default.xgridFocus} line.${classes_default.xgridFocus}`);
|
|
383
|
+
if (showContinuousSubchartGridFocus($$)) {
|
|
384
|
+
line.style("visibility", "hidden");
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
syncSubchartGridFocusStyle($$, line);
|
|
388
|
+
config.axis_rotated ? line.attr("x1", 0).attr("x2", state.width2).attr("y1", pos).attr("y2", pos) : line.attr("x1", pos).attr("x2", pos).attr("y1", 0).attr("y2", state.height2);
|
|
389
|
+
line.style("visibility", null);
|
|
390
|
+
},
|
|
391
|
+
/**
|
|
392
|
+
* Hide subchart focus grid line.
|
|
393
|
+
* @private
|
|
394
|
+
*/
|
|
395
|
+
hideSubchartGridFocus() {
|
|
396
|
+
hideContinuousSubchartGridFocus(this);
|
|
397
|
+
this.$el.subchart.main?.select(`g.${classes_default.xgridFocus} line.${classes_default.xgridFocus}`).style("visibility", "hidden");
|
|
398
|
+
},
|
|
399
|
+
/**
|
|
400
|
+
* Redraw the brush.
|
|
401
|
+
* @param {boolean} [callCallbck=true] Call 'onbrush' callback or not.
|
|
402
|
+
* @private
|
|
403
|
+
*/
|
|
404
|
+
redrawForBrush(callCallbck = true) {
|
|
405
|
+
const $$ = this;
|
|
406
|
+
const { config: { subchart_onbrush: onBrush, zoom_rescale: withY }, scale, state } = $$;
|
|
407
|
+
$$.redraw({
|
|
408
|
+
withTransition: false,
|
|
409
|
+
withY,
|
|
410
|
+
withSubchart: false,
|
|
411
|
+
withUpdateXDomain: true,
|
|
412
|
+
withDimension: false
|
|
413
|
+
});
|
|
414
|
+
callCallbck && state.rendered && onBrush.bind($$.api)(state.domain ?? scale.x.orgDomain());
|
|
415
|
+
},
|
|
416
|
+
/**
|
|
417
|
+
* Transform context
|
|
418
|
+
* @param {boolean} withTransition indicates transition is enabled
|
|
419
|
+
* @param {object} transitions The return value of the generateTransitions method of Axis.
|
|
420
|
+
* @private
|
|
421
|
+
*/
|
|
422
|
+
transformContext(withTransition, transitions) {
|
|
423
|
+
const $$ = this;
|
|
424
|
+
const { $el: { subchart }, $T } = $$;
|
|
425
|
+
const subXAxis = transitions?.axisSubX ? transitions.axisSubX : $T(subchart.main.select(`.${classes_default.axisX}`), withTransition);
|
|
426
|
+
const subYAxis = transitions?.axisSubY ? transitions.axisSubY : $T(subchart.main.select(`.${classes_default.axisY}`), withTransition);
|
|
427
|
+
const subY2Axis = transitions?.axisSubY2 ? transitions.axisSubY2 : $T(subchart.main.select(`.${classes_default.axisY2}`), withTransition);
|
|
428
|
+
subchart.main.attr("transform", $$.getTranslate("context"));
|
|
429
|
+
subXAxis.attr("transform", $$.getTranslate("subX"));
|
|
430
|
+
subYAxis.attr("transform", $$.getTranslate("subY"));
|
|
431
|
+
subY2Axis.attr("transform", $$.getTranslate("subY2"));
|
|
432
|
+
}
|
|
308
433
|
};
|
|
309
|
-
|
|
310
|
-
export {
|
|
434
|
+
//#endregion
|
|
435
|
+
export { subchart_default as default };
|