billboard.js 3.9.1 → 3.9.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/dist/billboard.css +1 -1
- package/dist/billboard.js +225 -131
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +1109 -294
- 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 +886 -165
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +887 -166
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +888 -167
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +888 -167
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +888 -167
- 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 +175 -86
- 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 +17 -17
- 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 +20 -2
- package/src/ChartInternal/shape/line.ts +0 -1
- package/src/ChartInternal/shape/radar.ts +5 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billboard.js",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2",
|
|
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.9",
|
|
106
|
+
"@babel/eslint-parser": "^7.22.9",
|
|
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.9",
|
|
110
|
+
"@babel/preset-env": "^7.22.9",
|
|
111
111
|
"@babel/preset-typescript": "^7.22.5",
|
|
112
112
|
"@babel/runtime": "^7.22.6",
|
|
113
|
-
"@commitlint/cli": "17.6.
|
|
114
|
-
"@commitlint/config-conventional": "^17.6.
|
|
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",
|
|
@@ -126,8 +126,8 @@
|
|
|
126
126
|
"@types/d3": "^7.4.0",
|
|
127
127
|
"@types/mocha": "^10.0.1",
|
|
128
128
|
"@types/sinon": "^10.0.15",
|
|
129
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
130
|
-
"@typescript-eslint/parser": "^6.
|
|
129
|
+
"@typescript-eslint/eslint-plugin": "^6.2.1",
|
|
130
|
+
"@typescript-eslint/parser": "^6.2.1",
|
|
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.5",
|
|
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",
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
"mocha": "^10.2.0",
|
|
182
182
|
"node-sass": "^9.0.0",
|
|
183
183
|
"regenerator-runtime": "^0.13.11",
|
|
184
|
-
"rollup": "^3.
|
|
184
|
+
"rollup": "^3.27.0",
|
|
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
|
};
|
|
@@ -694,7 +694,8 @@ export default {
|
|
|
694
694
|
.style("opacity", "0")
|
|
695
695
|
.remove();
|
|
696
696
|
|
|
697
|
-
mainArc = mainArc.enter()
|
|
697
|
+
mainArc = mainArc.enter()
|
|
698
|
+
.append("path")
|
|
698
699
|
.attr("class", $$.getClass("arc", true))
|
|
699
700
|
.style("fill", d => $$.color(d.data))
|
|
700
701
|
.style("cursor", d => (isSelectable?.bind?.($$.api)(d) ? "pointer" : null))
|
|
@@ -771,7 +772,7 @@ export default {
|
|
|
771
772
|
.call(endall, function() {
|
|
772
773
|
if ($$.levelColor) {
|
|
773
774
|
const path = d3Select(this);
|
|
774
|
-
const d: any = path.datum();
|
|
775
|
+
const d: any = path.datum(this._current);
|
|
775
776
|
|
|
776
777
|
$$.updateLegendItemColor(d.data.id, path.style("fill"));
|
|
777
778
|
}
|
|
@@ -1109,5 +1110,22 @@ export default {
|
|
|
1109
1110
|
.text($$.textForGaugeMinMax(config.gauge_max, true));
|
|
1110
1111
|
}
|
|
1111
1112
|
}
|
|
1113
|
+
},
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* Get Arc element by id or index
|
|
1117
|
+
* @param {string|number} value id or index of Arc
|
|
1118
|
+
* @returns {d3Selection} Arc path element
|
|
1119
|
+
* @private
|
|
1120
|
+
*/
|
|
1121
|
+
getArcElementByIdOrIndex(value: string | number): d3Selection {
|
|
1122
|
+
const $$ = this;
|
|
1123
|
+
const {$el: {arcs}} = $$;
|
|
1124
|
+
const filterFn = isNumber(value) ?
|
|
1125
|
+
d => d.index === value :
|
|
1126
|
+
d => d.data.id === value;
|
|
1127
|
+
|
|
1128
|
+
return arcs?.selectAll(`.${$COMMON.target} path`)
|
|
1129
|
+
.filter(filterFn);
|
|
1112
1130
|
}
|
|
1113
1131
|
};
|
|
@@ -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);
|