billboard.js 3.9.1 → 3.9.3
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/dist/billboard.css +1 -1
- package/dist/billboard.js +372 -248
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +1262 -422
- package/dist/billboard.pkgd.min.js +2 -2
- 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 +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +892 -176
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +893 -177
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +894 -178
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +894 -178
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +894 -178
- 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-esm/billboard.js +189 -92
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +20 -20
- package/src/Chart/api/load.ts +4 -2
- package/src/Chart/api/tooltip.ts +11 -3
- package/src/ChartInternal/data/data.ts +29 -12
- package/src/ChartInternal/interactions/eventrect.ts +75 -8
- package/src/ChartInternal/interactions/interaction.ts +2 -57
- package/src/ChartInternal/internals/redraw.ts +2 -0
- package/src/ChartInternal/internals/tooltip.ts +58 -2
- package/src/ChartInternal/shape/arc.ts +34 -6
- package/src/ChartInternal/shape/line.ts +0 -1
- package/src/ChartInternal/shape/radar.ts +5 -14
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.9.
|
|
8
|
+
* @version 3.9.3
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -121,7 +121,7 @@ var Plugin = /** @class */ (function () {
|
|
|
121
121
|
delete _this[key];
|
|
122
122
|
});
|
|
123
123
|
};
|
|
124
|
-
Plugin.version = "3.9.
|
|
124
|
+
Plugin.version = "3.9.3";
|
|
125
125
|
return Plugin;
|
|
126
126
|
}());
|
|
127
127
|
var Plugin$1 = Plugin;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.9.
|
|
8
|
+
* @version 3.9.3
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -263,7 +263,7 @@ var Plugin = /** @class */ (function () {
|
|
|
263
263
|
delete _this[key];
|
|
264
264
|
});
|
|
265
265
|
};
|
|
266
|
-
Plugin.version = "3.9.
|
|
266
|
+
Plugin.version = "3.9.3";
|
|
267
267
|
return Plugin;
|
|
268
268
|
}());
|
|
269
269
|
var Plugin$1 = Plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billboard.js",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.3",
|
|
4
4
|
"description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
|
|
5
5
|
"homepage": "https://naver.github.io/billboard.js/",
|
|
6
6
|
"main": "dist/billboard.js",
|
|
@@ -102,16 +102,16 @@
|
|
|
102
102
|
"d3-zoom": "^3.0.0"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
|
-
"@babel/core": "^7.22.
|
|
106
|
-
"@babel/eslint-parser": "^7.22.
|
|
105
|
+
"@babel/core": "^7.22.10",
|
|
106
|
+
"@babel/eslint-parser": "^7.22.10",
|
|
107
107
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
108
108
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
109
|
-
"@babel/plugin-transform-runtime": "^7.22.
|
|
110
|
-
"@babel/preset-env": "^7.22.
|
|
109
|
+
"@babel/plugin-transform-runtime": "^7.22.10",
|
|
110
|
+
"@babel/preset-env": "^7.22.10",
|
|
111
111
|
"@babel/preset-typescript": "^7.22.5",
|
|
112
|
-
"@babel/runtime": "^7.22.
|
|
113
|
-
"@commitlint/cli": "17.6.
|
|
114
|
-
"@commitlint/config-conventional": "^17.6.
|
|
112
|
+
"@babel/runtime": "^7.22.10",
|
|
113
|
+
"@commitlint/cli": "17.6.7",
|
|
114
|
+
"@commitlint/config-conventional": "^17.6.7",
|
|
115
115
|
"@rollup/plugin-babel": "^6.0.3",
|
|
116
116
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
117
117
|
"@rollup/plugin-replace": "^5.0.2",
|
|
@@ -125,9 +125,9 @@
|
|
|
125
125
|
"@types/chai": "^4.3.5",
|
|
126
126
|
"@types/d3": "^7.4.0",
|
|
127
127
|
"@types/mocha": "^10.0.1",
|
|
128
|
-
"@types/sinon": "^10.0.
|
|
129
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
130
|
-
"@typescript-eslint/parser": "^6.
|
|
128
|
+
"@types/sinon": "^10.0.16",
|
|
129
|
+
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
130
|
+
"@typescript-eslint/parser": "^6.3.0",
|
|
131
131
|
"babel-helper-modules": "^6.0.0",
|
|
132
132
|
"babel-loader": "^9.1.3",
|
|
133
133
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"chai": "^4.3.7",
|
|
144
144
|
"clean-webpack-plugin": "^4.0.0",
|
|
145
145
|
"cloc": "^2.11.0",
|
|
146
|
-
"core-js": "^3.
|
|
146
|
+
"core-js": "^3.32.0",
|
|
147
147
|
"coveralls": "^3.1.1",
|
|
148
148
|
"cross-env": "^7.0.3",
|
|
149
149
|
"css-loader": "^6.8.1",
|
|
@@ -154,16 +154,16 @@
|
|
|
154
154
|
"d3-polygon": "^3.0.1",
|
|
155
155
|
"docdash": "^2.0.1",
|
|
156
156
|
"dtslint": "^4.2.1",
|
|
157
|
-
"eslint": "^8.
|
|
157
|
+
"eslint": "^8.46.0",
|
|
158
158
|
"eslint-config-naver": "^2.1.0",
|
|
159
|
-
"eslint-plugin-import": "^2.
|
|
160
|
-
"eslint-plugin-jsdoc": "^46.4.
|
|
159
|
+
"eslint-plugin-import": "^2.28.0",
|
|
160
|
+
"eslint-plugin-jsdoc": "^46.4.6",
|
|
161
161
|
"eslint-webpack-plugin": "^4.0.1",
|
|
162
162
|
"exports-loader": "^4.0.0",
|
|
163
163
|
"hammer-simulator": "0.0.1",
|
|
164
164
|
"husky": "^8.0.3",
|
|
165
165
|
"istanbul-instrumenter-loader": "^3.0.1",
|
|
166
|
-
"istanbul-lib-instrument": "^
|
|
166
|
+
"istanbul-lib-instrument": "^6.0.0",
|
|
167
167
|
"jsdoc": "^4.0.2",
|
|
168
168
|
"karma": "^6.4.2",
|
|
169
169
|
"karma-chai": "^0.1.0",
|
|
@@ -180,8 +180,8 @@
|
|
|
180
180
|
"mini-css-extract-plugin": "^2.7.6",
|
|
181
181
|
"mocha": "^10.2.0",
|
|
182
182
|
"node-sass": "^9.0.0",
|
|
183
|
-
"regenerator-runtime": "^0.
|
|
184
|
-
"rollup": "^3.
|
|
183
|
+
"regenerator-runtime": "^0.14.0",
|
|
184
|
+
"rollup": "^3.27.2",
|
|
185
185
|
"rollup-plugin-delete": "^2.0.0",
|
|
186
186
|
"sass-loader": "^13.3.2",
|
|
187
187
|
"semantic-release": "^21.0.7",
|
|
@@ -191,9 +191,9 @@
|
|
|
191
191
|
"style-loader": "^3.3.3",
|
|
192
192
|
"taffydb": "^2.7.3",
|
|
193
193
|
"terser-webpack-plugin": "^5.3.9",
|
|
194
|
-
"tslib": "^2.6.
|
|
194
|
+
"tslib": "^2.6.1",
|
|
195
195
|
"typescript": "5.1.6",
|
|
196
|
-
"webpack": "^5.88.
|
|
196
|
+
"webpack": "^5.88.2",
|
|
197
197
|
"webpack-bundle-analyzer": "^4.9.0",
|
|
198
198
|
"webpack-clean": "^1.2.5",
|
|
199
199
|
"webpack-cli": "^5.1.4",
|
package/src/Chart/api/load.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {requestIdleCallback} from "../../module/browser";
|
|
6
|
-
import {isString, isArray} from "../../module/util";
|
|
6
|
+
import {isString, isArray, isEmpty} from "../../module/util";
|
|
7
7
|
import {callDone} from "../../ChartInternal/data/load";
|
|
8
8
|
|
|
9
9
|
export default {
|
|
@@ -182,7 +182,6 @@ export default {
|
|
|
182
182
|
requestIdleCallback(() => $$.loadFromArgs(args));
|
|
183
183
|
});
|
|
184
184
|
} else {
|
|
185
|
-
$$.api.tooltip.hide();
|
|
186
185
|
$$.loadFromArgs(args);
|
|
187
186
|
}
|
|
188
187
|
},
|
|
@@ -216,6 +215,9 @@ export default {
|
|
|
216
215
|
const $$ = this.internal;
|
|
217
216
|
let args = argsValue || {};
|
|
218
217
|
|
|
218
|
+
// hide possible tooltip display when data is completely unloaded
|
|
219
|
+
isEmpty(args) && this.tooltip.hide();
|
|
220
|
+
|
|
219
221
|
if (isArray(args)) {
|
|
220
222
|
args = {ids: args};
|
|
221
223
|
} else if (isString(args)) {
|
package/src/Chart/api/tooltip.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import {isDefined} from "../../module/util";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Define tooltip
|
|
@@ -48,6 +48,10 @@ const tooltip = {
|
|
|
48
48
|
* }
|
|
49
49
|
* });
|
|
50
50
|
*
|
|
51
|
+
* // for Arc types, specify 'id' or 'index'
|
|
52
|
+
* chart.tooltip.show({ data: { id: "data2" }});
|
|
53
|
+
* chart.tooltip.show({ data: { index: 2 }});
|
|
54
|
+
*
|
|
51
55
|
* // when data.xs is used
|
|
52
56
|
* chart.tooltip.show({
|
|
53
57
|
* data: {
|
|
@@ -80,7 +84,7 @@ const tooltip = {
|
|
|
80
84
|
// determine focus data
|
|
81
85
|
if (args.data) {
|
|
82
86
|
const {data} = args;
|
|
83
|
-
const y = $$.getYScaleById(data.id)(data.value);
|
|
87
|
+
const y = $$.getYScaleById(data.id)?.(data.value);
|
|
84
88
|
|
|
85
89
|
if (hasTreemap && data.id) {
|
|
86
90
|
eventReceiver.rect = $el.main.select(`${$$.selectorTarget(data.id, undefined, "rect")}`);
|
|
@@ -92,7 +96,11 @@ const tooltip = {
|
|
|
92
96
|
mouse = [0, y];
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
index =
|
|
99
|
+
index = data.index ?? (
|
|
100
|
+
$$.hasArcType() && data.id ?
|
|
101
|
+
$$.getArcElementByIdOrIndex(data.id)?.datum().index :
|
|
102
|
+
$$.getIndexByX(data.x)
|
|
103
|
+
);
|
|
96
104
|
}
|
|
97
105
|
} else if (isDefined(args.x)) {
|
|
98
106
|
index = $$.getIndexByX(args.x);
|
|
@@ -2,6 +2,7 @@
|
|
|
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";
|
|
5
6
|
import {$BAR, $CANDLESTICK, $COMMON} from "../../config/classes";
|
|
6
7
|
import {KEY} from "../../module/Cache";
|
|
7
8
|
import type {IData, IDataPoint, IDataRow} from "./IData";
|
|
@@ -664,18 +665,34 @@ export default {
|
|
|
664
665
|
*/
|
|
665
666
|
getDataIndexFromEvent(event): number {
|
|
666
667
|
const $$ = this;
|
|
667
|
-
const {config, state: {inputType, eventReceiver: {coords, rect}}} = $$;
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
668
|
+
const {config, state: {hasRadar, inputType, eventReceiver: {coords, rect}}} = $$;
|
|
669
|
+
let index;
|
|
670
|
+
|
|
671
|
+
if (hasRadar) {
|
|
672
|
+
let target = event.target;
|
|
673
|
+
|
|
674
|
+
// in case of multilined axis text
|
|
675
|
+
if (/tspan/i.test(target.tagName)) {
|
|
676
|
+
target = target.parentNode;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
const d: any = d3Select(target).datum();
|
|
680
|
+
|
|
681
|
+
index = d && Object.keys(d).length === 1 ? d.index : undefined;
|
|
682
|
+
} else {
|
|
683
|
+
const isRotated = config.axis_rotated;
|
|
684
|
+
|
|
685
|
+
// get data based on the mouse coords
|
|
686
|
+
const e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event;
|
|
687
|
+
|
|
688
|
+
index = findIndex(
|
|
689
|
+
coords,
|
|
690
|
+
isRotated ? e.clientY - rect.top : e.clientX - rect.left,
|
|
691
|
+
0,
|
|
692
|
+
coords.length - 1,
|
|
693
|
+
isRotated
|
|
694
|
+
);
|
|
695
|
+
}
|
|
679
696
|
|
|
680
697
|
return index;
|
|
681
698
|
},
|
|
@@ -61,7 +61,7 @@ export default {
|
|
|
61
61
|
$el.eventRect = eventRectUpdate;
|
|
62
62
|
|
|
63
63
|
if ($$.state.inputType === "touch" && !$el.svg.on("touchstart.eventRect") && !$$.hasArcType()) {
|
|
64
|
-
$$.bindTouchOnEventRect(
|
|
64
|
+
$$.bindTouchOnEventRect();
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// when initilazed with empty data and data loaded later, need to update eventRect
|
|
@@ -87,12 +87,12 @@ export default {
|
|
|
87
87
|
$$.updateEventRectData();
|
|
88
88
|
},
|
|
89
89
|
|
|
90
|
-
bindTouchOnEventRect(
|
|
90
|
+
bindTouchOnEventRect(): void {
|
|
91
91
|
const $$ = this;
|
|
92
92
|
const {config, state, $el: {eventRect, svg}} = $$;
|
|
93
93
|
|
|
94
94
|
const selectRect = context => {
|
|
95
|
-
if (isMultipleX) {
|
|
95
|
+
if ($$.isMultipleX()) {
|
|
96
96
|
$$.selectRectForMultipleXs(context);
|
|
97
97
|
} else {
|
|
98
98
|
const index = $$.getDataIndexFromEvent(state.event);
|
|
@@ -101,7 +101,7 @@ export default {
|
|
|
101
101
|
|
|
102
102
|
index === -1 ?
|
|
103
103
|
$$.unselectRect() :
|
|
104
|
-
$$.selectRectForSingle(context,
|
|
104
|
+
$$.selectRectForSingle(context, index);
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
|
|
@@ -313,7 +313,74 @@ export default {
|
|
|
313
313
|
});
|
|
314
314
|
},
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
/**
|
|
317
|
+
* Seletct rect for single x value
|
|
318
|
+
* @param {d3Selection} context Event rect element
|
|
319
|
+
* @param {number} index x Axis index
|
|
320
|
+
* @private
|
|
321
|
+
*/
|
|
322
|
+
selectRectForSingle(context: SVGRectElement, index: number): void {
|
|
323
|
+
const $$ = this;
|
|
324
|
+
const {config, $el: {main, circle}} = $$;
|
|
325
|
+
const isSelectionEnabled = config.data_selection_enabled;
|
|
326
|
+
const isSelectionGrouped = config.data_selection_grouped;
|
|
327
|
+
const isSelectable = config.data_selection_isselectable;
|
|
328
|
+
const isTooltipGrouped = config.tooltip_grouped;
|
|
329
|
+
const selectedData = $$.getAllValuesOnIndex(index);
|
|
330
|
+
|
|
331
|
+
if (isTooltipGrouped) {
|
|
332
|
+
$$.showTooltip(selectedData, context);
|
|
333
|
+
$$.showGridFocus?.(selectedData);
|
|
334
|
+
|
|
335
|
+
if (!isSelectionEnabled || isSelectionGrouped) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// remove possible previous focused state
|
|
341
|
+
!circle && main.selectAll(`.${$COMMON.EXPANDED}:not(.${$SHAPE.shape}-${index})`).classed($COMMON.EXPANDED, false);
|
|
342
|
+
|
|
343
|
+
const shapeAtIndex = main.selectAll(`.${$SHAPE.shape}-${index}`)
|
|
344
|
+
.classed($COMMON.EXPANDED, true)
|
|
345
|
+
.style("cursor", isSelectable ? "pointer" : null)
|
|
346
|
+
.filter(function(d) {
|
|
347
|
+
return $$.isWithinShape(this, d);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
if (shapeAtIndex.empty() && !isTooltipGrouped) {
|
|
351
|
+
$$.hideGridFocus?.();
|
|
352
|
+
$$.hideTooltip();
|
|
353
|
+
|
|
354
|
+
!isSelectionGrouped && $$.setExpand(index);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
shapeAtIndex
|
|
358
|
+
.call(selected => {
|
|
359
|
+
const d = selected.data();
|
|
360
|
+
|
|
361
|
+
if (isSelectionEnabled &&
|
|
362
|
+
(isSelectionGrouped || isSelectable?.bind($$.api)(d))
|
|
363
|
+
) {
|
|
364
|
+
context.style.cursor = "pointer";
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (!isTooltipGrouped) {
|
|
368
|
+
$$.showTooltip(d, context);
|
|
369
|
+
$$.showGridFocus?.(d);
|
|
370
|
+
$$.unexpandCircles?.();
|
|
371
|
+
|
|
372
|
+
selected.each(d => $$.setExpand(index, d.id));
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Select rect for multiple x values
|
|
379
|
+
* @param {d3Selection} context Event rect element
|
|
380
|
+
* @param {boolean} [triggerEvent=true] Whether trigger event or not
|
|
381
|
+
* @private
|
|
382
|
+
*/
|
|
383
|
+
selectRectForMultipleXs(context: SVGRectElement, triggerEvent = true): void {
|
|
317
384
|
const $$ = this;
|
|
318
385
|
const {config, state} = $$;
|
|
319
386
|
const targetsToShow = $$.filterTargetsToShow($$.data.targets);
|
|
@@ -326,7 +393,7 @@ export default {
|
|
|
326
393
|
const mouse = getPointer(state.event, context);
|
|
327
394
|
const closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
|
328
395
|
|
|
329
|
-
if (state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
|
|
396
|
+
if (triggerEvent && state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
|
|
330
397
|
config.data_onout.call($$.api, state.mouseover);
|
|
331
398
|
state.mouseover = undefined;
|
|
332
399
|
}
|
|
@@ -357,7 +424,7 @@ export default {
|
|
|
357
424
|
if ($$.isBarType(closest.id) || dist < $$.getPointSensitivity(closest)) {
|
|
358
425
|
$$.$el.svg.select(`.${$EVENT.eventRect}`).style("cursor", "pointer");
|
|
359
426
|
|
|
360
|
-
if (!state.mouseover) {
|
|
427
|
+
if (triggerEvent && !state.mouseover) {
|
|
361
428
|
config.data_onover.call($$.api, closest);
|
|
362
429
|
state.mouseover = closest;
|
|
363
430
|
}
|
|
@@ -461,7 +528,7 @@ export default {
|
|
|
461
528
|
}
|
|
462
529
|
|
|
463
530
|
index === -1 ?
|
|
464
|
-
$$.unselectRect() : $$.selectRectForSingle(this,
|
|
531
|
+
$$.unselectRect() : $$.selectRectForSingle(this, index);
|
|
465
532
|
|
|
466
533
|
// As of individual data point(or <path>) element can't bind mouseover/out event
|
|
467
534
|
// to determine current interacting element, so use 'mousemove' event instead.
|
|
@@ -10,61 +10,6 @@ import {emulateEvent, getPointer, isNumber, isObject} from "../../module/util";
|
|
|
10
10
|
import type {IArcDataRow} from "../data/IData";
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
|
-
selectRectForSingle(context, eventRect, index: number): void {
|
|
14
|
-
const $$ = this;
|
|
15
|
-
const {config, $el: {main, circle}} = $$;
|
|
16
|
-
const isSelectionEnabled = config.data_selection_enabled;
|
|
17
|
-
const isSelectionGrouped = config.data_selection_grouped;
|
|
18
|
-
const isSelectable = config.data_selection_isselectable;
|
|
19
|
-
const isTooltipGrouped = config.tooltip_grouped;
|
|
20
|
-
const selectedData = $$.getAllValuesOnIndex(index);
|
|
21
|
-
|
|
22
|
-
if (isTooltipGrouped) {
|
|
23
|
-
$$.showTooltip(selectedData, context);
|
|
24
|
-
$$.showGridFocus?.(selectedData);
|
|
25
|
-
|
|
26
|
-
if (!isSelectionEnabled || isSelectionGrouped) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// remove possible previous focused state
|
|
32
|
-
!circle && main.selectAll(`.${$COMMON.EXPANDED}:not(.${$SHAPE.shape}-${index})`).classed($COMMON.EXPANDED, false);
|
|
33
|
-
|
|
34
|
-
const shapeAtIndex = main.selectAll(`.${$SHAPE.shape}-${index}`)
|
|
35
|
-
.classed($COMMON.EXPANDED, true)
|
|
36
|
-
.style("cursor", isSelectable ? "pointer" : null)
|
|
37
|
-
.filter(function(d) {
|
|
38
|
-
return $$.isWithinShape(this, d);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (shapeAtIndex.empty() && !isTooltipGrouped) {
|
|
42
|
-
$$.hideGridFocus?.();
|
|
43
|
-
$$.hideTooltip();
|
|
44
|
-
|
|
45
|
-
!isSelectionGrouped && $$.setExpand(index);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
shapeAtIndex
|
|
49
|
-
.call(selected => {
|
|
50
|
-
const d = selected.data();
|
|
51
|
-
|
|
52
|
-
if (isSelectionEnabled &&
|
|
53
|
-
(isSelectionGrouped || isSelectable?.bind($$.api)(d))
|
|
54
|
-
) {
|
|
55
|
-
eventRect.style("cursor", "pointer");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!isTooltipGrouped) {
|
|
59
|
-
$$.showTooltip(d, context);
|
|
60
|
-
$$.showGridFocus?.(d);
|
|
61
|
-
$$.unexpandCircles?.();
|
|
62
|
-
|
|
63
|
-
selected.each(d => $$.setExpand(index, d.id));
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
|
|
68
13
|
/**
|
|
69
14
|
* Expand data shape/point
|
|
70
15
|
* @param {number} index Index number
|
|
@@ -225,11 +170,11 @@ export default {
|
|
|
225
170
|
const $$ = this;
|
|
226
171
|
const {config, state: {
|
|
227
172
|
eventReceiver, hasAxis, hasRadar, hasTreemap
|
|
228
|
-
}, $el: {eventRect,
|
|
173
|
+
}, $el: {eventRect, radar, treemap}} = $$;
|
|
229
174
|
const element = (
|
|
230
175
|
(hasTreemap && eventReceiver.rect) ||
|
|
231
176
|
(hasRadar && radar.axes.select(`.${$AXIS.axis}-${index} text`)) || (
|
|
232
|
-
eventRect ||
|
|
177
|
+
eventRect || $$.getArcElementByIdOrIndex?.(index)
|
|
233
178
|
)
|
|
234
179
|
)?.node();
|
|
235
180
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
6
|
import {document} from "../../module/browser";
|
|
7
7
|
import {$ARC, $TOOLTIP} from "../../config/classes";
|
|
8
|
-
import type {IDataRow} from "../data/IData";
|
|
8
|
+
import type {IArcData, IDataRow} from "../data/IData";
|
|
9
9
|
import {getPointer, isFunction, isObject, isString, isValue, callFn, sanitise, tplProcess, isUndefined, parseDate} from "../../module/util";
|
|
10
10
|
|
|
11
11
|
export default {
|
|
@@ -270,7 +270,7 @@ export default {
|
|
|
270
270
|
const datum = tooltip.datum();
|
|
271
271
|
|
|
272
272
|
if (!bindto && datum) {
|
|
273
|
-
const [x, y] = getPointer(state.event, eventTarget ?? eventRect
|
|
273
|
+
const [x, y] = getPointer(state.event, eventTarget ?? eventRect?.node()); // get mouse event position
|
|
274
274
|
const currPos: {x: number, y: number, xAxis?: number} = {x, y};
|
|
275
275
|
|
|
276
276
|
if (scale.x && datum && "x" in datum) {
|
|
@@ -494,5 +494,61 @@ export default {
|
|
|
494
494
|
}
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Update tooltip content on redraw
|
|
501
|
+
* - In a situation where tooltip is displayed and data load happens, it should reflect loaded data to tooltip
|
|
502
|
+
* @param {d3Selection} context Event rect element
|
|
503
|
+
* @param {number} index Data index
|
|
504
|
+
* @private
|
|
505
|
+
*/
|
|
506
|
+
updateTooltipOnRedraw(context?: SVGRectElement, index?: number): void {
|
|
507
|
+
const $$ = this;
|
|
508
|
+
const {
|
|
509
|
+
config,
|
|
510
|
+
$el: {eventRect, svg, tooltip},
|
|
511
|
+
state: {event, hasAxis, hasRadar, hasTreemap}
|
|
512
|
+
} = $$;
|
|
513
|
+
|
|
514
|
+
// Update tooltip, when tooltip is in shown state
|
|
515
|
+
if (tooltip?.style("display") === "block" && event) {
|
|
516
|
+
const rect = context ?? (hasRadar ? svg : eventRect)?.node();
|
|
517
|
+
|
|
518
|
+
// for Axis based & Radar
|
|
519
|
+
if (hasAxis || hasRadar) {
|
|
520
|
+
if ($$.isMultipleX()) {
|
|
521
|
+
$$.selectRectForMultipleXs(rect, false);
|
|
522
|
+
} else {
|
|
523
|
+
const idx = index ?? $$.getDataIndexFromEvent(event);
|
|
524
|
+
|
|
525
|
+
if (index === -1) {
|
|
526
|
+
$$.api.tooltip.hide();
|
|
527
|
+
} else {
|
|
528
|
+
$$.selectRectForSingle(rect, idx);
|
|
529
|
+
$$.setExpand(idx, null, true);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// for Arc & Treemap
|
|
534
|
+
} else {
|
|
535
|
+
const {clientX, clientY} = event;
|
|
536
|
+
|
|
537
|
+
setTimeout(() => {
|
|
538
|
+
let target = document.elementFromPoint(clientX, clientY);
|
|
539
|
+
const data = d3Select(target).datum() as IArcData;
|
|
540
|
+
|
|
541
|
+
if (data) {
|
|
542
|
+
const d = $$.hasArcType() ?
|
|
543
|
+
$$.convertToArcData($$.updateAngle(data)) : data?.data;
|
|
544
|
+
|
|
545
|
+
hasTreemap && (target = svg.node());
|
|
546
|
+
d && $$.showTooltip([d], target);
|
|
547
|
+
} else {
|
|
548
|
+
$$.api.tooltip.hide();
|
|
549
|
+
}
|
|
550
|
+
}, config.transition_duration);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
497
553
|
}
|
|
498
554
|
};
|
|
@@ -114,14 +114,24 @@ function getRadiusFn(expandRate = 0) {
|
|
|
114
114
|
*/
|
|
115
115
|
function getAttrTweenFn(fn: (d: IArcData) => string) {
|
|
116
116
|
return function(d: IArcData): (t: number) => string {
|
|
117
|
-
const
|
|
117
|
+
const getAngleKeyValue = ({startAngle = 0, endAngle = 0, padAngle = 0}) => ({
|
|
118
|
+
startAngle, endAngle, padAngle
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// d3.interpolate interpolates id value, if id is given as color string(ex. gold, silver, etc)
|
|
122
|
+
// to avoid unexpected behavior, interpolate only angle values
|
|
123
|
+
// https://github.com/naver/billboard.js/issues/3321
|
|
124
|
+
const interpolate = d3Interpolate(
|
|
125
|
+
getAngleKeyValue(this._current), getAngleKeyValue(d)
|
|
126
|
+
);
|
|
118
127
|
|
|
119
128
|
this._current = d;
|
|
120
129
|
|
|
121
130
|
return function(t: number): string {
|
|
122
|
-
const interpolated = interpolate(t);
|
|
131
|
+
const interpolated = interpolate(t) as IArcData;
|
|
132
|
+
const {data, index, value} = d;
|
|
123
133
|
|
|
124
|
-
return fn(interpolated);
|
|
134
|
+
return fn({...interpolated, data, index, value});
|
|
125
135
|
};
|
|
126
136
|
};
|
|
127
137
|
}
|
|
@@ -310,7 +320,7 @@ export default {
|
|
|
310
320
|
.innerRadius(inner)
|
|
311
321
|
.outerRadius(outer);
|
|
312
322
|
|
|
313
|
-
const newArc = function(d, withoutUpdate) {
|
|
323
|
+
const newArc = function(d: IArcData, withoutUpdate) {
|
|
314
324
|
let path: string | null = "M 0 0";
|
|
315
325
|
|
|
316
326
|
if (d.value || d.data) {
|
|
@@ -694,7 +704,8 @@ export default {
|
|
|
694
704
|
.style("opacity", "0")
|
|
695
705
|
.remove();
|
|
696
706
|
|
|
697
|
-
mainArc = mainArc.enter()
|
|
707
|
+
mainArc = mainArc.enter()
|
|
708
|
+
.append("path")
|
|
698
709
|
.attr("class", $$.getClass("arc", true))
|
|
699
710
|
.style("fill", d => $$.color(d.data))
|
|
700
711
|
.style("cursor", d => (isSelectable?.bind?.($$.api)(d) ? "pointer" : null))
|
|
@@ -771,7 +782,7 @@ export default {
|
|
|
771
782
|
.call(endall, function() {
|
|
772
783
|
if ($$.levelColor) {
|
|
773
784
|
const path = d3Select(this);
|
|
774
|
-
const d: any = path.datum();
|
|
785
|
+
const d: any = path.datum(this._current);
|
|
775
786
|
|
|
776
787
|
$$.updateLegendItemColor(d.data.id, path.style("fill"));
|
|
777
788
|
}
|
|
@@ -1109,5 +1120,22 @@ export default {
|
|
|
1109
1120
|
.text($$.textForGaugeMinMax(config.gauge_max, true));
|
|
1110
1121
|
}
|
|
1111
1122
|
}
|
|
1123
|
+
},
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Get Arc element by id or index
|
|
1127
|
+
* @param {string|number} value id or index of Arc
|
|
1128
|
+
* @returns {d3Selection} Arc path element
|
|
1129
|
+
* @private
|
|
1130
|
+
*/
|
|
1131
|
+
getArcElementByIdOrIndex(value: string | number): d3Selection {
|
|
1132
|
+
const $$ = this;
|
|
1133
|
+
const {$el: {arcs}} = $$;
|
|
1134
|
+
const filterFn = isNumber(value) ?
|
|
1135
|
+
d => d.index === value :
|
|
1136
|
+
d => d.data.id === value;
|
|
1137
|
+
|
|
1138
|
+
return arcs?.selectAll(`.${$COMMON.target} path`)
|
|
1139
|
+
.filter(filterFn);
|
|
1112
1140
|
}
|
|
1113
1141
|
};
|
|
@@ -301,22 +301,13 @@ export default {
|
|
|
301
301
|
|
|
302
302
|
if (config.interaction_enabled) {
|
|
303
303
|
const isMouse = inputType === "mouse";
|
|
304
|
-
const getIndex = event => {
|
|
305
|
-
let target = event.target;
|
|
306
304
|
|
|
307
|
-
// in case of multilined axis text
|
|
308
|
-
if (/tspan/i.test(target.tagName)) {
|
|
309
|
-
target = target.parentNode;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
const d: any = d3Select(target).datum();
|
|
313
|
-
|
|
314
|
-
return d && Object.keys(d).length === 1 ? d.index : undefined;
|
|
315
|
-
};
|
|
316
305
|
const hide = event => {
|
|
317
306
|
state.event = event;
|
|
318
307
|
|
|
319
|
-
const index = getIndex(event);
|
|
308
|
+
// const index = getIndex(event);
|
|
309
|
+
|
|
310
|
+
const index = $$.getDataIndexFromEvent(event);
|
|
320
311
|
const noIndex = isUndefined(index);
|
|
321
312
|
|
|
322
313
|
if (isMouse || noIndex) {
|
|
@@ -341,9 +332,9 @@ export default {
|
|
|
341
332
|
}
|
|
342
333
|
|
|
343
334
|
state.event = event;
|
|
344
|
-
const index =
|
|
335
|
+
const index = $$.getDataIndexFromEvent(event);
|
|
345
336
|
|
|
346
|
-
$$.selectRectForSingle(svg.node(),
|
|
337
|
+
$$.selectRectForSingle(svg.node(), index);
|
|
347
338
|
isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
|
|
348
339
|
})
|
|
349
340
|
.on("mouseout", isMouse ? hide : null);
|