billboard.js 4.0.2 → 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 +1938 -557
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +19 -25
- package/dist/billboard.pkgd.js +1934 -742
- package/dist/billboard.pkgd.min.js +24 -30
- 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 -147
- 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 +970 -1147
- 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 +286 -245
- 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 -272
- 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 -413
- 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 -828
- 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/focus.ts +8 -12
- 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 +19 -6
- package/src/ChartInternal/interactions/eventrect.ts +6 -0
- package/src/ChartInternal/interactions/subchart.ts +437 -66
- package/src/ChartInternal/internals/color.ts +7 -6
- 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 +19 -6
- package/src/ChartInternal/internals/transform.ts +8 -2
- package/src/ChartInternal/internals/type.ts +131 -33
- package/src/ChartInternal/shape/IShape.ts +6 -3
- package/src/ChartInternal/shape/bar.ts +87 -37
- 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/line.ts +1 -1
- package/src/ChartInternal/shape/point.ts +27 -13
- package/src/ChartInternal/shape/shape.ts +172 -18
- 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,626 +5,460 @@
|
|
|
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 { getPointer, getScrollPosition
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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
|
-
* Create eventRect for each data on the x-axis.
|
|
463
|
-
* Register touch and drag events.
|
|
464
|
-
* @param {object} eventRectEnter d3.select($EVENT.eventRects) object.
|
|
465
|
-
* @returns {object} d3.select($EVENT.eventRects) object.
|
|
466
|
-
* @private
|
|
467
|
-
*/
|
|
468
|
-
generateEventRectsForSingleX(eventRectEnter) {
|
|
469
|
-
const $$ = this;
|
|
470
|
-
const { config, state } = $$;
|
|
471
|
-
const { eventReceiver } = state;
|
|
472
|
-
const rect = eventRectEnter
|
|
473
|
-
.style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null)
|
|
474
|
-
.on("click", function (event) {
|
|
475
|
-
state.event = event;
|
|
476
|
-
const { currentIdx, data } = eventReceiver;
|
|
477
|
-
const d = data[currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx];
|
|
478
|
-
$$.clickHandlerForSingleX.bind(this)(d, $$);
|
|
479
|
-
})
|
|
480
|
-
.datum({ multipleX: false });
|
|
481
|
-
if (state.inputType === "mouse") {
|
|
482
|
-
const getData = event => {
|
|
483
|
-
const index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
|
|
484
|
-
return index > -1 ? eventReceiver.data[index] : null;
|
|
485
|
-
};
|
|
486
|
-
rect
|
|
487
|
-
.on("mouseover", event => {
|
|
488
|
-
state.event = event;
|
|
489
|
-
$$.updateEventRect();
|
|
490
|
-
Object.values($$.$el.axisTooltip)
|
|
491
|
-
.forEach((v) => v?.style("display", null));
|
|
492
|
-
})
|
|
493
|
-
.on("mousemove", function (event) {
|
|
494
|
-
const d = getData(event);
|
|
495
|
-
state.event = event;
|
|
496
|
-
if (!d) {
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
let { index } = d;
|
|
500
|
-
const stepType = config.line_step_type;
|
|
501
|
-
// tooltip position match for step-before & step-after
|
|
502
|
-
if (config.line_step_tooltipMatch && $$.hasType("step") &&
|
|
503
|
-
/^step\-(before|after)$/.test(stepType)) {
|
|
504
|
-
const scale = $$.scale.zoom || $$.scale.x;
|
|
505
|
-
const xs = $$.axis.xs[index];
|
|
506
|
-
const inverted = scale.invert(getPointer(event, this)[0]);
|
|
507
|
-
if (stepType === "step-after" && inverted < xs) {
|
|
508
|
-
index -= 1;
|
|
509
|
-
}
|
|
510
|
-
else if (stepType === "step-before" && inverted > xs) {
|
|
511
|
-
index += 1;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
$$.showAxisGridFocus();
|
|
515
|
-
const eventOnSameIdx = config.tooltip_grouped &&
|
|
516
|
-
index === eventReceiver.currentIdx;
|
|
517
|
-
// do nothing while dragging/flowing
|
|
518
|
-
if (state.dragging || state.flowing || $$.hasArcType() || eventOnSameIdx) {
|
|
519
|
-
// Throttle tooltip position updates: skip if mouse hasn't moved enough
|
|
520
|
-
if (config.tooltip_show && eventOnSameIdx) {
|
|
521
|
-
const [mx, my] = getPointer(event, this);
|
|
522
|
-
const last = state._lastTooltipMouse;
|
|
523
|
-
if (!last ||
|
|
524
|
-
(mx - last[0]) ** 2 + (my - last[1]) ** 2 >= 9) {
|
|
525
|
-
state._lastTooltipMouse = [mx, my];
|
|
526
|
-
$$.setTooltipPosition();
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
if (index !== eventReceiver.currentIdx) {
|
|
532
|
-
$$.setOverOut(false, eventReceiver.currentIdx);
|
|
533
|
-
eventReceiver.currentIdx = index;
|
|
534
|
-
}
|
|
535
|
-
index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, index);
|
|
536
|
-
// As of individual data point(or <path>) element can't bind mouseover/out event
|
|
537
|
-
// to determine current interacting element, so use 'mousemove' event instead.
|
|
538
|
-
$$.setOverOut(index !== -1, index);
|
|
539
|
-
})
|
|
540
|
-
.on("mouseout", event => {
|
|
541
|
-
state.event = event;
|
|
542
|
-
// chart is destroyed ($$.config, not the closure-captured one, becomes null)
|
|
543
|
-
if (!$$.config || $$.hasArcType() || eventReceiver.currentIdx === -1 ||
|
|
544
|
-
!config.interaction_onout) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
$$.hideAxisGridFocus();
|
|
548
|
-
$$.unselectRect();
|
|
549
|
-
$$.setOverOut(false, eventReceiver.currentIdx);
|
|
550
|
-
// reset the event current index
|
|
551
|
-
eventReceiver.currentIdx = -1;
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
return rect;
|
|
555
|
-
},
|
|
556
|
-
clickHandlerForSingleX(d, ctx) {
|
|
557
|
-
const $$ = ctx;
|
|
558
|
-
const { config, state, $el: { main } } = $$;
|
|
559
|
-
if (!d || $$.hasArcType() || state.cancelClick) {
|
|
560
|
-
state.cancelClick && (state.cancelClick = false);
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
const { index } = d;
|
|
564
|
-
main.selectAll(`.${$SHAPE.shape}-${index}`)
|
|
565
|
-
.each(function (d2) {
|
|
566
|
-
if (config.data_selection_grouped || $$.isWithinShape(this, d2)) {
|
|
567
|
-
$$.toggleShape?.(this, d2, index);
|
|
568
|
-
config.data_onclick.bind($$.api)(d2, this);
|
|
569
|
-
}
|
|
570
|
-
});
|
|
571
|
-
},
|
|
572
|
-
/**
|
|
573
|
-
* Create an eventRect,
|
|
574
|
-
* Register touch and drag events.
|
|
575
|
-
* @param {object} eventRectEnter d3.select($EVENT.eventRects) object.
|
|
576
|
-
* @private
|
|
577
|
-
*/
|
|
578
|
-
generateEventRectsForMultipleXs(eventRectEnter) {
|
|
579
|
-
const $$ = this;
|
|
580
|
-
const { config, state } = $$;
|
|
581
|
-
eventRectEnter
|
|
582
|
-
.on("click", function (event) {
|
|
583
|
-
state.event = event;
|
|
584
|
-
$$.clickHandlerForMultipleXS.bind(this)($$);
|
|
585
|
-
})
|
|
586
|
-
.datum({ multipleX: true });
|
|
587
|
-
if (state.inputType === "mouse") {
|
|
588
|
-
eventRectEnter
|
|
589
|
-
.on("mouseover mousemove", function (event) {
|
|
590
|
-
state.event = event;
|
|
591
|
-
$$.selectRectForMultipleXs(this);
|
|
592
|
-
})
|
|
593
|
-
.on("mouseout", event => {
|
|
594
|
-
state.event = event;
|
|
595
|
-
// chart is destroyed
|
|
596
|
-
if (!$$.config || $$.hasArcType() || !config.interaction_onout) {
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
$$.unselectRect();
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
},
|
|
603
|
-
clickHandlerForMultipleXS(ctx) {
|
|
604
|
-
const $$ = ctx;
|
|
605
|
-
const { config, state } = $$;
|
|
606
|
-
const targetsToShow = $$.getTargetsToShow();
|
|
607
|
-
if ($$.hasArcType(targetsToShow)) {
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
const mouse = getPointer(state.event, this);
|
|
611
|
-
const closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
|
612
|
-
if (!closest) {
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
const sensitivity = $$.getPointSensitivity(closest);
|
|
616
|
-
// select if selection enabled
|
|
617
|
-
if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < sensitivity) {
|
|
618
|
-
$$.$el.main.selectAll(`.${$SHAPE.shapes}${$$.getTargetSelectorSuffix(closest.id)}`)
|
|
619
|
-
.selectAll(`.${$SHAPE.shape}-${closest.index}`)
|
|
620
|
-
.each(function () {
|
|
621
|
-
if (config.data_selection_grouped || $$.isWithinShape(this, closest)) {
|
|
622
|
-
$$.toggleShape?.(this, closest, closest.index);
|
|
623
|
-
config.data_onclick.bind($$.api)(closest, this);
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
}
|
|
10
|
+
import { isBoolean, isFunction } from "../../module/util/type-checks.js";
|
|
11
|
+
import { getBoundingRect, getPointer, getScrollPosition } from "../../module/util/dom.js";
|
|
12
|
+
import { $COMMON, $EVENT, $SHAPE } from "../../config/classes.js";
|
|
13
|
+
//#region src/ChartInternal/interactions/eventrect.ts
|
|
14
|
+
var eventrect_default = {
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the area that detects the event.
|
|
17
|
+
* Add a container for the zone that detects the event.
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
initEventRect() {
|
|
21
|
+
this.$el.main.select(`.${$COMMON.chart}`).append("g").attr("class", $EVENT.eventRects).style("fill-opacity", "0");
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Redraws the area that detects the event.
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
redrawEventRect() {
|
|
28
|
+
const $$ = this;
|
|
29
|
+
const { config, state, $el } = $$;
|
|
30
|
+
const isMultipleX = $$.isMultipleX();
|
|
31
|
+
const isInverted = config.axis_x_inverted;
|
|
32
|
+
if ($el.eventRect) $$.updateEventRect($el.eventRect, true);
|
|
33
|
+
else if ($$.data.targets.length) {
|
|
34
|
+
const eventRectUpdate = $$.$el.main.select(`.${$EVENT.eventRects}`).style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ? config.axis_rotated ? "ns-resize" : "ew-resize" : null).classed($EVENT.eventRectsMultiple, isMultipleX).classed($EVENT.eventRectsSingle, !isMultipleX).selectAll(`.${$EVENT.eventRect}`).data([0]).enter().append("rect");
|
|
35
|
+
$$.updateEventRect(eventRectUpdate);
|
|
36
|
+
$$.updateEventType(eventRectUpdate);
|
|
37
|
+
eventRectUpdate.call($$.getDraggableSelection());
|
|
38
|
+
$el.eventRect = eventRectUpdate;
|
|
39
|
+
if ($$.state.inputType === "touch" && !$el.svg.on("touchstart.eventRect") && !$$.hasArcType()) $$.bindTouchOnEventRect();
|
|
40
|
+
state.rendered && $$.updateEventRect($el.eventRect, true);
|
|
41
|
+
}
|
|
42
|
+
if (!isMultipleX) {
|
|
43
|
+
const xAxisTickValues = $$.getMaxDataCountTarget();
|
|
44
|
+
if (!config.data_xSort || isInverted) xAxisTickValues.sort((a, b) => isInverted ? b.x - a.x : a.x - b.x);
|
|
45
|
+
$$.updateDataIndexByX(xAxisTickValues);
|
|
46
|
+
$$.updateXs(xAxisTickValues);
|
|
47
|
+
$$.updatePointClass?.(true);
|
|
48
|
+
state.eventReceiver.data = xAxisTickValues;
|
|
49
|
+
}
|
|
50
|
+
$$.updateEventRectData();
|
|
51
|
+
},
|
|
52
|
+
bindTouchOnEventRect() {
|
|
53
|
+
const $$ = this;
|
|
54
|
+
const { config, state, $el: { eventRect, svg } } = $$;
|
|
55
|
+
const selectRect = (context) => {
|
|
56
|
+
if ($$.isMultipleX()) $$.selectRectForMultipleXs(context);
|
|
57
|
+
else {
|
|
58
|
+
const index = $$.getDataIndexFromEvent(state.event);
|
|
59
|
+
$$.callOverOutForTouch(index);
|
|
60
|
+
index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, index);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const unselectRect = () => {
|
|
64
|
+
$$.unselectRect();
|
|
65
|
+
$$.callOverOutForTouch();
|
|
66
|
+
};
|
|
67
|
+
const preventDefault = config.interaction_inputType_touch.preventDefault;
|
|
68
|
+
const isPrevented = isBoolean(preventDefault) && preventDefault || false;
|
|
69
|
+
const preventThreshold = !isNaN(preventDefault) && preventDefault || null;
|
|
70
|
+
let startPx;
|
|
71
|
+
const passiveOption = !isPrevented && preventThreshold === null;
|
|
72
|
+
const preventEvent = (event) => {
|
|
73
|
+
const eventType = event.type;
|
|
74
|
+
const currentXY = event.changedTouches[0][`client${config.axis_rotated ? "Y" : "X"}`];
|
|
75
|
+
if (eventType === "touchstart") {
|
|
76
|
+
if (isPrevented) event.preventDefault();
|
|
77
|
+
else if (preventThreshold !== null) startPx = currentXY;
|
|
78
|
+
} else if (eventType === "touchmove") {
|
|
79
|
+
if (isPrevented || startPx === true || preventThreshold !== null && Math.abs(startPx - currentXY) >= preventThreshold) {
|
|
80
|
+
startPx = true;
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
eventRect.on("touchstart", (event) => {
|
|
86
|
+
state.event = event;
|
|
87
|
+
$$.updateEventRect();
|
|
88
|
+
}, { passive: passiveOption }).on("touchstart.eventRect touchmove.eventRect", (event) => {
|
|
89
|
+
state.event = event;
|
|
90
|
+
if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
|
|
91
|
+
if (state.dragging || state.flowing || $$.hasArcType() || event.touches.length > 1) return;
|
|
92
|
+
preventEvent(event);
|
|
93
|
+
selectRect(eventRect.node());
|
|
94
|
+
} else unselectRect();
|
|
95
|
+
}, { passive: passiveOption }).on("touchend.eventRect", (event) => {
|
|
96
|
+
state.event = event;
|
|
97
|
+
if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
|
|
98
|
+
if ($$.hasArcType() || !$$.toggleShape || state.cancelClick) state.cancelClick && (state.cancelClick = false);
|
|
99
|
+
}
|
|
100
|
+
}, { passive: passiveOption });
|
|
101
|
+
svg.on("touchstart", (event) => {
|
|
102
|
+
state.event = event;
|
|
103
|
+
const { target } = event;
|
|
104
|
+
if (target && target !== eventRect.node()) unselectRect();
|
|
105
|
+
}, { passive: passiveOption });
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* Update event rect size
|
|
109
|
+
* @param {d3Selection} eventRect Event <rect> element
|
|
110
|
+
* @param {boolean} force Force to update
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
updateEventRect(eventRect, force = false) {
|
|
114
|
+
const { state, $el } = this;
|
|
115
|
+
const { eventReceiver, width, height, rendered, resizing } = state;
|
|
116
|
+
const rectElement = eventRect || $el.eventRect;
|
|
117
|
+
const updateClientRect = () => {
|
|
118
|
+
if (eventReceiver) {
|
|
119
|
+
const scrollPos = getScrollPosition($el.chart.node());
|
|
120
|
+
eventReceiver.rect = getBoundingRect(rectElement.node(), true).toJSON();
|
|
121
|
+
eventReceiver.rect.top += scrollPos.y;
|
|
122
|
+
eventReceiver.rect.left += scrollPos.x;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
if (!rendered || resizing || force) {
|
|
126
|
+
rectElement.attr("x", 0).attr("y", 0).attr("width", width).attr("height", height);
|
|
127
|
+
if (!rendered || force) rectElement.classed($EVENT.eventRect, true);
|
|
128
|
+
}
|
|
129
|
+
updateClientRect();
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Update event type (single or multiple x)
|
|
133
|
+
* @param {d3Selection | boolean} target Target element or boolean to rebind event
|
|
134
|
+
*/
|
|
135
|
+
updateEventType(target) {
|
|
136
|
+
const $$ = this;
|
|
137
|
+
const isRebindCall = isBoolean(target);
|
|
138
|
+
const eventRect = isRebindCall ? $$.$el.eventRect : target;
|
|
139
|
+
const unbindEvent = isRebindCall ? target !== eventRect?.datum().multipleX : false;
|
|
140
|
+
if (eventRect) {
|
|
141
|
+
unbindEvent && eventRect?.on("mouseover mousemove mouseout click", null);
|
|
142
|
+
$$.isMultipleX() ? $$.generateEventRectsForMultipleXs(eventRect) : $$.generateEventRectsForSingleX(eventRect);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* Updates the location and size of the eventRect.
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
updateEventRectData() {
|
|
150
|
+
const $$ = this;
|
|
151
|
+
const { config, scale, state } = $$;
|
|
152
|
+
const xScale = scale.zoom || scale.x;
|
|
153
|
+
const isRotated = config.axis_rotated;
|
|
154
|
+
const isMultipleX = $$.isMultipleX();
|
|
155
|
+
const xDomain = xScale?.domain();
|
|
156
|
+
const fingerprint = xDomain ? `${xDomain[0]}_${xDomain[1]}_${state.width}_${state.height}_${$$.data.targets.length}_${state.dataGeneration}_${[...state.hiddenTargetIds].join(",")}` : null;
|
|
157
|
+
if (fingerprint && fingerprint === state._eventRectFingerprint) return;
|
|
158
|
+
state._eventRectFingerprint = fingerprint;
|
|
159
|
+
let x;
|
|
160
|
+
let y;
|
|
161
|
+
let w;
|
|
162
|
+
let h;
|
|
163
|
+
$$.updateEventType(isMultipleX);
|
|
164
|
+
if (isMultipleX) {
|
|
165
|
+
x = 0;
|
|
166
|
+
y = 0;
|
|
167
|
+
w = state.width;
|
|
168
|
+
h = state.height;
|
|
169
|
+
} else {
|
|
170
|
+
let rectW;
|
|
171
|
+
let rectX;
|
|
172
|
+
if ($$.axis.isCategorized()) {
|
|
173
|
+
rectW = $$.getEventRectWidth();
|
|
174
|
+
rectX = (d) => xScale(d.x) - rectW / 2;
|
|
175
|
+
} else {
|
|
176
|
+
const getPrevNextX = ({ index }) => ({
|
|
177
|
+
prev: $$.getPrevX(index),
|
|
178
|
+
next: $$.getNextX(index)
|
|
179
|
+
});
|
|
180
|
+
rectW = (d) => {
|
|
181
|
+
const x = getPrevNextX(d);
|
|
182
|
+
const xDomain = xScale.domain();
|
|
183
|
+
let val;
|
|
184
|
+
if (x.prev === null && x.next === null) val = isRotated ? state.height : state.width;
|
|
185
|
+
else if (x.prev === null) val = (xScale(x.next) + xScale(d.x)) / 2;
|
|
186
|
+
else if (x.next === null) val = xScale(xDomain[1]) - (xScale(x.prev) + xScale(d.x)) / 2;
|
|
187
|
+
else val = Math.max(0, (xScale(x.next) - xScale(x.prev)) / 2);
|
|
188
|
+
return val;
|
|
189
|
+
};
|
|
190
|
+
rectX = (d) => {
|
|
191
|
+
const x = getPrevNextX(d);
|
|
192
|
+
let val;
|
|
193
|
+
if (x.prev === null && x.next === null) val = 0;
|
|
194
|
+
else if (x.prev === null) val = xScale(xScale.domain()[0]);
|
|
195
|
+
else val = (xScale(d.x) + xScale(x.prev)) / 2;
|
|
196
|
+
return val;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
x = isRotated ? 0 : rectX;
|
|
200
|
+
y = isRotated ? rectX : 0;
|
|
201
|
+
w = isRotated ? state.width : rectW;
|
|
202
|
+
h = isRotated ? rectW : state.height;
|
|
203
|
+
}
|
|
204
|
+
const { eventReceiver } = state;
|
|
205
|
+
const call = (fn, v) => isFunction(fn) ? fn(v) : fn;
|
|
206
|
+
eventReceiver.coords.splice(eventReceiver.data.length);
|
|
207
|
+
eventReceiver.data.forEach((d, i) => {
|
|
208
|
+
eventReceiver.coords[i] = {
|
|
209
|
+
x: call(x, d),
|
|
210
|
+
y: call(y, d),
|
|
211
|
+
w: call(w, d),
|
|
212
|
+
h: call(h, d)
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
/**
|
|
217
|
+
* Seletct rect for single x value
|
|
218
|
+
* @param {d3Selection} context Event rect element
|
|
219
|
+
* @param {number} index x Axis index
|
|
220
|
+
* @private
|
|
221
|
+
*/
|
|
222
|
+
selectRectForSingle(context, index) {
|
|
223
|
+
const $$ = this;
|
|
224
|
+
const { config, state, $el: { main, circle } } = $$;
|
|
225
|
+
const isSelectionEnabled = config.data_selection_enabled;
|
|
226
|
+
const isSelectionGrouped = config.data_selection_grouped;
|
|
227
|
+
const isSelectable = config.data_selection_isselectable;
|
|
228
|
+
const isTooltipGrouped = config.tooltip_grouped;
|
|
229
|
+
const selectedData = $$.getAllValuesOnIndex(index);
|
|
230
|
+
if (isTooltipGrouped) {
|
|
231
|
+
$$.showTooltip(selectedData, context);
|
|
232
|
+
$$.showGridFocus?.(selectedData);
|
|
233
|
+
$$.showSubchartGridFocus?.(selectedData);
|
|
234
|
+
if (!isSelectionEnabled || isSelectionGrouped) return;
|
|
235
|
+
}
|
|
236
|
+
!circle && main.selectAll(`.${$COMMON.EXPANDED}:not(.${$SHAPE.shape}-${index})`).classed($COMMON.EXPANDED, false);
|
|
237
|
+
const shapeAtIndex = main.selectAll(`.${$SHAPE.shape}-${index}`).classed($COMMON.EXPANDED, true).style("cursor", isSelectable ? "pointer" : null).filter(function(d) {
|
|
238
|
+
return $$.isWithinShape(this, d);
|
|
239
|
+
});
|
|
240
|
+
shapeAtIndex.call((selected) => {
|
|
241
|
+
const d = selected.data();
|
|
242
|
+
if (isSelectionEnabled && (isSelectionGrouped || isSelectable?.bind($$.api)(d))) context.style.cursor = "pointer";
|
|
243
|
+
if (!isTooltipGrouped) {
|
|
244
|
+
$$.showTooltip(d, context);
|
|
245
|
+
$$.showGridFocus?.(d);
|
|
246
|
+
$$.showSubchartGridFocus?.(d);
|
|
247
|
+
$$.unexpandCircles?.();
|
|
248
|
+
selected.each((d) => $$.setExpand(index, d.id));
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
if (!isTooltipGrouped && shapeAtIndex.empty()) {
|
|
252
|
+
const mouse = getPointer(state.event, context);
|
|
253
|
+
const closestData = selectedData.filter((d) => {
|
|
254
|
+
if ($$.isTargetToShow(d.id)) return $$.dist(d, mouse) < $$.getPointSensitivity(d);
|
|
255
|
+
return false;
|
|
256
|
+
});
|
|
257
|
+
if (closestData.length > 0) {
|
|
258
|
+
let closest = closestData[0];
|
|
259
|
+
let minDist = $$.dist(closest, mouse);
|
|
260
|
+
for (let i = 1; i < closestData.length; i++) {
|
|
261
|
+
const d = closestData[i];
|
|
262
|
+
const dist = $$.dist(d, mouse);
|
|
263
|
+
if (dist < minDist) {
|
|
264
|
+
minDist = dist;
|
|
265
|
+
closest = d;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
$$.showTooltip([closest], context);
|
|
269
|
+
$$.showGridFocus?.([closest]);
|
|
270
|
+
$$.showSubchartGridFocus?.([closest]);
|
|
271
|
+
$$.unexpandCircles?.();
|
|
272
|
+
$$.setExpand(index, closest.id, true);
|
|
273
|
+
if (isSelectionEnabled && (isSelectionGrouped || isSelectable?.bind($$.api)(closest))) context.style.cursor = "pointer";
|
|
274
|
+
} else if (config.interaction_onout) {
|
|
275
|
+
$$.hideGridFocus?.();
|
|
276
|
+
$$.hideSubchartGridFocus?.();
|
|
277
|
+
$$.hideTooltip();
|
|
278
|
+
!isSelectionGrouped && $$.setExpand(index);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
/**
|
|
283
|
+
* Select rect for multiple x values
|
|
284
|
+
* @param {d3Selection} context Event rect element
|
|
285
|
+
* @param {boolean} [triggerEvent=true] Whether trigger event or not
|
|
286
|
+
* @private
|
|
287
|
+
*/
|
|
288
|
+
selectRectForMultipleXs(context, triggerEvent = true) {
|
|
289
|
+
const $$ = this;
|
|
290
|
+
const { config, state } = $$;
|
|
291
|
+
const targetsToShow = $$.getTargetsToShow();
|
|
292
|
+
if (state.dragging || $$.hasArcType(targetsToShow)) return;
|
|
293
|
+
const mouse = getPointer(state.event, context);
|
|
294
|
+
const closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
|
295
|
+
if (triggerEvent && state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
|
|
296
|
+
config.data_onout.call($$.api, state.mouseover);
|
|
297
|
+
state.mouseover = void 0;
|
|
298
|
+
}
|
|
299
|
+
if (!closest) {
|
|
300
|
+
$$.unselectRect();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const selectedData = ($$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x)).map((d) => $$.addName(d));
|
|
304
|
+
$$.showTooltip(selectedData, context);
|
|
305
|
+
$$.setExpand(closest.index, closest.id, true);
|
|
306
|
+
$$.showGridFocus?.(selectedData);
|
|
307
|
+
$$.showSubchartGridFocus?.(selectedData);
|
|
308
|
+
const dist = $$.dist(closest, mouse);
|
|
309
|
+
if ($$.isBarType(closest.id) || dist < $$.getPointSensitivity(closest)) {
|
|
310
|
+
$$.$el.eventRect.style("cursor", "pointer");
|
|
311
|
+
if (triggerEvent && (!state.mouseover || state.mouseover.x !== closest.x || state.mouseover.id !== closest.id)) {
|
|
312
|
+
config.data_onover.call($$.api, closest);
|
|
313
|
+
state.mouseover = closest;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
/**
|
|
318
|
+
* Unselect EventRect.
|
|
319
|
+
* @private
|
|
320
|
+
*/
|
|
321
|
+
unselectRect() {
|
|
322
|
+
const $$ = this;
|
|
323
|
+
const { state, $el: { circle, tooltip } } = $$;
|
|
324
|
+
state._lastTooltipMouse = null;
|
|
325
|
+
if (state.isCanvasMode) {
|
|
326
|
+
$$.clearCanvasFocus?.();
|
|
327
|
+
tooltip && $$.hideTooltip();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
$$.$el.eventRect?.style("cursor", null);
|
|
331
|
+
$$.hideGridFocus?.();
|
|
332
|
+
$$.hideSubchartGridFocus?.();
|
|
333
|
+
if (tooltip) {
|
|
334
|
+
$$.hideTooltip();
|
|
335
|
+
$$._handleLinkedCharts(false);
|
|
336
|
+
}
|
|
337
|
+
circle && !$$.isPointFocusOnly() && $$.unexpandCircles();
|
|
338
|
+
$$.expandBarTypeShapes(false);
|
|
339
|
+
},
|
|
340
|
+
/**
|
|
341
|
+
* Create eventRect for each data on the x-axis.
|
|
342
|
+
* Register touch and drag events.
|
|
343
|
+
* @param {object} eventRectEnter d3.select($EVENT.eventRects) object.
|
|
344
|
+
* @returns {object} d3.select($EVENT.eventRects) object.
|
|
345
|
+
* @private
|
|
346
|
+
*/
|
|
347
|
+
generateEventRectsForSingleX(eventRectEnter) {
|
|
348
|
+
const $$ = this;
|
|
349
|
+
const { config, state } = $$;
|
|
350
|
+
const { eventReceiver } = state;
|
|
351
|
+
const rect = eventRectEnter.style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null).on("click", function(event) {
|
|
352
|
+
state.event = event;
|
|
353
|
+
const { currentIdx, data } = eventReceiver;
|
|
354
|
+
const d = data[currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx];
|
|
355
|
+
$$.clickHandlerForSingleX.bind(this)(d, $$);
|
|
356
|
+
}).datum({ multipleX: false });
|
|
357
|
+
if (state.inputType === "mouse") {
|
|
358
|
+
const getData = (event) => {
|
|
359
|
+
const index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
|
|
360
|
+
return index > -1 ? eventReceiver.data[index] : null;
|
|
361
|
+
};
|
|
362
|
+
rect.on("mouseover", (event) => {
|
|
363
|
+
state.event = event;
|
|
364
|
+
$$.updateEventRect();
|
|
365
|
+
Object.values($$.$el.axisTooltip).forEach((v) => v?.style("display", null));
|
|
366
|
+
}).on("mousemove", function(event) {
|
|
367
|
+
const d = getData(event);
|
|
368
|
+
state.event = event;
|
|
369
|
+
if (!d) return;
|
|
370
|
+
let { index } = d;
|
|
371
|
+
const stepType = config.line_step_type;
|
|
372
|
+
if (config.line_step_tooltipMatch && $$.hasType("step") && /^step\-(before|after)$/.test(stepType)) {
|
|
373
|
+
const scale = $$.scale.zoom || $$.scale.x;
|
|
374
|
+
const xs = $$.axis.xs[index];
|
|
375
|
+
const inverted = scale.invert(getPointer(event, this)[0]);
|
|
376
|
+
if (stepType === "step-after" && inverted < xs) index -= 1;
|
|
377
|
+
else if (stepType === "step-before" && inverted > xs) index += 1;
|
|
378
|
+
}
|
|
379
|
+
$$.showAxisGridFocus();
|
|
380
|
+
const eventOnSameIdx = config.tooltip_grouped && index === eventReceiver.currentIdx;
|
|
381
|
+
if (state.dragging || state.flowing || $$.hasArcType() || eventOnSameIdx) {
|
|
382
|
+
if (config.tooltip_show && eventOnSameIdx) {
|
|
383
|
+
const [mx, my] = getPointer(event, this);
|
|
384
|
+
const last = state._lastTooltipMouse;
|
|
385
|
+
if (!last || (mx - last[0]) ** 2 + (my - last[1]) ** 2 >= 9) {
|
|
386
|
+
state._lastTooltipMouse = [mx, my];
|
|
387
|
+
$$.setTooltipPosition();
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (index !== eventReceiver.currentIdx) {
|
|
393
|
+
$$.setOverOut(false, eventReceiver.currentIdx);
|
|
394
|
+
eventReceiver.currentIdx = index;
|
|
395
|
+
}
|
|
396
|
+
index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, index);
|
|
397
|
+
$$.setOverOut(index !== -1, index);
|
|
398
|
+
}).on("mouseout", (event) => {
|
|
399
|
+
state.event = event;
|
|
400
|
+
if (!$$.config || $$.hasArcType() || eventReceiver.currentIdx === -1 || !config.interaction_onout) return;
|
|
401
|
+
$$.hideAxisGridFocus();
|
|
402
|
+
$$.unselectRect();
|
|
403
|
+
$$.setOverOut(false, eventReceiver.currentIdx);
|
|
404
|
+
eventReceiver.currentIdx = -1;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return rect;
|
|
408
|
+
},
|
|
409
|
+
clickHandlerForSingleX(d, ctx) {
|
|
410
|
+
const $$ = ctx;
|
|
411
|
+
const { config, state, $el: { main } } = $$;
|
|
412
|
+
if (!d || $$.hasArcType() || state.cancelClick) {
|
|
413
|
+
state.cancelClick && (state.cancelClick = false);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const { index } = d;
|
|
417
|
+
main.selectAll(`.${$SHAPE.shape}-${index}`).each(function(d2) {
|
|
418
|
+
if (config.data_selection_grouped || $$.isWithinShape(this, d2)) {
|
|
419
|
+
$$.toggleShape?.(this, d2, index);
|
|
420
|
+
config.data_onclick.bind($$.api)(d2, this);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
},
|
|
424
|
+
/**
|
|
425
|
+
* Create an eventRect,
|
|
426
|
+
* Register touch and drag events.
|
|
427
|
+
* @param {object} eventRectEnter d3.select($EVENT.eventRects) object.
|
|
428
|
+
* @private
|
|
429
|
+
*/
|
|
430
|
+
generateEventRectsForMultipleXs(eventRectEnter) {
|
|
431
|
+
const $$ = this;
|
|
432
|
+
const { config, state } = $$;
|
|
433
|
+
eventRectEnter.on("click", function(event) {
|
|
434
|
+
state.event = event;
|
|
435
|
+
$$.clickHandlerForMultipleXS.bind(this)($$);
|
|
436
|
+
}).datum({ multipleX: true });
|
|
437
|
+
if (state.inputType === "mouse") eventRectEnter.on("mouseover mousemove", function(event) {
|
|
438
|
+
state.event = event;
|
|
439
|
+
$$.selectRectForMultipleXs(this);
|
|
440
|
+
}).on("mouseout", (event) => {
|
|
441
|
+
state.event = event;
|
|
442
|
+
if (!$$.config || $$.hasArcType() || !config.interaction_onout) return;
|
|
443
|
+
$$.unselectRect();
|
|
444
|
+
});
|
|
445
|
+
},
|
|
446
|
+
clickHandlerForMultipleXS(ctx) {
|
|
447
|
+
const $$ = ctx;
|
|
448
|
+
const { config, state } = $$;
|
|
449
|
+
const targetsToShow = $$.getTargetsToShow();
|
|
450
|
+
if ($$.hasArcType(targetsToShow)) return;
|
|
451
|
+
const mouse = getPointer(state.event, this);
|
|
452
|
+
const closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
|
453
|
+
if (!closest) return;
|
|
454
|
+
const sensitivity = $$.getPointSensitivity(closest);
|
|
455
|
+
if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < sensitivity) $$.$el.main.selectAll(`.${$SHAPE.shapes}${$$.getTargetSelectorSuffix(closest.id)}`).selectAll(`.${$SHAPE.shape}-${closest.index}`).each(function() {
|
|
456
|
+
if (config.data_selection_grouped || $$.isWithinShape(this, closest)) {
|
|
457
|
+
$$.toggleShape?.(this, closest, closest.index);
|
|
458
|
+
config.data_onclick.bind($$.api)(closest, this);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
628
462
|
};
|
|
629
|
-
|
|
630
|
-
export {
|
|
463
|
+
//#endregion
|
|
464
|
+
export { eventrect_default as default };
|