billboard.js 3.11.3 → 3.12.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 +1 -5
- package/dist/billboard.css +13 -1
- package/dist/billboard.js +19672 -24210
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +26 -3
- package/dist/billboard.pkgd.js +24515 -30430
- package/dist/billboard.pkgd.min.js +33 -3
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
- package/dist/plugin/billboardjs-plugin-sparkline.js +429 -1134
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +666 -1524
- package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
- package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
- package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
- package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1387 -1854
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2760 -3959
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3504 -5057
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2906 -4072
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3076 -4506
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
- package/dist/theme/dark.css +12 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +12 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +12 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +12 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +12 -1
- package/dist/theme/modern.min.css +3 -4
- package/dist-esm/billboard.js +9297 -8527
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +20 -27
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +155 -149
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +302 -289
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +236 -236
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +41 -43
- package/package.json +29 -49
- package/src/Chart/api/axis.ts +6 -13
- package/src/Chart/api/chart.ts +12 -11
- package/src/Chart/api/data.ts +8 -7
- package/src/Chart/api/export.ts +28 -21
- package/src/Chart/api/flow.ts +4 -2
- package/src/Chart/api/grid.ts +1 -5
- package/src/Chart/api/load.ts +2 -2
- package/src/Chart/api/regions.ts +29 -5
- package/src/Chart/api/selection.ts +2 -2
- package/src/Chart/api/show.ts +2 -3
- package/src/Chart/api/subchart.ts +2 -2
- package/src/Chart/api/tooltip.ts +8 -9
- package/src/Chart/api/x.ts +2 -2
- package/src/Chart/api/zoom.ts +2 -2
- package/src/ChartInternal/Axis/Axis.ts +119 -44
- package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
- package/src/ChartInternal/ChartInternal.ts +87 -55
- package/src/ChartInternal/data/IData.ts +31 -31
- package/src/ChartInternal/data/convert.helper.ts +66 -68
- package/src/ChartInternal/data/convert.ts +11 -11
- package/src/ChartInternal/data/data.ts +51 -27
- package/src/ChartInternal/data/load.ts +7 -6
- package/src/ChartInternal/interactions/drag.ts +2 -1
- package/src/ChartInternal/interactions/eventrect.ts +84 -32
- package/src/ChartInternal/interactions/flow.ts +14 -4
- package/src/ChartInternal/interactions/interaction.ts +51 -22
- package/src/ChartInternal/interactions/subchart.ts +27 -25
- package/src/ChartInternal/interactions/zoom.ts +29 -18
- package/src/ChartInternal/internals/category.ts +1 -1
- package/src/ChartInternal/internals/class.ts +6 -6
- package/src/ChartInternal/internals/clip.ts +8 -4
- package/src/ChartInternal/internals/color.ts +70 -42
- package/src/ChartInternal/internals/domain.ts +59 -28
- package/src/ChartInternal/internals/format.ts +5 -5
- package/src/ChartInternal/internals/grid.ts +131 -47
- package/src/ChartInternal/internals/legend.ts +93 -61
- package/src/ChartInternal/internals/redraw.ts +6 -2
- package/src/ChartInternal/internals/region.ts +5 -3
- package/src/ChartInternal/internals/scale.ts +28 -15
- package/src/ChartInternal/internals/selection.ts +14 -13
- package/src/ChartInternal/internals/size.axis.ts +18 -10
- package/src/ChartInternal/internals/size.ts +98 -67
- package/src/ChartInternal/internals/style.ts +21 -19
- package/src/ChartInternal/internals/text.ts +79 -43
- package/src/ChartInternal/internals/title.ts +2 -2
- package/src/ChartInternal/internals/tooltip.ts +78 -32
- package/src/ChartInternal/internals/transform.ts +4 -4
- package/src/ChartInternal/internals/type.ts +17 -12
- package/src/ChartInternal/shape/arc.ts +78 -44
- package/src/ChartInternal/shape/area.ts +19 -22
- package/src/ChartInternal/shape/bar.ts +41 -31
- package/src/ChartInternal/shape/bubble.ts +5 -5
- package/src/ChartInternal/shape/candlestick.ts +15 -13
- package/src/ChartInternal/shape/funnel.ts +317 -0
- package/src/ChartInternal/shape/gauge.ts +16 -9
- package/src/ChartInternal/shape/line.ts +62 -46
- package/src/ChartInternal/shape/point.common.ts +1 -4
- package/src/ChartInternal/shape/point.ts +54 -34
- package/src/ChartInternal/shape/polar.ts +4 -2
- package/src/ChartInternal/shape/radar.ts +40 -22
- package/src/ChartInternal/shape/shape.ts +84 -58
- package/src/ChartInternal/shape/treemap.ts +31 -20
- package/src/Plugin/bubblecompare/index.ts +1 -3
- package/src/Plugin/sparkline/index.ts +3 -4
- package/src/Plugin/stanford/ColorScale.ts +3 -2
- package/src/Plugin/stanford/Elements.ts +15 -6
- package/src/Plugin/stanford/Options.ts +5 -5
- package/src/Plugin/stanford/index.ts +13 -9
- package/src/Plugin/tableview/Options.ts +1 -1
- package/src/Plugin/tableview/const.ts +1 -4
- package/src/Plugin/tableview/index.ts +11 -9
- package/src/Plugin/textoverlap/index.ts +4 -6
- package/src/config/Options/Options.ts +3 -3
- package/src/config/Options/axis/axis.ts +36 -0
- package/src/config/Options/axis/x.ts +34 -14
- package/src/config/Options/axis/y.ts +13 -13
- package/src/config/Options/axis/y2.ts +23 -10
- package/src/config/Options/common/color.ts +4 -4
- package/src/config/Options/common/grid.ts +4 -4
- package/src/config/Options/common/legend.ts +12 -13
- package/src/config/Options/common/main.ts +23 -23
- package/src/config/Options/common/point.ts +17 -18
- package/src/config/Options/common/title.ts +2 -2
- package/src/config/Options/common/tooltip.ts +13 -11
- package/src/config/Options/data/axis.ts +2 -2
- package/src/config/Options/data/data.ts +48 -45
- package/src/config/Options/interaction/interaction.ts +1 -1
- package/src/config/Options/interaction/subchart.ts +2 -2
- package/src/config/Options/interaction/zoom.ts +9 -9
- package/src/config/Options/shape/arc.ts +10 -13
- package/src/config/Options/shape/area.ts +5 -7
- package/src/config/Options/shape/bar.ts +8 -10
- package/src/config/Options/shape/bubble.ts +1 -1
- package/src/config/Options/shape/candlestick.ts +2 -2
- package/src/config/Options/shape/donut.ts +4 -4
- package/src/config/Options/shape/funnel.ts +38 -0
- package/src/config/Options/shape/gauge.ts +6 -6
- package/src/config/Options/shape/line.ts +3 -3
- package/src/config/Options/shape/pie.ts +5 -5
- package/src/config/Options/shape/polar.ts +3 -3
- package/src/config/Options/shape/radar.ts +2 -2
- package/src/config/Options/shape/scatter.ts +1 -1
- package/src/config/Options/shape/treemap.ts +1 -1
- package/src/config/Store/Element.ts +8 -5
- package/src/config/Store/State.ts +20 -13
- package/src/config/classes.ts +14 -4
- package/src/config/config.ts +1 -1
- package/src/config/const.ts +2 -0
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/interaction.ts +3 -7
- package/src/config/resolver/shape.ts +17 -12
- package/src/core.ts +2 -3
- package/src/index.esm.ts +3 -6
- package/src/index.ts +2 -2
- package/src/module/Cache.ts +2 -3
- package/src/module/browser.ts +15 -10
- package/src/module/error.ts +9 -8
- package/src/module/generator.ts +3 -5
- package/src/module/util.ts +62 -39
- package/src/module/worker.ts +14 -11
- package/src/scss/billboard.scss +18 -0
- package/src/scss/theme/dark.scss +17 -0
- package/src/scss/theme/datalab.scss +17 -0
- package/src/scss/theme/graph.scss +17 -0
- package/src/scss/theme/insight.scss +17 -0
- package/src/scss/theme/modern.scss +17 -0
- package/types/axis.d.ts +17 -0
- package/types/bb.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/options.d.ts +9 -0
- package/types/options.shape.d.ts +26 -1
- package/types/types.d.ts +1 -0
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {select as d3Select} from "d3-selection";
|
|
6
5
|
import {drag as d3Drag} from "d3-drag";
|
|
7
|
-
import {
|
|
6
|
+
import {select as d3Select} from "d3-selection";
|
|
7
|
+
import {$ARC, $AXIS, $COMMON, $SHAPE} from "../../config/classes";
|
|
8
8
|
import {KEY} from "../../module/Cache";
|
|
9
9
|
import {emulateEvent, getPointer, isNumber, isObject} from "../../module/util";
|
|
10
10
|
import type {IArcDataRow} from "../data/IData";
|
|
@@ -55,19 +55,22 @@ export default {
|
|
|
55
55
|
*/
|
|
56
56
|
setOverOut(isOver: boolean, d: number | IArcDataRow): void {
|
|
57
57
|
const $$ = this;
|
|
58
|
-
const {config, state: {hasRadar, hasTreemap}, $el: {main}} = $$;
|
|
59
|
-
const
|
|
58
|
+
const {config, state: {hasFunnel, hasRadar, hasTreemap}, $el: {main}} = $$;
|
|
59
|
+
const isArcishData = isObject(d);
|
|
60
60
|
|
|
61
61
|
// Call event handler
|
|
62
|
-
if (
|
|
62
|
+
if (isArcishData || d !== -1) {
|
|
63
63
|
const callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
|
|
64
64
|
|
|
65
|
-
config.color_onover && $$.setOverColor(isOver, d,
|
|
65
|
+
config.color_onover && $$.setOverColor(isOver, d, isArcishData);
|
|
66
66
|
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
67
|
+
if (isArcishData && "id") {
|
|
68
|
+
const suffix = $$.getTargetSelectorSuffix((d as IArcDataRow).id);
|
|
69
|
+
const selector = hasFunnel || hasTreemap ?
|
|
70
|
+
`${$COMMON.target + suffix} .${$SHAPE.shape}` :
|
|
71
|
+
$ARC.arc + suffix;
|
|
69
72
|
|
|
70
|
-
callback(d, main.select(`.${selector}
|
|
73
|
+
callback(d, main.select(`.${selector}`).node());
|
|
71
74
|
} else if (!config.tooltip_grouped) {
|
|
72
75
|
const last = $$.cache.get(KEY.setOverOut) || [];
|
|
73
76
|
|
|
@@ -83,9 +86,11 @@ export default {
|
|
|
83
86
|
});
|
|
84
87
|
|
|
85
88
|
// call onout callback
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
if (
|
|
90
|
+
!isOver || shapesAtIndex.empty() || (
|
|
91
|
+
last.length === shape.size() && shape.nodes().every((v, i) => v !== last[i])
|
|
92
|
+
)
|
|
93
|
+
) {
|
|
89
94
|
while (last.length) {
|
|
90
95
|
const target = last.pop();
|
|
91
96
|
|
|
@@ -156,7 +161,8 @@ export default {
|
|
|
156
161
|
.on("end", event => {
|
|
157
162
|
state.event = event;
|
|
158
163
|
$$.dragend();
|
|
159
|
-
}) :
|
|
164
|
+
}) :
|
|
165
|
+
() => {};
|
|
160
166
|
},
|
|
161
167
|
|
|
162
168
|
/**
|
|
@@ -168,11 +174,19 @@ export default {
|
|
|
168
174
|
*/
|
|
169
175
|
dispatchEvent(type: string, index: number, mouse: [number, number]): void {
|
|
170
176
|
const $$ = this;
|
|
171
|
-
const {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
177
|
+
const {
|
|
178
|
+
config,
|
|
179
|
+
state: {
|
|
180
|
+
eventReceiver,
|
|
181
|
+
hasAxis,
|
|
182
|
+
hasFunnel,
|
|
183
|
+
hasRadar,
|
|
184
|
+
hasTreemap
|
|
185
|
+
},
|
|
186
|
+
$el: {eventRect, funnel, radar, treemap}
|
|
187
|
+
} = $$;
|
|
188
|
+
let element = (
|
|
189
|
+
((hasFunnel || hasTreemap) && eventReceiver.rect) ||
|
|
176
190
|
(hasRadar && radar.axes.select(`.${$AXIS.axis}-${index} text`)) || (
|
|
177
191
|
eventRect || $$.getArcElementByIdOrIndex?.(index)
|
|
178
192
|
)
|
|
@@ -211,9 +225,16 @@ export default {
|
|
|
211
225
|
bubbles: hasRadar // radar type needs to bubble up event
|
|
212
226
|
};
|
|
213
227
|
|
|
228
|
+
// for funnel and treemap event bound to <g> node
|
|
229
|
+
if (hasFunnel || hasTreemap) {
|
|
230
|
+
element = (funnel ?? treemap).node();
|
|
231
|
+
}
|
|
232
|
+
|
|
214
233
|
emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](
|
|
215
|
-
|
|
216
|
-
type,
|
|
234
|
+
element,
|
|
235
|
+
type,
|
|
236
|
+
params
|
|
237
|
+
);
|
|
217
238
|
}
|
|
218
239
|
},
|
|
219
240
|
|
|
@@ -239,7 +260,7 @@ export default {
|
|
|
239
260
|
* Unbind all attached events
|
|
240
261
|
* @private
|
|
241
262
|
*/
|
|
242
|
-
unbindAllEvents():
|
|
263
|
+
unbindAllEvents(): void {
|
|
243
264
|
const $$ = this;
|
|
244
265
|
const {$el: {arcs, eventRect, legend, region, svg, treemap}, brush} = $$;
|
|
245
266
|
const list = [
|
|
@@ -262,7 +283,15 @@ export default {
|
|
|
262
283
|
].join(" ");
|
|
263
284
|
|
|
264
285
|
// detach all possible event types
|
|
265
|
-
[
|
|
286
|
+
[
|
|
287
|
+
svg,
|
|
288
|
+
eventRect,
|
|
289
|
+
region?.list,
|
|
290
|
+
brush?.getSelection(),
|
|
291
|
+
arcs?.selectAll("path"),
|
|
292
|
+
legend?.selectAll("g"),
|
|
293
|
+
treemap
|
|
294
|
+
]
|
|
266
295
|
.forEach(v => v?.on(list, null));
|
|
267
296
|
|
|
268
297
|
$$.unbindZoomEvent?.();
|
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
+
import {brushSelection as d3BrushSelection, brushX as d3BrushX, brushY as d3BrushY} from "d3-brush";
|
|
5
6
|
import {select as d3Select} from "d3-selection";
|
|
6
|
-
import {
|
|
7
|
-
brushX as d3BrushX,
|
|
8
|
-
brushY as d3BrushY,
|
|
9
|
-
brushSelection as d3BrushSelection
|
|
10
|
-
} from "d3-brush";
|
|
11
7
|
import CLASS from "../../config/classes";
|
|
12
8
|
import {brushEmpty, capitalize, isArray, isFunction, parseDate} from "../../module/util";
|
|
13
9
|
|
|
@@ -44,11 +40,12 @@ export default {
|
|
|
44
40
|
if (/(start|brush)/.test(type)) {
|
|
45
41
|
// when brush selection updates happens on one edge, update only chainging edge and
|
|
46
42
|
// is only for adjustment of given domain range to be used to return current domain range.
|
|
47
|
-
type === "brush" && sourceEvent && state.domain &&
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
type === "brush" && sourceEvent && state.domain &&
|
|
44
|
+
lastSelection?.forEach((v, i) => {
|
|
45
|
+
if (v !== selection[i]) {
|
|
46
|
+
state.domain[i] = scale.x.orgDomain()[i];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
52
49
|
|
|
53
50
|
$$.redrawForBrush(type !== "start");
|
|
54
51
|
}
|
|
@@ -198,19 +195,18 @@ export default {
|
|
|
198
195
|
const customHandleClass = "handle--custom";
|
|
199
196
|
|
|
200
197
|
// brush handle shape's path
|
|
201
|
-
const path = isRotated ?
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
198
|
+
const path = isRotated ?
|
|
199
|
+
[
|
|
200
|
+
"M8.5 0 a6 6 0 0 0 -6 -6.5 H-2.5 a 6 6 0 0 0 -6 6.5 z m-5 -2 H-3.5 m7 -2 H-3.5z",
|
|
201
|
+
"M8.5 0 a6 -6 0 0 1 -6 6.5 H-2.5 a 6 -6 0 0 1 -6 -6.5z m-5 2 H-3.5 m7 2 H-3.5z"
|
|
202
|
+
] :
|
|
203
|
+
[
|
|
204
|
+
"M0 -8.5 A6 6 0 0 0 -6.5 -3.5 V2.5 A6 6 0 0 0 0 8.5 Z M-2 -3.5 V3.5 M-4 -3.5 V3.5z",
|
|
205
|
+
"M0 -8.5 A6 6 0 0 1 6.5 -3.5 V2.5 A6 6 0 0 1 0 8.5 Z M2 -3.5 V3.5 M4 -3.5 V3.5z"
|
|
206
|
+
];
|
|
208
207
|
|
|
209
208
|
$$.brush.handle = brush.selectAll(`.${customHandleClass}`)
|
|
210
|
-
.data(isRotated ?
|
|
211
|
-
[{type: "n"}, {type: "s"}] :
|
|
212
|
-
[{type: "w"}, {type: "e"}]
|
|
213
|
-
)
|
|
209
|
+
.data(isRotated ? [{type: "n"}, {type: "s"}] : [{type: "w"}, {type: "e"}])
|
|
214
210
|
.enter()
|
|
215
211
|
.append("path")
|
|
216
212
|
.attr("class", customHandleClass)
|
|
@@ -271,7 +267,8 @@ export default {
|
|
|
271
267
|
|
|
272
268
|
// -- Brush --//
|
|
273
269
|
main.selectAll(`.${CLASS.brush} rect`)
|
|
274
|
-
.attr(config.axis_rotated ? "width" : "height",
|
|
270
|
+
.attr(config.axis_rotated ? "width" : "height",
|
|
271
|
+
config.axis_rotated ? state.width2 : state.height2);
|
|
275
272
|
}
|
|
276
273
|
},
|
|
277
274
|
|
|
@@ -339,9 +336,14 @@ export default {
|
|
|
339
336
|
*/
|
|
340
337
|
redrawForBrush(callCallbck = true): void {
|
|
341
338
|
const $$ = this;
|
|
342
|
-
const {
|
|
343
|
-
|
|
344
|
-
|
|
339
|
+
const {
|
|
340
|
+
config: {
|
|
341
|
+
subchart_onbrush: onBrush,
|
|
342
|
+
zoom_rescale: withY
|
|
343
|
+
},
|
|
344
|
+
scale,
|
|
345
|
+
state
|
|
346
|
+
} = $$;
|
|
345
347
|
|
|
346
348
|
$$.redraw({
|
|
347
349
|
withTransition: false,
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {drag as d3Drag} from "d3-drag";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
zoom as d3Zoom,
|
|
8
|
+
zoomIdentity as d3ZoomIdentity,
|
|
9
|
+
zoomTransform as d3ZoomTransform
|
|
10
|
+
} from "d3-zoom";
|
|
7
11
|
import {$COMMON, $ZOOM} from "../../config/classes";
|
|
8
12
|
import {callFn, diffDomain, getPointer, isFunction} from "../../module/util";
|
|
9
13
|
|
|
@@ -79,7 +83,8 @@ export default {
|
|
|
79
83
|
* @private
|
|
80
84
|
*/
|
|
81
85
|
// @ts-ignore
|
|
82
|
-
zoom.updateTransformScale = (transform: d3ZoomTransform,
|
|
86
|
+
zoom.updateTransformScale = (transform: d3ZoomTransform,
|
|
87
|
+
correctTransform: boolean): void => {
|
|
83
88
|
const isRotated = config.axis_rotated;
|
|
84
89
|
|
|
85
90
|
// in case of resize, update range of orgXScale
|
|
@@ -102,7 +107,8 @@ export default {
|
|
|
102
107
|
const tX = isRotated ? transform.x : t;
|
|
103
108
|
const tY = isRotated ? t : transform.y;
|
|
104
109
|
|
|
105
|
-
$$.$el.eventRect.property("__zoom",
|
|
110
|
+
$$.$el.eventRect.property("__zoom",
|
|
111
|
+
d3ZoomIdentity.translate(tX, tY).scale(transform.k));
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
if (!$$.state.xTickOffset) {
|
|
@@ -172,7 +178,8 @@ export default {
|
|
|
172
178
|
if (
|
|
173
179
|
!config.zoom_enabled ||
|
|
174
180
|
$$.filterTargetsToShow($$.data.targets).length === 0 ||
|
|
175
|
-
(!scale.zoom && sourceEvent?.type.indexOf("touch") > -1 &&
|
|
181
|
+
(!scale.zoom && sourceEvent?.type.indexOf("touch") > -1 &&
|
|
182
|
+
sourceEvent?.touches.length === 1)
|
|
176
183
|
) {
|
|
177
184
|
return;
|
|
178
185
|
}
|
|
@@ -197,8 +204,8 @@ export default {
|
|
|
197
204
|
// - when .unzoom() is called (event.transform === d3ZoomIdentity)
|
|
198
205
|
const doTransition = config.transition_duration > 0 &&
|
|
199
206
|
!config.subchart_show && (
|
|
200
|
-
|
|
201
|
-
|
|
207
|
+
state.dragging || isUnZoom || !event.sourceEvent
|
|
208
|
+
);
|
|
202
209
|
|
|
203
210
|
$$.redraw({
|
|
204
211
|
withTransition: doTransition,
|
|
@@ -236,9 +243,11 @@ export default {
|
|
|
236
243
|
}
|
|
237
244
|
|
|
238
245
|
// if click, do nothing. otherwise, click interaction will be canceled.
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
if (
|
|
247
|
+
config.zoom_type === "drag" && (
|
|
248
|
+
e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY
|
|
249
|
+
)
|
|
250
|
+
) {
|
|
242
251
|
return;
|
|
243
252
|
}
|
|
244
253
|
|
|
@@ -268,15 +277,17 @@ export default {
|
|
|
268
277
|
const xDomain = subX.domain();
|
|
269
278
|
const delta = 0.015; // arbitrary value
|
|
270
279
|
|
|
271
|
-
const isfullyShown = $$.config.axis_x_inverted ?
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
+
const isfullyShown = $$.config.axis_x_inverted ?
|
|
281
|
+
(
|
|
282
|
+
zoomDomain[0] >= xDomain[0] || (zoomDomain[0] + delta) >= xDomain[0]
|
|
283
|
+
) && (
|
|
284
|
+
xDomain[1] >= zoomDomain[1] || xDomain[1] >= (zoomDomain[1] + delta)
|
|
285
|
+
) :
|
|
286
|
+
(
|
|
287
|
+
zoomDomain[0] <= xDomain[0] || (zoomDomain[0] - delta) <= xDomain[0]
|
|
288
|
+
) && (
|
|
289
|
+
xDomain[1] <= zoomDomain[1] || xDomain[1] <= (zoomDomain[1] - delta)
|
|
290
|
+
);
|
|
280
291
|
|
|
281
292
|
// check if the zoomed chart is fully shown, then reset scale when zoom is out as initial
|
|
282
293
|
if (force || isfullyShown) {
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
*/
|
|
19
19
|
getClass(type: string, withShape: boolean): Function {
|
|
20
20
|
const isPlural = /s$/.test(type);
|
|
21
|
-
const useIdKey = /^(area|arc|line|treemap)s?$/.test(type);
|
|
21
|
+
const useIdKey = /^(area|arc|line|funnel|treemap)s?$/.test(type);
|
|
22
22
|
const key = isPlural ? "id" : "index";
|
|
23
23
|
|
|
24
24
|
return (d): string => {
|
|
@@ -94,14 +94,15 @@ export default {
|
|
|
94
94
|
const target = this.getTargetSelectorSuffix(id);
|
|
95
95
|
|
|
96
96
|
// select target & circle
|
|
97
|
-
return `${prefix}.${CLASS.target + target} ${postfix}, ${prefix}.${
|
|
97
|
+
return `${prefix}.${CLASS.target + target} ${postfix}, ${prefix}.${
|
|
98
|
+
CLASS.circles + target
|
|
99
|
+
} ${postfix}`;
|
|
98
100
|
},
|
|
99
101
|
|
|
100
102
|
selectorTargets(idsValue, prefix: string): string[] | null {
|
|
101
103
|
const ids = idsValue || [];
|
|
102
104
|
|
|
103
|
-
return ids.length ?
|
|
104
|
-
ids.map(id => this.selectorTarget(id, prefix)) : null;
|
|
105
|
+
return ids.length ? ids.map(id => this.selectorTarget(id, prefix)) : null;
|
|
105
106
|
},
|
|
106
107
|
|
|
107
108
|
selectorLegend(id: string): string {
|
|
@@ -109,7 +110,6 @@ export default {
|
|
|
109
110
|
},
|
|
110
111
|
|
|
111
112
|
selectorLegends(ids): string[] | null {
|
|
112
|
-
return ids?.length ?
|
|
113
|
-
ids.map(id => this.selectorLegend(id)) : null;
|
|
113
|
+
return ids?.length ? ids.map(id => this.selectorLegend(id)) : null;
|
|
114
114
|
}
|
|
115
115
|
};
|
|
@@ -26,9 +26,11 @@ export default {
|
|
|
26
26
|
const $$ = this;
|
|
27
27
|
const {config} = $$;
|
|
28
28
|
|
|
29
|
-
if (
|
|
29
|
+
if (
|
|
30
|
+
(!config.clipPath && /-clip$/.test(id)) ||
|
|
30
31
|
(!config.axis_x_clipPath && /-clip-xaxis$/.test(id)) ||
|
|
31
|
-
(!config.axis_y_clipPath && /-clip-yaxis$/.test(id))
|
|
32
|
+
(!config.axis_y_clipPath && /-clip-yaxis$/.test(id))
|
|
33
|
+
) {
|
|
32
34
|
return null;
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -78,7 +80,8 @@ export default {
|
|
|
78
80
|
const left = Math.max(30, margin.left) - (isRotated ? 20 : 0);
|
|
79
81
|
const isInner = config.axis_y_inner;
|
|
80
82
|
|
|
81
|
-
const x = isInner && !isRotated ?
|
|
83
|
+
const x = isInner && !isRotated ?
|
|
84
|
+
(config.axis_y_label.text ? -20 : -1) :
|
|
82
85
|
(isRotated ? -(1 + left) : -(left - 1));
|
|
83
86
|
const y = -(isRotated ? 20 : margin.top);
|
|
84
87
|
const w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0);
|
|
@@ -104,7 +107,8 @@ export default {
|
|
|
104
107
|
clip.idXAxisTickTexts = clipId;
|
|
105
108
|
}
|
|
106
109
|
|
|
107
|
-
if (
|
|
110
|
+
if (
|
|
111
|
+
!config.axis_x_tick_multiline &&
|
|
108
112
|
$$.getAxisTickRotate("x") &&
|
|
109
113
|
newXAxisHeight !== xAxisHeight
|
|
110
114
|
) {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {select as d3Select} from "d3-selection";
|
|
6
5
|
import {scaleOrdinal as d3ScaleOrdinal} from "d3-scale";
|
|
7
|
-
import {
|
|
6
|
+
import {select as d3Select} from "d3-selection";
|
|
7
|
+
import {d3Selection} from "../../../types";
|
|
8
8
|
import {$ARC, $COLOR, $SHAPE} from "../../config/classes";
|
|
9
|
+
import {document} from "../../module/browser";
|
|
9
10
|
import {KEY} from "../../module/Cache";
|
|
10
|
-
import {
|
|
11
|
+
import {isFunction, isObject, isString, notEmpty} from "../../module/util";
|
|
11
12
|
import type {IArcData, IDataRow} from "../data/IData";
|
|
12
|
-
import {d3Selection} from "../../../types";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Set pattern's background color
|
|
@@ -72,7 +72,18 @@ function getColorFromCss(element: d3Selection): string[] {
|
|
|
72
72
|
|
|
73
73
|
// Replacement of d3.schemeCategory10.
|
|
74
74
|
// Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
|
|
75
|
-
const schemeCategory10 = [
|
|
75
|
+
const schemeCategory10 = [
|
|
76
|
+
"#1f77b4",
|
|
77
|
+
"#ff7f0e",
|
|
78
|
+
"#2ca02c",
|
|
79
|
+
"#d62728",
|
|
80
|
+
"#9467bd",
|
|
81
|
+
"#8c564b",
|
|
82
|
+
"#e377c2",
|
|
83
|
+
"#7f7f7f",
|
|
84
|
+
"#bcbd22",
|
|
85
|
+
"#17becf"
|
|
86
|
+
];
|
|
76
87
|
|
|
77
88
|
export default {
|
|
78
89
|
generateColor(): Function {
|
|
@@ -82,7 +93,8 @@ export default {
|
|
|
82
93
|
const callback = config.data_color;
|
|
83
94
|
const ids: string[] = [];
|
|
84
95
|
|
|
85
|
-
let pattern = notEmpty(config.color_pattern) ?
|
|
96
|
+
let pattern = notEmpty(config.color_pattern) ?
|
|
97
|
+
config.color_pattern :
|
|
86
98
|
d3ScaleOrdinal(getColorFromCss($el.chart) || schemeCategory10).range();
|
|
87
99
|
|
|
88
100
|
const originalColorPattern = pattern;
|
|
@@ -114,24 +126,24 @@ export default {
|
|
|
114
126
|
if (isFunction(colors[id])) {
|
|
115
127
|
color = colors[id].bind($$.api)(d);
|
|
116
128
|
|
|
117
|
-
|
|
129
|
+
// if specified, choose that color
|
|
118
130
|
} else if (colors[id]) {
|
|
119
131
|
color = colors[id];
|
|
120
132
|
|
|
121
|
-
|
|
133
|
+
// if not specified, choose from pattern
|
|
122
134
|
} else {
|
|
123
135
|
if (ids.indexOf(id) < 0) {
|
|
124
136
|
ids.push(id);
|
|
125
137
|
}
|
|
126
138
|
|
|
127
|
-
color = isLine ?
|
|
139
|
+
color = isLine ?
|
|
140
|
+
originalColorPattern[ids.indexOf(id) % originalColorPattern.length] :
|
|
128
141
|
pattern[ids.indexOf(id) % pattern.length];
|
|
129
142
|
|
|
130
143
|
colors[id] = color;
|
|
131
144
|
}
|
|
132
145
|
|
|
133
|
-
return isFunction(callback) ?
|
|
134
|
-
callback.bind($$.api)(color, d) : color;
|
|
146
|
+
return isFunction(callback) ? callback.bind($$.api)(color, d) : color;
|
|
135
147
|
};
|
|
136
148
|
},
|
|
137
149
|
|
|
@@ -143,52 +155,66 @@ export default {
|
|
|
143
155
|
const asValue = threshold.unit === "value";
|
|
144
156
|
const max = threshold.max || 100;
|
|
145
157
|
const values = threshold.values &&
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
threshold.values.length ?
|
|
159
|
+
threshold.values :
|
|
160
|
+
[];
|
|
161
|
+
|
|
162
|
+
return notEmpty(threshold) ?
|
|
163
|
+
function(value) {
|
|
164
|
+
const v = asValue ? value : (value * 100 / max);
|
|
165
|
+
let color = colors[colors.length - 1];
|
|
166
|
+
|
|
167
|
+
for (let i = 0, l = values.length; i < l; i++) {
|
|
168
|
+
if (v <= values[i]) {
|
|
169
|
+
color = colors[i];
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
156
172
|
}
|
|
157
|
-
}
|
|
158
173
|
|
|
159
|
-
|
|
160
|
-
|
|
174
|
+
return color;
|
|
175
|
+
} :
|
|
176
|
+
null;
|
|
161
177
|
},
|
|
162
178
|
|
|
163
179
|
/**
|
|
164
180
|
* Append data backgound color filter definition
|
|
165
|
-
* @param {string} color Color string
|
|
181
|
+
* @param {string|object} color Color string
|
|
182
|
+
* @param {object} attr filter attribute
|
|
166
183
|
* @private
|
|
167
184
|
*/
|
|
168
|
-
|
|
185
|
+
generateTextBGColorFilter(color: string | object, attr = {
|
|
186
|
+
x: 0,
|
|
187
|
+
y: 0,
|
|
188
|
+
width: 1,
|
|
189
|
+
height: 1
|
|
190
|
+
}): void {
|
|
169
191
|
const $$ = this;
|
|
170
|
-
const {$el,
|
|
171
|
-
const backgroundColors = color || config.data_labels_backgroundColors;
|
|
192
|
+
const {$el, state} = $$;
|
|
172
193
|
|
|
173
|
-
if (
|
|
194
|
+
if (color) {
|
|
174
195
|
let ids: string[] = [];
|
|
175
196
|
|
|
176
|
-
if (isString(
|
|
197
|
+
if (isString(color)) {
|
|
177
198
|
ids.push("");
|
|
178
|
-
} else if (isObject(
|
|
179
|
-
ids = Object.keys(
|
|
199
|
+
} else if (isObject(color)) {
|
|
200
|
+
ids = Object.keys(color);
|
|
180
201
|
}
|
|
181
202
|
|
|
182
203
|
ids.forEach(v => {
|
|
183
|
-
const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${
|
|
204
|
+
const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${
|
|
205
|
+
isString(color) ? $$.getTargetSelectorSuffix(color) : ""
|
|
206
|
+
}`;
|
|
184
207
|
|
|
185
208
|
$el.defs.append("filter")
|
|
186
|
-
.attr("x",
|
|
187
|
-
.attr("y",
|
|
188
|
-
.attr("width",
|
|
189
|
-
.attr("height",
|
|
209
|
+
.attr("x", attr.x)
|
|
210
|
+
.attr("y", attr.y)
|
|
211
|
+
.attr("width", attr.width)
|
|
212
|
+
.attr("height", attr.height)
|
|
190
213
|
.attr("id", id)
|
|
191
|
-
.html(
|
|
214
|
+
.html(
|
|
215
|
+
`<feFlood flood-color="${v === "" ? color : color[v]}" />
|
|
216
|
+
<feComposite in="SourceGraphic" />`
|
|
217
|
+
);
|
|
192
218
|
});
|
|
193
219
|
}
|
|
194
220
|
},
|
|
@@ -221,8 +247,8 @@ export default {
|
|
|
221
247
|
if ((radialGradient || supportedType) && defs.select(`#${id}`).empty()) {
|
|
222
248
|
const color = $$.color(d);
|
|
223
249
|
const gradient = {
|
|
224
|
-
defs: <null|d3Selection>null,
|
|
225
|
-
stops: <[number, string|Function|null, number][]>[]
|
|
250
|
+
defs: <null | d3Selection>null,
|
|
251
|
+
stops: <[number, string | Function | null, number][]>[]
|
|
226
252
|
};
|
|
227
253
|
|
|
228
254
|
if (radialGradient) {
|
|
@@ -256,9 +282,11 @@ export default {
|
|
|
256
282
|
.attr("y2", y[1]);
|
|
257
283
|
}
|
|
258
284
|
|
|
259
|
-
gradient.stops.forEach((v: [number, string|Function|null, number]) => {
|
|
285
|
+
gradient.stops.forEach((v: [number, string | Function | null, number]) => {
|
|
260
286
|
const [offset, stopColor, stopOpacity] = v;
|
|
261
|
-
const colorValue = isFunction(stopColor) ?
|
|
287
|
+
const colorValue = isFunction(stopColor) ?
|
|
288
|
+
stopColor.bind($$.api)(d.id) :
|
|
289
|
+
stopColor;
|
|
262
290
|
|
|
263
291
|
gradient.defs && gradient.defs.append("stop")
|
|
264
292
|
.attr("offset", offset)
|