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
|
@@ -3,8 +3,20 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {TYPE, TYPE_BY_CATEGORY} from "../../config/const";
|
|
6
|
+
import {
|
|
7
|
+
brushEmpty,
|
|
8
|
+
diffDomain,
|
|
9
|
+
getBrushSelection,
|
|
10
|
+
getMinMax,
|
|
11
|
+
isDefined,
|
|
12
|
+
isNumber,
|
|
13
|
+
isObject,
|
|
14
|
+
isValue,
|
|
15
|
+
notEmpty,
|
|
16
|
+
parseDate,
|
|
17
|
+
sortValue
|
|
18
|
+
} from "../../module/util";
|
|
6
19
|
import type {IData, TDomainRange} from "../data/IData";
|
|
7
|
-
import {brushEmpty, getBrushSelection, getMinMax, isDefined, notEmpty, isValue, isObject, isNumber, diffDomain, parseDate, sortValue} from "../../module/util";
|
|
8
20
|
|
|
9
21
|
export default {
|
|
10
22
|
getYDomainMinMax(targets, type: "min" | "max"): number | Date | undefined {
|
|
@@ -88,8 +100,7 @@ export default {
|
|
|
88
100
|
return scale[axisId].domain();
|
|
89
101
|
} else {
|
|
90
102
|
return axisId === "y2" ?
|
|
91
|
-
scale.y.domain() :
|
|
92
|
-
// When all data bounds to y2, y Axis domain is called prior y2.
|
|
103
|
+
scale.y.domain() : // When all data bounds to y2, y Axis domain is called prior y2.
|
|
93
104
|
// So, it needs to call to get y2 domain here
|
|
94
105
|
$$.getYDomain(targets, "y2", xDomain);
|
|
95
106
|
}
|
|
@@ -114,15 +125,19 @@ export default {
|
|
|
114
125
|
|
|
115
126
|
// MEMO: avoid inverting domain unexpectedly
|
|
116
127
|
yDomainMin = isValue(yMin) ? yMin : (
|
|
117
|
-
isValue(yMax) ?
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
isValue(yMax) ?
|
|
129
|
+
(
|
|
130
|
+
yDomainMin <= yMax ? yDomainMin : yMax - 10
|
|
131
|
+
) :
|
|
132
|
+
yDomainMin
|
|
120
133
|
);
|
|
121
134
|
|
|
122
135
|
yDomainMax = isValue(yMax) ? yMax : (
|
|
123
|
-
isValue(yMin) ?
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
isValue(yMin) ?
|
|
137
|
+
(
|
|
138
|
+
yMin <= yDomainMax ? yDomainMax : yMin + 10
|
|
139
|
+
) :
|
|
140
|
+
yDomainMax
|
|
126
141
|
);
|
|
127
142
|
|
|
128
143
|
if (isNaN(yDomainMin)) { // set minimum to zero when not number
|
|
@@ -196,7 +211,8 @@ export default {
|
|
|
196
211
|
isAllNegative && (padding.top = -yDomainMax);
|
|
197
212
|
}
|
|
198
213
|
|
|
199
|
-
const domain = isLog ?
|
|
214
|
+
const domain = isLog ?
|
|
215
|
+
[yDomainMin, yDomainMax].map(v => (v < 0 ? 0 : v)) :
|
|
200
216
|
[yDomainMin - padding.bottom, yDomainMax + padding.top];
|
|
201
217
|
|
|
202
218
|
return isInverted ? domain.reverse() : domain;
|
|
@@ -205,14 +221,17 @@ export default {
|
|
|
205
221
|
getXDomainMinMax(targets, type) {
|
|
206
222
|
const $$ = this;
|
|
207
223
|
const configValue = $$.config[`axis_x_${type}`];
|
|
208
|
-
const dataValue = getMinMax(type,
|
|
224
|
+
const dataValue = getMinMax(type,
|
|
225
|
+
targets.map(t => getMinMax(type, t.values.map(v => v.x))));
|
|
209
226
|
let value = isObject(configValue) ? configValue.value : configValue;
|
|
210
227
|
|
|
211
228
|
value = isDefined(value) && $$.axis?.isTimeSeries() ? parseDate.bind(this)(value) : value;
|
|
212
229
|
|
|
213
|
-
if (
|
|
214
|
-
(
|
|
215
|
-
|
|
230
|
+
if (
|
|
231
|
+
isObject(configValue) && configValue.fit && (
|
|
232
|
+
(type === "min" && value < dataValue) || (type === "max" && value > dataValue)
|
|
233
|
+
)
|
|
234
|
+
) {
|
|
216
235
|
value = undefined;
|
|
217
236
|
}
|
|
218
237
|
|
|
@@ -246,7 +265,8 @@ export default {
|
|
|
246
265
|
}
|
|
247
266
|
|
|
248
267
|
let {left = defaultValue, right = defaultValue} = isNumber(padding) ?
|
|
249
|
-
{left: padding, right: padding} :
|
|
268
|
+
{left: padding, right: padding} :
|
|
269
|
+
padding;
|
|
250
270
|
|
|
251
271
|
// when the unit is pixel, convert pixels to axis scale value
|
|
252
272
|
if (padding.unit === "px") {
|
|
@@ -274,7 +294,7 @@ export default {
|
|
|
274
294
|
* @returns {Array} x Axis domain
|
|
275
295
|
* @private
|
|
276
296
|
*/
|
|
277
|
-
getXDomain(targets: IData[]): (Date|number)[] {
|
|
297
|
+
getXDomain(targets: IData[]): (Date | number)[] {
|
|
278
298
|
const $$ = this;
|
|
279
299
|
const {axis, config, scale: {x}} = $$;
|
|
280
300
|
const isInverted = config.axis_x_inverted;
|
|
@@ -302,11 +322,15 @@ export default {
|
|
|
302
322
|
}
|
|
303
323
|
|
|
304
324
|
if (firstX || firstX === 0) {
|
|
305
|
-
min = isTimeSeries ?
|
|
325
|
+
min = isTimeSeries ?
|
|
326
|
+
new Date(firstX.getTime() - padding.left) :
|
|
327
|
+
firstX - padding.left;
|
|
306
328
|
}
|
|
307
329
|
|
|
308
330
|
if (lastX || lastX === 0) {
|
|
309
|
-
max = isTimeSeries ?
|
|
331
|
+
max = isTimeSeries ?
|
|
332
|
+
new Date(lastX.getTime() + padding.right) :
|
|
333
|
+
lastX + padding.right;
|
|
310
334
|
}
|
|
311
335
|
}
|
|
312
336
|
|
|
@@ -330,7 +354,8 @@ export default {
|
|
|
330
354
|
|
|
331
355
|
if (withUpdateXDomain) {
|
|
332
356
|
const domainValue = domain || (!$$.brush || brushEmpty($$)) ?
|
|
333
|
-
org.xDomain :
|
|
357
|
+
org.xDomain :
|
|
358
|
+
getBrushSelection($$).map(subX.invert);
|
|
334
359
|
|
|
335
360
|
x.domain(domainValue);
|
|
336
361
|
// zoomEnabled && $$.zoom.updateScaleExtent();
|
|
@@ -411,7 +436,9 @@ export default {
|
|
|
411
436
|
const isInverted = config.axis_x_inverted;
|
|
412
437
|
|
|
413
438
|
// need to add offset to original value for 'category' type
|
|
414
|
-
const domain = domainValue.map((v, i) =>
|
|
439
|
+
const domain = domainValue.map((v, i) =>
|
|
440
|
+
Number(v) + (i === 0 ? +isInverted : +!isInverted)
|
|
441
|
+
);
|
|
415
442
|
|
|
416
443
|
return domain as T;
|
|
417
444
|
}
|
|
@@ -427,7 +454,7 @@ export default {
|
|
|
427
454
|
* @returns {number}
|
|
428
455
|
* @private
|
|
429
456
|
*/
|
|
430
|
-
convertPixelToScale(type: "x"|"y", pixels: number, domainLength: number): number {
|
|
457
|
+
convertPixelToScale(type: "x" | "y", pixels: number, domainLength: number): number {
|
|
431
458
|
const $$ = this;
|
|
432
459
|
const {config, state} = $$;
|
|
433
460
|
const isRotated = config.axis_rotated;
|
|
@@ -461,13 +488,17 @@ export default {
|
|
|
461
488
|
isInverted && target.reverse();
|
|
462
489
|
|
|
463
490
|
if (target[0] < target[1]) {
|
|
464
|
-
return domain.every((v, i) =>
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
491
|
+
return domain.every((v, i) =>
|
|
492
|
+
(
|
|
493
|
+
i === 0 ?
|
|
494
|
+
(
|
|
495
|
+
isInverted ? +v <= min : +v >= min
|
|
496
|
+
) :
|
|
497
|
+
(
|
|
498
|
+
isInverted ? +v >= max : +v <= max
|
|
499
|
+
)
|
|
500
|
+
) && !(domain.every((v, i) => v === current[i]))
|
|
501
|
+
);
|
|
471
502
|
}
|
|
472
503
|
}
|
|
473
504
|
|
|
@@ -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 {isArray, isValue, isFunction, isObjectType, isObject} from "../../module/util";
|
|
6
5
|
import type {AxisType} from "../../../types/types";
|
|
6
|
+
import {isArray, isFunction, isObject, isObjectType, isValue} from "../../module/util";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Get formatted
|
|
@@ -16,8 +16,7 @@ import type {AxisType} from "../../../types/types";
|
|
|
16
16
|
function getFormat($$, typeValue: AxisType, v: number): number | string {
|
|
17
17
|
const {config} = $$;
|
|
18
18
|
const type = `axis_${typeValue}_tick_format`;
|
|
19
|
-
const format = config[type] ?
|
|
20
|
-
config[type] : $$.defaultValueFormat;
|
|
19
|
+
const format = config[type] ? config[type] : $$.defaultValueFormat;
|
|
21
20
|
|
|
22
21
|
return format.call($$.api, v);
|
|
23
22
|
}
|
|
@@ -50,7 +49,7 @@ export default {
|
|
|
50
49
|
};
|
|
51
50
|
},
|
|
52
51
|
|
|
53
|
-
defaultValueFormat(v: number|number[]): number|string {
|
|
52
|
+
defaultValueFormat(v: number | number[]): number | string {
|
|
54
53
|
return isArray(v) ? v.join("~") : (isValue(v) ? +v : "");
|
|
55
54
|
},
|
|
56
55
|
|
|
@@ -85,7 +84,8 @@ export default {
|
|
|
85
84
|
} else if (isObjectType(dataLabels.format)) {
|
|
86
85
|
if (dataLabels.format[targetId]) {
|
|
87
86
|
format = dataLabels.format[targetId] === true ?
|
|
88
|
-
defaultFormat :
|
|
87
|
+
defaultFormat :
|
|
88
|
+
dataLabels.format[targetId];
|
|
89
89
|
} else {
|
|
90
90
|
format = () => "";
|
|
91
91
|
}
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
selectAll as d3SelectAll
|
|
8
|
-
} from "d3-selection";
|
|
5
|
+
import {select as d3Select, selectAll as d3SelectAll} from "d3-selection";
|
|
6
|
+
import type {d3Selection} from "../../../types/types";
|
|
9
7
|
import {$AXIS, $COMMON, $FOCUS, $GRID} from "../../config/classes";
|
|
10
|
-
import {isArray, isValue} from "../../module/util";
|
|
8
|
+
import {getPointer, isArray, isValue} from "../../module/util";
|
|
11
9
|
|
|
12
10
|
// Grid position and text anchor helpers
|
|
13
11
|
const getGridTextAnchor = d => isValue(d.position) || "end";
|
|
@@ -72,7 +70,8 @@ export default {
|
|
|
72
70
|
const {config, state: {clip}, $el} = $$;
|
|
73
71
|
|
|
74
72
|
if (config.grid_x_lines.length || config.grid_y_lines.length) {
|
|
75
|
-
$el.gridLines.main = $el.main.insert("g",
|
|
73
|
+
$el.gridLines.main = $el.main.insert("g",
|
|
74
|
+
`.${$COMMON.chart}${config.grid_lines_front ? " + *" : ""}`)
|
|
76
75
|
.attr("clip-path", clip.pathGrid)
|
|
77
76
|
.attr("class", `${$GRID.grid} ${$GRID.gridLines}`);
|
|
78
77
|
|
|
@@ -89,21 +88,24 @@ export default {
|
|
|
89
88
|
const isRotated = config.axis_rotated;
|
|
90
89
|
const xgridData = $$.generateGridData(config.grid_x_type, scale.x);
|
|
91
90
|
const tickOffset = $$.axis.isCategorized() ? $$.axis.x.tickOffset() : 0;
|
|
92
|
-
const pos = d =>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
const pos = d =>
|
|
92
|
+
(scale.zoom || scale.x)(d) + (
|
|
93
|
+
tickOffset * (isRotated ? -1 : 1)
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
state.xgridAttr = isRotated ?
|
|
97
|
+
{
|
|
98
|
+
x1: 0,
|
|
99
|
+
x2: state.width,
|
|
100
|
+
y1: pos,
|
|
101
|
+
y2: pos
|
|
102
|
+
} :
|
|
103
|
+
{
|
|
104
|
+
x1: pos,
|
|
105
|
+
x2: pos,
|
|
106
|
+
y1: 0,
|
|
107
|
+
y2: state.height
|
|
108
|
+
};
|
|
107
109
|
|
|
108
110
|
grid.x = main.select(`.${$GRID.xgrids}`)
|
|
109
111
|
.selectAll(`.${$GRID.xgrid}`)
|
|
@@ -124,7 +126,8 @@ export default {
|
|
|
124
126
|
grid.attr(id, state.xgridAttr[id])
|
|
125
127
|
.style("opacity", () => (
|
|
126
128
|
grid.attr(isRotated ? "y1" : "x1") === (isRotated ? state.height : 0) ?
|
|
127
|
-
"0" :
|
|
129
|
+
"0" :
|
|
130
|
+
null
|
|
128
131
|
));
|
|
129
132
|
});
|
|
130
133
|
});
|
|
@@ -136,8 +139,8 @@ export default {
|
|
|
136
139
|
const {axis, config, scale, state, $el: {grid, main}} = $$;
|
|
137
140
|
const isRotated = config.axis_rotated;
|
|
138
141
|
const pos = d => Math.ceil(scale.y(d));
|
|
139
|
-
const gridValues =
|
|
140
|
-
|
|
142
|
+
const gridValues = axis.y.getGeneratedTicks(config.grid_y_ticks) ||
|
|
143
|
+
$$.scale.y.ticks(config.grid_y_ticks);
|
|
141
144
|
|
|
142
145
|
grid.y = main.select(`.${$GRID.ygrids}`)
|
|
143
146
|
.selectAll(`.${$GRID.ygrid}`)
|
|
@@ -216,13 +219,12 @@ export default {
|
|
|
216
219
|
.attr("class", d => `${$GRID[`${type}gridLine`]} ${d.class || ""}`.trim())
|
|
217
220
|
.select("text")
|
|
218
221
|
.attr("text-anchor", getGridTextAnchor)
|
|
219
|
-
.attr("transform",
|
|
220
|
-
(
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
.attr("transform",
|
|
223
|
+
() => (isX ?
|
|
224
|
+
(isRotated ? null : "rotate(-90)") :
|
|
225
|
+
(isRotated ? "rotate(-90)" : null)))
|
|
223
226
|
.attr("dx", getGridTextDx)
|
|
224
|
-
.attr("dy", -5)
|
|
225
|
-
)
|
|
227
|
+
.attr("dy", -5))
|
|
226
228
|
.text(function(d) {
|
|
227
229
|
return d.text ?? this.remove();
|
|
228
230
|
});
|
|
@@ -279,7 +281,9 @@ export default {
|
|
|
279
281
|
const $$ = this;
|
|
280
282
|
const {config, state: {clip}, $el} = $$;
|
|
281
283
|
const isFront = config.grid_front;
|
|
282
|
-
const className = `.${isFront && $el.gridLines.main ? $GRID.gridLines : $COMMON.chart}${
|
|
284
|
+
const className = `.${isFront && $el.gridLines.main ? $GRID.gridLines : $COMMON.chart}${
|
|
285
|
+
isFront ? " + *" : ""
|
|
286
|
+
}`;
|
|
283
287
|
|
|
284
288
|
const grid = $el.main.insert("g", className)
|
|
285
289
|
.attr("clip-path", clip.pathGrid)
|
|
@@ -293,7 +297,14 @@ export default {
|
|
|
293
297
|
config.grid_y_show &&
|
|
294
298
|
grid.append("g").attr("class", $GRID.ygrids);
|
|
295
299
|
|
|
296
|
-
if (config.
|
|
300
|
+
if (config.axis_tooltip) {
|
|
301
|
+
const axis = grid.append("g").attr("class", "bb-axis-tooltip");
|
|
302
|
+
|
|
303
|
+
axis.append("line").attr("class", "bb-axis-tooltip-x");
|
|
304
|
+
axis.append("line").attr("class", "bb-axis-tooltip-y");
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (config.interaction_enabled && config.grid_focus_show && !config.axis_tooltip) {
|
|
297
308
|
grid.append("g")
|
|
298
309
|
.attr("class", $FOCUS.xgridFocus)
|
|
299
310
|
.append("line")
|
|
@@ -309,6 +320,64 @@ export default {
|
|
|
309
320
|
}
|
|
310
321
|
},
|
|
311
322
|
|
|
323
|
+
showAxisGridFocus() {
|
|
324
|
+
const $$ = this;
|
|
325
|
+
const {config, format, state: {event, width, height}} = $$;
|
|
326
|
+
const isRotated = config.axis_rotated;
|
|
327
|
+
|
|
328
|
+
// get mouse event position
|
|
329
|
+
const [x, y] = getPointer(event, $$.$el.eventRect?.node());
|
|
330
|
+
const pos = {x, y};
|
|
331
|
+
|
|
332
|
+
for (const [axis, node] of Object.entries($$.$el.axisTooltip)) {
|
|
333
|
+
const attr = (axis === "x" && !isRotated) || (axis !== "x" && isRotated) ? "x" : "y";
|
|
334
|
+
const value = pos[attr];
|
|
335
|
+
let scaleText = $$.scale[axis]?.invert(value);
|
|
336
|
+
|
|
337
|
+
if (scaleText) {
|
|
338
|
+
scaleText = axis === "x" && $$.axis.isTimeSeries() ?
|
|
339
|
+
format.xAxisTick(scaleText) :
|
|
340
|
+
scaleText?.toFixed(2);
|
|
341
|
+
|
|
342
|
+
// set position & its text value based on position
|
|
343
|
+
(node as d3Selection)?.attr(attr, value)
|
|
344
|
+
.text(scaleText);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
$$.$el.main.selectAll(
|
|
349
|
+
`line.bb-axis-tooltip-x, line.bb-axis-tooltip-y`
|
|
350
|
+
).style("visibility", null)
|
|
351
|
+
.each(function(d, i) {
|
|
352
|
+
const line = d3Select(this);
|
|
353
|
+
|
|
354
|
+
if (i === 0) {
|
|
355
|
+
line
|
|
356
|
+
.attr("x1", x)
|
|
357
|
+
.attr("x2", x)
|
|
358
|
+
.attr("y1", i ? 0 : height)
|
|
359
|
+
.attr("y2", i ? height : 0);
|
|
360
|
+
} else {
|
|
361
|
+
line
|
|
362
|
+
.attr("x1", i ? 0 : width)
|
|
363
|
+
.attr("x2", i ? width : 0)
|
|
364
|
+
.attr("y1", y)
|
|
365
|
+
.attr("y2", y);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
hideAxisGridFocus() {
|
|
371
|
+
const $$ = this;
|
|
372
|
+
|
|
373
|
+
$$.$el.main.selectAll(
|
|
374
|
+
`line.bb-axis-tooltip-x, line.bb-axis-tooltip-y`
|
|
375
|
+
).style("visibility", "hidden");
|
|
376
|
+
|
|
377
|
+
Object.values($$.$el.axisTooltip)
|
|
378
|
+
.forEach((v: d3Selection) => v?.style("display", "none"));
|
|
379
|
+
},
|
|
380
|
+
|
|
312
381
|
/**
|
|
313
382
|
* Show grid focus line
|
|
314
383
|
* @param {Array} data Selected data
|
|
@@ -318,12 +387,20 @@ export default {
|
|
|
318
387
|
const $$ = this;
|
|
319
388
|
const {config, state: {width, height}} = $$;
|
|
320
389
|
const isRotated = config.axis_rotated;
|
|
321
|
-
const focusEl = $$.$el.main.selectAll(
|
|
390
|
+
const focusEl = $$.$el.main.selectAll(
|
|
391
|
+
`line.${$FOCUS.xgridFocus}, line.${$FOCUS.ygridFocus}`
|
|
392
|
+
);
|
|
322
393
|
|
|
323
|
-
const dataToShow = (data || [focusEl.datum()]).filter(d =>
|
|
394
|
+
const dataToShow = (data || [focusEl.datum()]).filter(d =>
|
|
395
|
+
d && isValue($$.getBaseValue(d))
|
|
396
|
+
);
|
|
324
397
|
|
|
325
398
|
// Hide when bubble/scatter/stanford plot exists
|
|
326
|
-
if (
|
|
399
|
+
if (
|
|
400
|
+
!config.tooltip_show || dataToShow.length === 0 || (
|
|
401
|
+
!config.axis_x_forceAsSingle && $$.hasType("bubble")
|
|
402
|
+
) || $$.hasArcType()
|
|
403
|
+
) {
|
|
327
404
|
return;
|
|
328
405
|
}
|
|
329
406
|
|
|
@@ -349,7 +426,8 @@ export default {
|
|
|
349
426
|
pos.x, // y1
|
|
350
427
|
isEdge ? pos.y : width, // x2
|
|
351
428
|
pos.x // y2
|
|
352
|
-
] :
|
|
429
|
+
] :
|
|
430
|
+
[
|
|
353
431
|
pos.x,
|
|
354
432
|
isEdge ? pos.y : null,
|
|
355
433
|
pos.x,
|
|
@@ -364,7 +442,8 @@ export default {
|
|
|
364
442
|
isEdge && !isY2 ? pos.x : null, // y1
|
|
365
443
|
pos.y, // x2
|
|
366
444
|
isEdge && isY2 ? pos.x : height // y2
|
|
367
|
-
] :
|
|
445
|
+
] :
|
|
446
|
+
[
|
|
368
447
|
isEdge && isY2 ? pos.x : null,
|
|
369
448
|
pos.y,
|
|
370
449
|
isEdge && !isY2 ? pos.x : width,
|
|
@@ -444,17 +523,22 @@ export default {
|
|
|
444
523
|
},
|
|
445
524
|
|
|
446
525
|
getGridFilterToRemove(params): Function {
|
|
447
|
-
return params ?
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
526
|
+
return params ?
|
|
527
|
+
line => {
|
|
528
|
+
let found = false;
|
|
529
|
+
|
|
530
|
+
(isArray(params) ? params.concat() : [params]).forEach(param => {
|
|
531
|
+
if (
|
|
532
|
+
(("value" in param && line.value === param.value) ||
|
|
533
|
+
("class" in param && line.class === param.class))
|
|
534
|
+
) {
|
|
535
|
+
found = true;
|
|
536
|
+
}
|
|
537
|
+
});
|
|
455
538
|
|
|
456
|
-
|
|
457
|
-
|
|
539
|
+
return found;
|
|
540
|
+
} :
|
|
541
|
+
() => true;
|
|
458
542
|
},
|
|
459
543
|
|
|
460
544
|
removeGridLines(params, forX?: boolean): void {
|