billboard.js 3.11.2 → 3.12.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 +2 -6
- package/dist/billboard.css +5 -1
- package/dist/billboard.js +19431 -24292
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +26 -3
- package/dist/billboard.pkgd.js +22301 -29057
- 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 +423 -1134
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +660 -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 +339 -1324
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1701 -3424
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2385 -4462
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1783 -3467
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2031 -3979
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
- package/dist/theme/dark.css +5 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +5 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +5 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +5 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +5 -1
- package/dist/theme/modern.min.css +3 -4
- package/dist-esm/billboard.js +9051 -8666
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +19 -25
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +149 -148
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +295 -286
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +235 -234
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +40 -41
- package/package.json +26 -46
- 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 +5 -7
- 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 +79 -51
- package/src/ChartInternal/data/IData.ts +22 -29
- package/src/ChartInternal/data/convert.helper.ts +66 -68
- package/src/ChartInternal/data/convert.ts +11 -11
- package/src/ChartInternal/data/data.ts +40 -23
- package/src/ChartInternal/data/load.ts +7 -6
- package/src/ChartInternal/interactions/drag.ts +2 -1
- package/src/ChartInternal/interactions/eventrect.ts +54 -25
- package/src/ChartInternal/interactions/flow.ts +14 -4
- package/src/ChartInternal/interactions/interaction.ts +34 -12
- 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 +5 -5
- package/src/ChartInternal/internals/clip.ts +9 -10
- 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 +130 -47
- package/src/ChartInternal/internals/legend.ts +99 -66
- package/src/ChartInternal/internals/redraw.ts +3 -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 +97 -66
- package/src/ChartInternal/internals/style.ts +21 -19
- package/src/ChartInternal/internals/text.ts +64 -39
- package/src/ChartInternal/internals/title.ts +2 -2
- package/src/ChartInternal/internals/tooltip.ts +83 -34
- package/src/ChartInternal/internals/transform.ts +2 -2
- package/src/ChartInternal/internals/type.ts +12 -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/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 +52 -32
- 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 +29 -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 +12 -13
- 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 +13 -14
- 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 +45 -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/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 +19 -13
- package/src/config/classes.ts +6 -4
- package/src/config/config.ts +1 -1
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/interaction.ts +3 -7
- package/src/config/resolver/shape.ts +11 -12
- package/src/core.ts +2 -3
- package/src/index.esm.ts +2 -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 +60 -37
- package/src/module/worker.ts +14 -11
- package/src/scss/billboard.scss +6 -0
- package/src/scss/theme/dark.scss +6 -0
- package/src/scss/theme/datalab.scss +6 -0
- package/src/scss/theme/graph.scss +6 -0
- package/src/scss/theme/insight.scss +6 -0
- package/src/scss/theme/modern.scss +6 -0
- package/types/axis.d.ts +7 -0
- package/types/options.d.ts +7 -0
- package/types/options.shape.d.ts +7 -0
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
6
|
import {$BAR, $CANDLESTICK, $COMMON} from "../../config/classes";
|
|
7
7
|
import {KEY} from "../../module/Cache";
|
|
8
|
-
import type {IData, IDataPoint, IDataRow} from "./IData";
|
|
9
8
|
import {
|
|
10
9
|
findIndex,
|
|
11
|
-
getUnique,
|
|
12
10
|
getScrollPosition,
|
|
11
|
+
getUnique,
|
|
13
12
|
hasValue,
|
|
14
13
|
isArray,
|
|
15
14
|
isboolean,
|
|
@@ -26,6 +25,7 @@ import {
|
|
|
26
25
|
parseDate,
|
|
27
26
|
sortValue
|
|
28
27
|
} from "../../module/util";
|
|
28
|
+
import type {IData, IDataPoint, IDataRow} from "./IData";
|
|
29
29
|
|
|
30
30
|
export default {
|
|
31
31
|
isX(key) {
|
|
@@ -56,9 +56,7 @@ export default {
|
|
|
56
56
|
isGrouped(id?: string): boolean {
|
|
57
57
|
const groups = this.config.data_groups;
|
|
58
58
|
|
|
59
|
-
return id ?
|
|
60
|
-
groups.some(v => v.indexOf(id) >= 0 && v.length > 1) :
|
|
61
|
-
groups.length > 0;
|
|
59
|
+
return id ? groups.some(v => v.indexOf(id) >= 0 && v.length > 1) : groups.length > 0;
|
|
62
60
|
},
|
|
63
61
|
|
|
64
62
|
getXKey(id) {
|
|
@@ -66,7 +64,8 @@ export default {
|
|
|
66
64
|
const {config} = $$;
|
|
67
65
|
|
|
68
66
|
return config.data_x ?
|
|
69
|
-
config.data_x :
|
|
67
|
+
config.data_x :
|
|
68
|
+
(notEmpty(config.data_xs) ? config.data_xs[id] : null);
|
|
70
69
|
},
|
|
71
70
|
|
|
72
71
|
getXValuesOfXKey(key, targets) {
|
|
@@ -90,7 +89,7 @@ export default {
|
|
|
90
89
|
* @returns {number} index number
|
|
91
90
|
* @private
|
|
92
91
|
*/
|
|
93
|
-
getIndexByX(x: Date|number|string, basedX: (Date|number|string)[]): number {
|
|
92
|
+
getIndexByX(x: Date | number | string, basedX: (Date | number | string)[]): number {
|
|
94
93
|
const $$ = this;
|
|
95
94
|
|
|
96
95
|
return basedX ?
|
|
@@ -102,8 +101,10 @@ export default {
|
|
|
102
101
|
const $$ = this;
|
|
103
102
|
|
|
104
103
|
return id in $$.data.xs &&
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
$$.data.xs[id] &&
|
|
105
|
+
isValue($$.data.xs[id][i]) ?
|
|
106
|
+
$$.data.xs[id][i] :
|
|
107
|
+
i;
|
|
107
108
|
},
|
|
108
109
|
|
|
109
110
|
getOtherTargetXs(): string | null {
|
|
@@ -413,7 +414,10 @@ export default {
|
|
|
413
414
|
.map(v => v.x);
|
|
414
415
|
|
|
415
416
|
target = sortValue(getUnique(target))
|
|
416
|
-
.map((x, index, array) => ({
|
|
417
|
+
.map((x, index, array) => ({
|
|
418
|
+
x,
|
|
419
|
+
index: isInverted ? array.length - index - 1 : index
|
|
420
|
+
}));
|
|
417
421
|
} else if (length) {
|
|
418
422
|
target = target[0].values.concat();
|
|
419
423
|
}
|
|
@@ -527,8 +531,10 @@ export default {
|
|
|
527
531
|
const {hasAxis} = $$.state;
|
|
528
532
|
const ys = {};
|
|
529
533
|
const isMultipleX = $$.isMultipleX();
|
|
530
|
-
const xs = isMultipleX ?
|
|
531
|
-
|
|
534
|
+
const xs = isMultipleX ?
|
|
535
|
+
$$.mapTargetsToUniqueXs(targets)
|
|
536
|
+
.map(v => (isString(v) ? v : +v)) :
|
|
537
|
+
null;
|
|
532
538
|
|
|
533
539
|
targets.forEach(t => {
|
|
534
540
|
const data: any[] = [];
|
|
@@ -540,7 +546,9 @@ export default {
|
|
|
540
546
|
|
|
541
547
|
// exclude 'volume' value to correct mis domain calculation
|
|
542
548
|
if (value !== null && $$.isCandlestickType(v)) {
|
|
543
|
-
value = isArray(value) ?
|
|
549
|
+
value = isArray(value) ?
|
|
550
|
+
value.slice(0, 4) :
|
|
551
|
+
[value.open, value.high, value.low, value.close];
|
|
544
552
|
}
|
|
545
553
|
|
|
546
554
|
if (isArray(value)) {
|
|
@@ -627,8 +635,8 @@ export default {
|
|
|
627
635
|
if (orderAsc || orderDesc) {
|
|
628
636
|
const reducer = (p, c) => p + Math.abs(c.value);
|
|
629
637
|
const sum = v => (isNumber(v) ? v : (
|
|
630
|
-
"values" in v ? v.values.reduce(reducer, 0) : v.value
|
|
631
|
-
);
|
|
638
|
+
"values" in v ? v.values.reduce(reducer, 0) : v.value
|
|
639
|
+
));
|
|
632
640
|
|
|
633
641
|
fn = (t1: IData | IDataRow, t2: IData | IDataRow) => {
|
|
634
642
|
const t1Sum = sum(t1);
|
|
@@ -694,7 +702,9 @@ export default {
|
|
|
694
702
|
const scrollPos = getScrollPosition($el.chart.node());
|
|
695
703
|
|
|
696
704
|
// get data based on the mouse coords
|
|
697
|
-
const e = inputType === "touch" && event.changedTouches ?
|
|
705
|
+
const e = inputType === "touch" && event.changedTouches ?
|
|
706
|
+
event.changedTouches[0] :
|
|
707
|
+
event;
|
|
698
708
|
|
|
699
709
|
index = findIndex(
|
|
700
710
|
coords,
|
|
@@ -782,8 +792,12 @@ export default {
|
|
|
782
792
|
.filter(v => $$.isBarType(v.id) || $$.isCandlestickType(v.id))
|
|
783
793
|
.forEach(v => {
|
|
784
794
|
const selector = $$.isBarType(v.id) ?
|
|
785
|
-
`.${$BAR.chartBar}.${$COMMON.target}${
|
|
786
|
-
|
|
795
|
+
`.${$BAR.chartBar}.${$COMMON.target}${
|
|
796
|
+
$$.getTargetSelectorSuffix(v.id)
|
|
797
|
+
} .${$BAR.bar}-${v.index}` :
|
|
798
|
+
`.${$CANDLESTICK.chartCandlestick}.${$COMMON.target}${
|
|
799
|
+
$$.getTargetSelectorSuffix(v.id)
|
|
800
|
+
} .${$CANDLESTICK.candlestick}-${v.index} path`;
|
|
787
801
|
|
|
788
802
|
if (!closest && $$.isWithinBar(main.select(selector).node())) {
|
|
789
803
|
closest = v;
|
|
@@ -968,7 +982,8 @@ export default {
|
|
|
968
982
|
// otherwise, based on the rendered angle value
|
|
969
983
|
} else {
|
|
970
984
|
const gaugeArcLength = config.gauge_fullCircle ?
|
|
971
|
-
$$.getArcLength() :
|
|
985
|
+
$$.getArcLength() :
|
|
986
|
+
$$.getStartingAngle() * -2;
|
|
972
987
|
const arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
|
|
973
988
|
|
|
974
989
|
ratio = (d.endAngle - d.startAngle) / arcLength;
|
|
@@ -982,7 +997,9 @@ export default {
|
|
|
982
997
|
|
|
983
998
|
if (hiddenSum.length) {
|
|
984
999
|
hiddenSum = hiddenSum
|
|
985
|
-
.reduce((acc, curr) =>
|
|
1000
|
+
.reduce((acc, curr) =>
|
|
1001
|
+
acc.map((v, i) => (isNumber(v) ? v : 0) + curr[i])
|
|
1002
|
+
);
|
|
986
1003
|
|
|
987
1004
|
total = total.map((v, i) => v - hiddenSum[i]);
|
|
988
1005
|
}
|
|
@@ -990,8 +1007,7 @@ export default {
|
|
|
990
1007
|
|
|
991
1008
|
const divisor = total[d.index];
|
|
992
1009
|
|
|
993
|
-
d.ratio = isNumber(d.value) && total && divisor ?
|
|
994
|
-
d.value / divisor : 0;
|
|
1010
|
+
d.ratio = isNumber(d.value) && total && divisor ? d.value / divisor : 0;
|
|
995
1011
|
|
|
996
1012
|
ratio = d.ratio;
|
|
997
1013
|
} else if (type === "radar") {
|
|
@@ -1064,7 +1080,8 @@ export default {
|
|
|
1064
1080
|
const $$ = this;
|
|
1065
1081
|
const {value} = d;
|
|
1066
1082
|
|
|
1067
|
-
return $$.isBarType(d) && isArray(value) && value.length >= 2 &&
|
|
1083
|
+
return $$.isBarType(d) && isArray(value) && value.length >= 2 &&
|
|
1084
|
+
value.every(v => isNumber(v));
|
|
1068
1085
|
},
|
|
1069
1086
|
|
|
1070
1087
|
/**
|
|
@@ -25,9 +25,9 @@ export default {
|
|
|
25
25
|
const {axis, data, org, scale} = $$;
|
|
26
26
|
const {append} = args;
|
|
27
27
|
const zoomState = {
|
|
28
|
-
domain: <any>
|
|
29
|
-
currentDomain: <any>
|
|
30
|
-
x: <any>
|
|
28
|
+
domain: <any>null,
|
|
29
|
+
currentDomain: <any>null,
|
|
30
|
+
x: <any>null
|
|
31
31
|
};
|
|
32
32
|
let targets = rawTargets;
|
|
33
33
|
|
|
@@ -50,8 +50,7 @@ export default {
|
|
|
50
50
|
data.targets.forEach(d => {
|
|
51
51
|
for (let i = 0; i < targets.length; i++) {
|
|
52
52
|
if (d.id === targets[i].id) {
|
|
53
|
-
d.values = append ?
|
|
54
|
-
d.values.concat(targets[i].values) : targets[i].values;
|
|
53
|
+
d.values = append ? d.values.concat(targets[i].values) : targets[i].values;
|
|
55
54
|
|
|
56
55
|
targets.splice(i, 1);
|
|
57
56
|
break;
|
|
@@ -66,7 +65,9 @@ export default {
|
|
|
66
65
|
$$.updateTargets(data.targets);
|
|
67
66
|
|
|
68
67
|
if (scale.zoom) {
|
|
69
|
-
zoomState.x = axis.isCategorized() ?
|
|
68
|
+
zoomState.x = axis.isCategorized() ?
|
|
69
|
+
scale.x.orgScale() :
|
|
70
|
+
(org.xScale || scale.x).copy();
|
|
70
71
|
zoomState.domain = $$.getXDomain(data.targets); // get updated xDomain
|
|
71
72
|
|
|
72
73
|
zoomState.x.domain(zoomState.domain);
|
|
@@ -23,7 +23,8 @@ export default {
|
|
|
23
23
|
const isSelectionGrouped = config.data_selection_grouped;
|
|
24
24
|
const isSelectable = config.interaction_enabled && config.data_selection_isselectable;
|
|
25
25
|
|
|
26
|
-
if (
|
|
26
|
+
if (
|
|
27
|
+
$$.hasArcType() ||
|
|
27
28
|
!config.data_selection_enabled || // do nothing if not selectable
|
|
28
29
|
(config.zoom_enabled && !$$.zoom.altDomain) || // skip if zoomable because of conflict drag behavior
|
|
29
30
|
!config.data_selection_multiple // skip when single selection because drag is used for multiple selection
|
|
@@ -2,8 +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 type {d3Selection} from "../../../types";
|
|
5
6
|
import {$COMMON, $EVENT, $SHAPE} from "../../config/classes";
|
|
6
|
-
import {
|
|
7
|
+
import {getPointer, getScrollPosition, isboolean, isFunction} from "../../module/util";
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
/**
|
|
@@ -33,12 +34,14 @@ export default {
|
|
|
33
34
|
if ($el.eventRect) {
|
|
34
35
|
$$.updateEventRect($el.eventRect, true);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
// do not initialize eventRect when data is empty
|
|
37
38
|
} else if ($$.data.targets.length) {
|
|
38
39
|
const eventRects = $$.$el.main.select(`.${$EVENT.eventRects}`)
|
|
39
|
-
.style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ?
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
.style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ?
|
|
41
|
+
(
|
|
42
|
+
config.axis_rotated ? "ns-resize" : "ew-resize"
|
|
43
|
+
) :
|
|
44
|
+
null)
|
|
42
45
|
.classed($EVENT.eventRectsMultiple, isMultipleX)
|
|
43
46
|
.classed($EVENT.eventRectsSingle, !isMultipleX);
|
|
44
47
|
|
|
@@ -60,7 +63,10 @@ export default {
|
|
|
60
63
|
|
|
61
64
|
$el.eventRect = eventRectUpdate;
|
|
62
65
|
|
|
63
|
-
if (
|
|
66
|
+
if (
|
|
67
|
+
$$.state.inputType === "touch" && !$el.svg.on("touchstart.eventRect") &&
|
|
68
|
+
!$$.hasArcType()
|
|
69
|
+
) {
|
|
64
70
|
$$.bindTouchOnEventRect();
|
|
65
71
|
}
|
|
66
72
|
|
|
@@ -99,9 +105,7 @@ export default {
|
|
|
99
105
|
|
|
100
106
|
$$.callOverOutForTouch(index);
|
|
101
107
|
|
|
102
|
-
index === -1 ?
|
|
103
|
-
$$.unselectRect() :
|
|
104
|
-
$$.selectRectForSingle(context, index);
|
|
108
|
+
index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, index);
|
|
105
109
|
}
|
|
106
110
|
};
|
|
107
111
|
|
|
@@ -130,9 +134,12 @@ export default {
|
|
|
130
134
|
startPx = currentXY;
|
|
131
135
|
}
|
|
132
136
|
} else if (eventType === "touchmove") {
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
137
|
+
if (
|
|
138
|
+
isPrevented || startPx === true || (
|
|
139
|
+
preventThreshold !== null &&
|
|
140
|
+
Math.abs(startPx - currentXY) >= preventThreshold
|
|
141
|
+
)
|
|
142
|
+
) {
|
|
136
143
|
// once prevented, keep prevented during whole 'touchmove' context
|
|
137
144
|
startPx = true;
|
|
138
145
|
event.preventDefault();
|
|
@@ -151,7 +158,10 @@ export default {
|
|
|
151
158
|
|
|
152
159
|
if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
|
|
153
160
|
// if touch points are > 1, means doing zooming interaction. In this case do not execute tooltip codes.
|
|
154
|
-
if (
|
|
161
|
+
if (
|
|
162
|
+
state.dragging || state.flowing || $$.hasArcType() ||
|
|
163
|
+
event.touches.length > 1
|
|
164
|
+
) {
|
|
155
165
|
return;
|
|
156
166
|
}
|
|
157
167
|
|
|
@@ -344,7 +354,11 @@ export default {
|
|
|
344
354
|
}
|
|
345
355
|
|
|
346
356
|
// remove possible previous focused state
|
|
347
|
-
!circle &&
|
|
357
|
+
!circle &&
|
|
358
|
+
main.selectAll(`.${$COMMON.EXPANDED}:not(.${$SHAPE.shape}-${index})`).classed(
|
|
359
|
+
$COMMON.EXPANDED,
|
|
360
|
+
false
|
|
361
|
+
);
|
|
348
362
|
|
|
349
363
|
const shapeAtIndex = main.selectAll(`.${$SHAPE.shape}-${index}`)
|
|
350
364
|
.classed($COMMON.EXPANDED, true)
|
|
@@ -364,7 +378,8 @@ export default {
|
|
|
364
378
|
.call(selected => {
|
|
365
379
|
const d = selected.data();
|
|
366
380
|
|
|
367
|
-
if (
|
|
381
|
+
if (
|
|
382
|
+
isSelectionEnabled &&
|
|
368
383
|
(isSelectionGrouped || isSelectable?.bind($$.api)(d))
|
|
369
384
|
) {
|
|
370
385
|
context.style.cursor = "pointer";
|
|
@@ -410,8 +425,10 @@ export default {
|
|
|
410
425
|
}
|
|
411
426
|
|
|
412
427
|
const sameXData = (
|
|
413
|
-
|
|
414
|
-
|
|
428
|
+
$$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped
|
|
429
|
+
) ?
|
|
430
|
+
[closest] :
|
|
431
|
+
$$.filterByX(targetsToShow, closest.x);
|
|
415
432
|
|
|
416
433
|
// show tooltip when cursor is close to some point
|
|
417
434
|
const selectedData = sameXData.map(d => $$.addName(d));
|
|
@@ -470,14 +487,14 @@ export default {
|
|
|
470
487
|
const {eventReceiver} = state;
|
|
471
488
|
|
|
472
489
|
const rect = eventRectEnter
|
|
473
|
-
.style("cursor",
|
|
490
|
+
.style("cursor",
|
|
491
|
+
config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null)
|
|
474
492
|
.on("click", function(event) {
|
|
475
493
|
state.event = event;
|
|
476
494
|
|
|
477
495
|
const {currentIdx, data} = eventReceiver;
|
|
478
496
|
const d = data[
|
|
479
|
-
currentIdx === -1 ?
|
|
480
|
-
$$.getDataIndexFromEvent(event) : currentIdx
|
|
497
|
+
currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx
|
|
481
498
|
];
|
|
482
499
|
|
|
483
500
|
$$.clickHandlerForSingleX.bind(this)(d, $$);
|
|
@@ -494,6 +511,9 @@ export default {
|
|
|
494
511
|
.on("mouseover", event => {
|
|
495
512
|
state.event = event;
|
|
496
513
|
$$.updateEventRect();
|
|
514
|
+
|
|
515
|
+
Object.values($$.$el.axisTooltip)
|
|
516
|
+
.forEach((v: d3Selection) => v?.style("display", null));
|
|
497
517
|
})
|
|
498
518
|
.on("mousemove", function(event) {
|
|
499
519
|
const d = getData(event);
|
|
@@ -508,7 +528,10 @@ export default {
|
|
|
508
528
|
const stepType = config.line_step_type;
|
|
509
529
|
|
|
510
530
|
// tooltip position match for step-before & step-after
|
|
511
|
-
if (
|
|
531
|
+
if (
|
|
532
|
+
config.line_step_tooltipMatch && $$.hasType("step") &&
|
|
533
|
+
/^step\-(before|after)$/.test(stepType)
|
|
534
|
+
) {
|
|
512
535
|
const scale = $$.scale.zoom || $$.scale.x;
|
|
513
536
|
const xs = $$.axis.xs[index];
|
|
514
537
|
const inverted = scale.invert(getPointer(event, this)[0]);
|
|
@@ -520,7 +543,10 @@ export default {
|
|
|
520
543
|
}
|
|
521
544
|
}
|
|
522
545
|
|
|
523
|
-
|
|
546
|
+
$$.showAxisGridFocus();
|
|
547
|
+
|
|
548
|
+
const eventOnSameIdx = config.tooltip_grouped &&
|
|
549
|
+
index === eventReceiver.currentIdx;
|
|
524
550
|
|
|
525
551
|
// do nothing while dragging/flowing
|
|
526
552
|
if (state.dragging || state.flowing || $$.hasArcType() || eventOnSameIdx) {
|
|
@@ -533,8 +559,7 @@ export default {
|
|
|
533
559
|
eventReceiver.currentIdx = index;
|
|
534
560
|
}
|
|
535
561
|
|
|
536
|
-
index === -1 ?
|
|
537
|
-
$$.unselectRect() : $$.selectRectForSingle(this, index);
|
|
562
|
+
index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, index);
|
|
538
563
|
|
|
539
564
|
// As of individual data point(or <path>) element can't bind mouseover/out event
|
|
540
565
|
// to determine current interacting element, so use 'mousemove' event instead.
|
|
@@ -548,6 +573,8 @@ export default {
|
|
|
548
573
|
return;
|
|
549
574
|
}
|
|
550
575
|
|
|
576
|
+
$$.hideAxisGridFocus();
|
|
577
|
+
|
|
551
578
|
$$.unselectRect();
|
|
552
579
|
$$.setOverOut(false, eventReceiver.currentIdx);
|
|
553
580
|
|
|
@@ -626,7 +653,9 @@ export default {
|
|
|
626
653
|
|
|
627
654
|
const mouse = getPointer(state.event, this);
|
|
628
655
|
const closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
|
629
|
-
const sensitivity = config.point_sensitivity === "radius" ?
|
|
656
|
+
const sensitivity = config.point_sensitivity === "radius" ?
|
|
657
|
+
closest.r :
|
|
658
|
+
config.point_sensitivity;
|
|
630
659
|
|
|
631
660
|
if (!closest) {
|
|
632
661
|
return;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {easeLinear as d3EaseLinear} from "d3-ease";
|
|
6
|
+
import CLASS from "../../config/classes";
|
|
6
7
|
import {generateWait} from "../../module/generator";
|
|
7
8
|
import {diffDomain} from "../../module/util";
|
|
8
|
-
import CLASS from "../../config/classes";
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
11
|
/**
|
|
@@ -37,7 +37,17 @@ export default {
|
|
|
37
37
|
// target elements
|
|
38
38
|
const elements = {};
|
|
39
39
|
|
|
40
|
-
[
|
|
40
|
+
[
|
|
41
|
+
"axis.x",
|
|
42
|
+
"grid.x",
|
|
43
|
+
"gridLines.x",
|
|
44
|
+
"region.list",
|
|
45
|
+
"text",
|
|
46
|
+
"bar",
|
|
47
|
+
"line",
|
|
48
|
+
"area",
|
|
49
|
+
"circle"
|
|
50
|
+
]
|
|
41
51
|
.forEach(v => {
|
|
42
52
|
const name = v.split(".");
|
|
43
53
|
let node = $el[name[0]];
|
|
@@ -69,7 +79,7 @@ export default {
|
|
|
69
79
|
duration = args.duration,
|
|
70
80
|
index: flowIndex,
|
|
71
81
|
length: flowLength,
|
|
72
|
-
orgDataCount
|
|
82
|
+
orgDataCount
|
|
73
83
|
} = flow;
|
|
74
84
|
|
|
75
85
|
const transform = $$.getFlowTransform(targets, orgDataCount, flowIndex, flowLength);
|
|
@@ -227,7 +237,7 @@ export default {
|
|
|
227
237
|
x(flowStart?.x || 0) - x(flowEnd.x);
|
|
228
238
|
}
|
|
229
239
|
|
|
230
|
-
const scaleX =
|
|
240
|
+
const scaleX = diffDomain(orgDomain) / diffDomain(domain);
|
|
231
241
|
|
|
232
242
|
return `translate(${translateX},0) scale(${scaleX},1)`;
|
|
233
243
|
}
|
|
@@ -2,8 +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 {select as d3Select} from "d3-selection";
|
|
6
5
|
import {drag as d3Drag} from "d3-drag";
|
|
6
|
+
import {select as d3Select} from "d3-selection";
|
|
7
7
|
import {$ARC, $AXIS, $COMMON, $SHAPE, $TREEMAP} from "../../config/classes";
|
|
8
8
|
import {KEY} from "../../module/Cache";
|
|
9
9
|
import {emulateEvent, getPointer, isNumber, isObject} from "../../module/util";
|
|
@@ -67,7 +67,9 @@ export default {
|
|
|
67
67
|
if (isArcTreemap && "id") {
|
|
68
68
|
const selector = hasTreemap ? $TREEMAP.treemap : $ARC.arc;
|
|
69
69
|
|
|
70
|
-
callback(d,
|
|
70
|
+
callback(d,
|
|
71
|
+
main.select(`.${selector}${$$.getTargetSelectorSuffix((d as IArcDataRow).id)}`)
|
|
72
|
+
.node());
|
|
71
73
|
} else if (!config.tooltip_grouped) {
|
|
72
74
|
const last = $$.cache.get(KEY.setOverOut) || [];
|
|
73
75
|
|
|
@@ -83,9 +85,11 @@ export default {
|
|
|
83
85
|
});
|
|
84
86
|
|
|
85
87
|
// call onout callback
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
if (
|
|
89
|
+
!isOver || shapesAtIndex.empty() || (
|
|
90
|
+
last.length === shape.size() && shape.nodes().every((v, i) => v !== last[i])
|
|
91
|
+
)
|
|
92
|
+
) {
|
|
89
93
|
while (last.length) {
|
|
90
94
|
const target = last.pop();
|
|
91
95
|
|
|
@@ -156,7 +160,8 @@ export default {
|
|
|
156
160
|
.on("end", event => {
|
|
157
161
|
state.event = event;
|
|
158
162
|
$$.dragend();
|
|
159
|
-
}) :
|
|
163
|
+
}) :
|
|
164
|
+
() => {};
|
|
160
165
|
},
|
|
161
166
|
|
|
162
167
|
/**
|
|
@@ -168,9 +173,16 @@ export default {
|
|
|
168
173
|
*/
|
|
169
174
|
dispatchEvent(type: string, index: number, mouse: [number, number]): void {
|
|
170
175
|
const $$ = this;
|
|
171
|
-
const {
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
const {
|
|
177
|
+
config,
|
|
178
|
+
state: {
|
|
179
|
+
eventReceiver,
|
|
180
|
+
hasAxis,
|
|
181
|
+
hasRadar,
|
|
182
|
+
hasTreemap
|
|
183
|
+
},
|
|
184
|
+
$el: {eventRect, radar, treemap}
|
|
185
|
+
} = $$;
|
|
174
186
|
const element = (
|
|
175
187
|
(hasTreemap && eventReceiver.rect) ||
|
|
176
188
|
(hasRadar && radar.axes.select(`.${$AXIS.axis}-${index} text`)) || (
|
|
@@ -213,7 +225,9 @@ export default {
|
|
|
213
225
|
|
|
214
226
|
emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](
|
|
215
227
|
hasTreemap ? treemap.node() : element,
|
|
216
|
-
type,
|
|
228
|
+
type,
|
|
229
|
+
params
|
|
230
|
+
);
|
|
217
231
|
}
|
|
218
232
|
},
|
|
219
233
|
|
|
@@ -239,7 +253,7 @@ export default {
|
|
|
239
253
|
* Unbind all attached events
|
|
240
254
|
* @private
|
|
241
255
|
*/
|
|
242
|
-
unbindAllEvents():
|
|
256
|
+
unbindAllEvents(): void {
|
|
243
257
|
const $$ = this;
|
|
244
258
|
const {$el: {arcs, eventRect, legend, region, svg, treemap}, brush} = $$;
|
|
245
259
|
const list = [
|
|
@@ -262,7 +276,15 @@ export default {
|
|
|
262
276
|
].join(" ");
|
|
263
277
|
|
|
264
278
|
// detach all possible event types
|
|
265
|
-
[
|
|
279
|
+
[
|
|
280
|
+
svg,
|
|
281
|
+
eventRect,
|
|
282
|
+
region?.list,
|
|
283
|
+
brush?.getSelection(),
|
|
284
|
+
arcs?.selectAll("path"),
|
|
285
|
+
legend?.selectAll("g"),
|
|
286
|
+
treemap
|
|
287
|
+
]
|
|
266
288
|
.forEach(v => v?.on(list, null));
|
|
267
289
|
|
|
268
290
|
$$.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,
|