billboard.js 3.9.4 → 3.10.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 +2 -2
- package/dist/billboard.css +2 -2
- package/dist/billboard.js +2742 -2516
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +2936 -2704
- package/dist/billboard.pkgd.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +15 -15
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +205 -186
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +231 -226
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +172 -152
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +161 -142
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/{billboardjs-plugin-bubblecompare.js → billboardjs-plugin-bubblecompare.pkgd.js} +52 -32
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-sparkline.js → billboardjs-plugin-sparkline.pkgd.js} +239 -200
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-stanford.js → billboardjs-plugin-stanford.pkgd.js} +301 -277
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-tableview.js → billboardjs-plugin-tableview.pkgd.js} +206 -166
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-textoverlap.js → billboardjs-plugin-textoverlap.pkgd.js} +308 -278
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +12 -0
- package/dist/theme/dark.css +5 -4
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +5 -4
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +5 -4
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +5 -4
- package/dist/theme/insight.min.css +2 -2
- package/dist-esm/billboard.js +718 -509
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -3
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +15 -9
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +21 -28
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +17 -11
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +13 -7
- package/package.json +32 -32
- package/src/Chart/api/axis.ts +4 -0
- package/src/Chart/api/category.ts +8 -4
- package/src/Chart/api/export.ts +1 -2
- package/src/Chart/api/subchart.ts +162 -89
- package/src/Chart/api/zoom.ts +69 -79
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +0 -8
- package/src/ChartInternal/data/IData.ts +4 -1
- package/src/ChartInternal/data/convert.helper.ts +1 -15
- package/src/ChartInternal/data/data.ts +8 -2
- package/src/ChartInternal/interactions/eventrect.ts +3 -4
- package/src/ChartInternal/interactions/flow.ts +1 -7
- package/src/ChartInternal/interactions/interaction.ts +11 -5
- package/src/ChartInternal/interactions/subchart.ts +36 -30
- package/src/ChartInternal/interactions/zoom.ts +13 -3
- package/src/ChartInternal/internals/category.ts +2 -2
- package/src/ChartInternal/internals/clip.ts +4 -5
- package/src/ChartInternal/internals/color.ts +49 -23
- package/src/ChartInternal/internals/domain.ts +46 -10
- package/src/ChartInternal/internals/grid.ts +57 -86
- package/src/ChartInternal/internals/redraw.ts +1 -6
- package/src/ChartInternal/internals/region.ts +35 -12
- package/src/ChartInternal/internals/selection.ts +1 -1
- package/src/ChartInternal/internals/text.ts +1 -26
- package/src/ChartInternal/internals/title.ts +10 -48
- package/src/ChartInternal/internals/tooltip.ts +50 -54
- package/src/ChartInternal/shape/arc.ts +2 -2
- package/src/ChartInternal/shape/candlestick.ts +2 -17
- package/src/ChartInternal/shape/point.ts +36 -8
- package/src/ChartInternal/shape/radar.ts +1 -1
- package/src/ChartInternal/shape/shape.ts +50 -4
- package/src/ChartInternal/shape/treemap.ts +2 -2
- package/src/Plugin/bubblecompare/index.ts +1 -1
- package/src/Plugin/sparkline/index.ts +2 -2
- package/src/Plugin/stanford/Elements.ts +10 -2
- package/src/Plugin/stanford/index.ts +1 -24
- package/src/Plugin/tableview/index.ts +2 -2
- package/src/config/Options/axis/x.ts +1 -0
- package/src/config/Options/common/main.ts +12 -2
- package/src/config/Options/common/point.ts +41 -0
- package/src/config/Options/common/tooltip.ts +10 -10
- package/src/config/Options/data/axis.ts +3 -1
- package/src/config/Options/data/data.ts +10 -2
- package/src/config/Options/shape/area.ts +10 -4
- package/src/config/Options/shape/bar.ts +10 -4
- package/src/config/Store/State.ts +3 -0
- package/src/module/Cache.ts +7 -5
- package/src/module/browser.ts +34 -14
- package/src/module/util.ts +8 -4
- package/src/module/worker.ts +24 -13
- package/src/scss/billboard.scss +4 -2
- package/src/scss/theme/dark.scss +4 -2
- package/src/scss/theme/datalab.scss +4 -2
- package/src/scss/theme/graph.scss +4 -2
- package/src/scss/theme/insight.scss +4 -2
- package/types/chart.d.ts +11 -0
- package/types/options.d.ts +9 -3
- package/types/options.shape.d.ts +26 -0
- package/types/types.d.ts +15 -1
|
@@ -18,9 +18,11 @@ export default {
|
|
|
18
18
|
*/
|
|
19
19
|
initBrush(): void {
|
|
20
20
|
const $$ = this;
|
|
21
|
-
const {config, scale, $el: {subchart}} = $$;
|
|
21
|
+
const {config, scale, $el: {subchart}, state} = $$;
|
|
22
22
|
const isRotated = config.axis_rotated;
|
|
23
|
+
const height = config.subchart_size_height;
|
|
23
24
|
let lastDomain;
|
|
25
|
+
let lastSelection;
|
|
24
26
|
let timeout;
|
|
25
27
|
|
|
26
28
|
// set the brush
|
|
@@ -28,28 +30,27 @@ export default {
|
|
|
28
30
|
isRotated ? d3BrushY() : d3BrushX()
|
|
29
31
|
).handleSize(5);
|
|
30
32
|
|
|
31
|
-
const getBrushSize = () => {
|
|
32
|
-
const brush = $$.$el.svg.select(`.${CLASS.brush} .overlay`);
|
|
33
|
-
const brushSize = {width: 0, height: 0};
|
|
34
|
-
|
|
35
|
-
if (brush.size()) {
|
|
36
|
-
brushSize.width = +brush.attr("width");
|
|
37
|
-
brushSize.height = +brush.attr("height");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return brushSize[isRotated ? "width" : "height"];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
33
|
// bind brush event
|
|
44
34
|
$$.brush.on("start brush end", event => {
|
|
45
|
-
const {selection, target, type} = event;
|
|
35
|
+
const {selection, sourceEvent, target, type} = event;
|
|
46
36
|
|
|
47
37
|
if (type === "start") {
|
|
48
38
|
$$.state.inputType === "touch" && $$.hideTooltip();
|
|
39
|
+
lastSelection = sourceEvent ? selection : null;
|
|
40
|
+
// sourceEvent && (state.domain = null);
|
|
49
41
|
}
|
|
50
42
|
|
|
43
|
+
// if (type === "brush") {
|
|
51
44
|
if (/(start|brush)/.test(type)) {
|
|
52
|
-
|
|
45
|
+
// when brush selection updates happens on one edge, update only chainging edge and
|
|
46
|
+
// is only for adjustment of given domain range to be used to return current domain range.
|
|
47
|
+
type === "brush" && sourceEvent && state.domain && lastSelection?.forEach((v, i) => {
|
|
48
|
+
if (v !== selection[i]) {
|
|
49
|
+
state.domain[i] = scale.x.orgDomain()[i];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
$$.redrawForBrush(type !== "start");
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
if (type === "end") {
|
|
@@ -63,10 +64,9 @@ export default {
|
|
|
63
64
|
} else {
|
|
64
65
|
$$.brush.handle.attr("display", null)
|
|
65
66
|
.attr("transform", (d, i) => {
|
|
66
|
-
const pos =
|
|
67
|
-
[33, selection[i] - (i === 0 ? 30 : 24)] : [selection[i], 3];
|
|
67
|
+
const pos = [selection[i], height / 2];
|
|
68
68
|
|
|
69
|
-
return `translate(${pos})`;
|
|
69
|
+
return `translate(${isRotated ? pos.reverse() : pos})`;
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -94,7 +94,7 @@ export default {
|
|
|
94
94
|
|
|
95
95
|
// set the brush extent
|
|
96
96
|
$$.brush.scale = function(scale) {
|
|
97
|
-
const h = config.subchart_size_height
|
|
97
|
+
const h = config.subchart_size_height;
|
|
98
98
|
let extent = $$.getExtent();
|
|
99
99
|
|
|
100
100
|
if (!extent && scale.range) {
|
|
@@ -199,11 +199,11 @@ export default {
|
|
|
199
199
|
|
|
200
200
|
// brush handle shape's path
|
|
201
201
|
const path = isRotated ? [
|
|
202
|
-
"
|
|
203
|
-
"
|
|
202
|
+
"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",
|
|
203
|
+
"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"
|
|
204
204
|
] : [
|
|
205
|
-
"
|
|
206
|
-
"
|
|
205
|
+
"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",
|
|
206
|
+
"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"
|
|
207
207
|
];
|
|
208
208
|
|
|
209
209
|
$$.brush.handle = brush.selectAll(`.${customHandleClass}`)
|
|
@@ -320,23 +320,28 @@ export default {
|
|
|
320
320
|
$$.redrawCircle(cx, cy, withTransition, undefined, true);
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
!state.rendered && initRange
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
if (!state.rendered && initRange) {
|
|
324
|
+
state.domain = initRange;
|
|
325
|
+
|
|
326
|
+
$$.brush.move(
|
|
327
|
+
$$.brush.getSelection(),
|
|
328
|
+
initRange.map($$.scale.x)
|
|
329
|
+
);
|
|
330
|
+
}
|
|
327
331
|
}
|
|
328
332
|
}
|
|
329
333
|
},
|
|
330
334
|
|
|
331
335
|
/**
|
|
332
336
|
* Redraw the brush.
|
|
337
|
+
* @param {boolean} [callCallbck=true] Call 'onbrush' callback or not.
|
|
333
338
|
* @private
|
|
334
339
|
*/
|
|
335
|
-
redrawForBrush() {
|
|
340
|
+
redrawForBrush(callCallbck = true): void {
|
|
336
341
|
const $$ = this;
|
|
337
342
|
const {config: {
|
|
338
343
|
subchart_onbrush: onBrush, zoom_rescale: withY
|
|
339
|
-
}, scale} = $$;
|
|
344
|
+
}, scale, state} = $$;
|
|
340
345
|
|
|
341
346
|
$$.redraw({
|
|
342
347
|
withTransition: false,
|
|
@@ -346,7 +351,8 @@ export default {
|
|
|
346
351
|
withDimension: false
|
|
347
352
|
});
|
|
348
353
|
|
|
349
|
-
|
|
354
|
+
callCallbck && state.rendered &&
|
|
355
|
+
onBrush.bind($$.api)(state.domain ?? scale.x.orgDomain());
|
|
350
356
|
},
|
|
351
357
|
|
|
352
358
|
/**
|
|
@@ -125,7 +125,7 @@ export default {
|
|
|
125
125
|
* @private
|
|
126
126
|
*/
|
|
127
127
|
// @ts-ignore
|
|
128
|
-
zoom.getDomain = (): number|Date[] => {
|
|
128
|
+
zoom.getDomain = (): (number | Date)[] => {
|
|
129
129
|
const domain = scale[scale.zoom ? "zoom" : "subX"].domain();
|
|
130
130
|
const isCategorized = $$.axis.isCategorized();
|
|
131
131
|
|
|
@@ -135,6 +135,7 @@ export default {
|
|
|
135
135
|
|
|
136
136
|
return domain;
|
|
137
137
|
};
|
|
138
|
+
|
|
138
139
|
$$.zoom = zoom;
|
|
139
140
|
},
|
|
140
141
|
|
|
@@ -175,6 +176,7 @@ export default {
|
|
|
175
176
|
|
|
176
177
|
if (event.sourceEvent) {
|
|
177
178
|
state.zooming = true;
|
|
179
|
+
state.domain = undefined;
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
const isMousemove = sourceEvent?.type === "mousemove";
|
|
@@ -206,7 +208,11 @@ export default {
|
|
|
206
208
|
$$.state.cancelClick = isMousemove;
|
|
207
209
|
|
|
208
210
|
// do not call event cb when is .unzoom() is called
|
|
209
|
-
!isUnZoom && callFn(
|
|
211
|
+
!isUnZoom && callFn(
|
|
212
|
+
config.zoom_onzoom,
|
|
213
|
+
$$.api,
|
|
214
|
+
$$.state.domain ?? $$.zoom.getDomain()
|
|
215
|
+
);
|
|
210
216
|
},
|
|
211
217
|
|
|
212
218
|
/**
|
|
@@ -239,7 +245,11 @@ export default {
|
|
|
239
245
|
state.zooming = false;
|
|
240
246
|
|
|
241
247
|
// do not call event cb when is .unzoom() is called
|
|
242
|
-
!isUnZoom && (e || state.dragging) && callFn(
|
|
248
|
+
!isUnZoom && (e || state.dragging) && callFn(
|
|
249
|
+
config.zoom_onzoomend,
|
|
250
|
+
$$.api,
|
|
251
|
+
$$.state.domain ?? $$.zoom.getDomain()
|
|
252
|
+
);
|
|
243
253
|
},
|
|
244
254
|
|
|
245
255
|
/**
|
|
@@ -10,8 +10,8 @@ export default {
|
|
|
10
10
|
* @private
|
|
11
11
|
*/
|
|
12
12
|
categoryName(i: number): string {
|
|
13
|
-
const {axis_x_categories
|
|
13
|
+
const {axis_x_categories} = this.config;
|
|
14
14
|
|
|
15
|
-
return
|
|
15
|
+
return axis_x_categories?.[i] ?? i;
|
|
16
16
|
},
|
|
17
17
|
};
|
|
@@ -57,16 +57,15 @@ export default {
|
|
|
57
57
|
const isRotated = config.axis_rotated;
|
|
58
58
|
const left = Math.max(30, margin.left) - (isRotated ? 0 : 20);
|
|
59
59
|
|
|
60
|
-
const x = isRotated ? -(1 + left) : -(left - 1);
|
|
61
|
-
const y = -Math.max(15, margin.top);
|
|
62
|
-
const w = isRotated ? margin.left + 20 : width + 10 + left;
|
|
63
|
-
|
|
64
60
|
// less than 20 is not enough to show the axis label 'outer' without legend
|
|
65
61
|
const h = (isRotated ? (margin.top + height) + 10 : margin.bottom) + 20;
|
|
66
62
|
|
|
63
|
+
const x = isRotated ? -(1 + left) : -(left - 1);
|
|
64
|
+
const w = isRotated ? margin.left + 20 : width + 10 + left;
|
|
65
|
+
|
|
67
66
|
node
|
|
68
67
|
.attr("x", x)
|
|
69
|
-
.attr("y",
|
|
68
|
+
.attr("y", -2)
|
|
70
69
|
.attr("width", w)
|
|
71
70
|
.attr("height", h);
|
|
72
71
|
},
|
|
@@ -204,7 +204,9 @@ export default {
|
|
|
204
204
|
},
|
|
205
205
|
|
|
206
206
|
/**
|
|
207
|
-
* Update linear gradient definition
|
|
207
|
+
* Update linear/radial gradient definition
|
|
208
|
+
* - linear: area & bar only
|
|
209
|
+
* - radial: type which has data points only
|
|
208
210
|
* @private
|
|
209
211
|
*/
|
|
210
212
|
updateLinearGradient(): void {
|
|
@@ -213,31 +215,55 @@ export default {
|
|
|
213
215
|
|
|
214
216
|
targets.forEach(d => {
|
|
215
217
|
const id = `${datetimeId}-gradient${$$.getTargetSelectorSuffix(d.id)}`;
|
|
218
|
+
const radialGradient = $$.hasPointType() && config.point_radialGradient;
|
|
216
219
|
const supportedType = ($$.isAreaType(d) && "area") || ($$.isBarType(d) && "bar");
|
|
217
|
-
const isRotated = config.axis_rotated;
|
|
218
220
|
|
|
219
|
-
if (supportedType && defs.select(`#${id}`).empty()) {
|
|
221
|
+
if ((radialGradient || supportedType) && defs.select(`#${id}`).empty()) {
|
|
220
222
|
const color = $$.color(d);
|
|
221
|
-
const {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
.attr("
|
|
239
|
-
.attr("
|
|
240
|
-
|
|
223
|
+
const gradient = {
|
|
224
|
+
defs: <null|d3Selection>null,
|
|
225
|
+
stops: <[number, string|Function|null, number][]>[]
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
if (radialGradient) {
|
|
229
|
+
const {
|
|
230
|
+
cx = 0.3,
|
|
231
|
+
cy = 0.3,
|
|
232
|
+
r = 0.7,
|
|
233
|
+
stops = [[0.1, color, 0], [0.9, color, 1]]
|
|
234
|
+
} = radialGradient;
|
|
235
|
+
|
|
236
|
+
gradient.stops = stops;
|
|
237
|
+
gradient.defs = defs.append("radialGradient")
|
|
238
|
+
.attr("id", `${id}`)
|
|
239
|
+
.attr("cx", cx)
|
|
240
|
+
.attr("cy", cy)
|
|
241
|
+
.attr("r", r);
|
|
242
|
+
} else {
|
|
243
|
+
const isRotated = config.axis_rotated;
|
|
244
|
+
const {
|
|
245
|
+
x = isRotated ? [1, 0] : [0, 0],
|
|
246
|
+
y = isRotated ? [0, 0] : [0, 1],
|
|
247
|
+
stops = [[0, color, 1], [1, color, 0]]
|
|
248
|
+
} = config[`${supportedType}_linearGradient`];
|
|
249
|
+
|
|
250
|
+
gradient.stops = stops;
|
|
251
|
+
gradient.defs = defs.append("linearGradient")
|
|
252
|
+
.attr("id", `${id}`)
|
|
253
|
+
.attr("x1", x[0])
|
|
254
|
+
.attr("x2", x[1])
|
|
255
|
+
.attr("y1", y[0])
|
|
256
|
+
.attr("y2", y[1]);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
gradient.stops.forEach((v: [number, string|Function|null, number]) => {
|
|
260
|
+
const [offset, stopColor, stopOpacity] = v;
|
|
261
|
+
const colorValue = isFunction(stopColor) ? stopColor.bind($$.api)(d.id) : stopColor;
|
|
262
|
+
|
|
263
|
+
gradient.defs && gradient.defs.append("stop")
|
|
264
|
+
.attr("offset", offset)
|
|
265
|
+
.attr("stop-color", colorValue || color)
|
|
266
|
+
.attr("stop-opacity", stopOpacity);
|
|
241
267
|
});
|
|
242
268
|
}
|
|
243
269
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
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 type {IData} from "../data/IData";
|
|
6
|
+
import type {IData, TDomainRange} from "../data/IData";
|
|
7
7
|
import {brushEmpty, getBrushSelection, getMinMax, isDefined, notEmpty, isValue, isObject, isNumber, diffDomain, parseDate, sortValue} from "../../module/util";
|
|
8
8
|
|
|
9
9
|
export default {
|
|
@@ -368,21 +368,25 @@ export default {
|
|
|
368
368
|
},
|
|
369
369
|
|
|
370
370
|
/**
|
|
371
|
-
* Get zoom domain
|
|
371
|
+
* Get subchart/zoom domain
|
|
372
|
+
* @param {string} type "subX" or "zoom"
|
|
373
|
+
* @param {boolean} getCurrent Get current domain if true
|
|
372
374
|
* @returns {Array} zoom domain
|
|
373
375
|
* @private
|
|
374
376
|
*/
|
|
375
|
-
getZoomDomain(
|
|
377
|
+
getZoomDomain(type: "subX" | "zoom" = "zoom", getCurrent = false): TDomainRange {
|
|
376
378
|
const $$ = this;
|
|
377
|
-
const {config, org} = $$;
|
|
378
|
-
let [min, max] = org.xDomain;
|
|
379
|
+
const {config, scale, org} = $$;
|
|
380
|
+
let [min, max] = getCurrent && scale[type] ? scale[type].domain() : org.xDomain;
|
|
379
381
|
|
|
380
|
-
if (
|
|
381
|
-
|
|
382
|
-
|
|
382
|
+
if (type === "zoom") {
|
|
383
|
+
if (isDefined(config.zoom_x_min)) {
|
|
384
|
+
min = getMinMax("min", [min, config.zoom_x_min]);
|
|
385
|
+
}
|
|
383
386
|
|
|
384
|
-
|
|
385
|
-
|
|
387
|
+
if (isDefined(config.zoom_x_max)) {
|
|
388
|
+
max = getMinMax("max", [max, config.zoom_x_max]);
|
|
389
|
+
}
|
|
386
390
|
}
|
|
387
391
|
|
|
388
392
|
return [min, max];
|
|
@@ -409,5 +413,37 @@ export default {
|
|
|
409
413
|
}
|
|
410
414
|
|
|
411
415
|
return domainLength * (pixels / state[length]);
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Check if the given domain is within subchart/zoom range
|
|
420
|
+
* @param {Array} domain Target domain value
|
|
421
|
+
* @param {Array} current Current subchart/zoom domain value
|
|
422
|
+
* @param {Array} range subchart/zoom range value
|
|
423
|
+
* @returns {boolean}
|
|
424
|
+
* @private
|
|
425
|
+
*/
|
|
426
|
+
withinRange<T = TDomainRange>(domain: T, current: T, range: T): boolean {
|
|
427
|
+
const $$ = this;
|
|
428
|
+
const isInverted = $$.config.axis_x_inverted;
|
|
429
|
+
const [min, max] = range as number[];
|
|
430
|
+
|
|
431
|
+
if (Array.isArray(domain)) {
|
|
432
|
+
const target = [...domain];
|
|
433
|
+
|
|
434
|
+
isInverted && target.reverse();
|
|
435
|
+
|
|
436
|
+
if (target[0] < target[1]) {
|
|
437
|
+
return domain.every((v, i) => (
|
|
438
|
+
i === 0 ? (
|
|
439
|
+
isInverted ? +v <= min : +v >= min
|
|
440
|
+
) : (
|
|
441
|
+
isInverted ? +v >= max : +v <= max
|
|
442
|
+
)
|
|
443
|
+
) && !(domain.every((v, i) => v === current[i])));
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return false;
|
|
412
448
|
}
|
|
413
449
|
};
|
|
@@ -169,109 +169,65 @@ export default {
|
|
|
169
169
|
grid.main.style("visibility", $$.hasArcType() ? "hidden" : null);
|
|
170
170
|
|
|
171
171
|
$$.hideGridFocus();
|
|
172
|
-
$$.
|
|
173
|
-
$$.
|
|
172
|
+
$$.updateGridLines("x");
|
|
173
|
+
$$.updateGridLines("y");
|
|
174
174
|
},
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
* Update
|
|
177
|
+
* Update Grid lines
|
|
178
|
+
* @param {string} type x | y
|
|
178
179
|
* @private
|
|
179
180
|
*/
|
|
180
|
-
|
|
181
|
+
updateGridLines(type: "x" | "y"): void {
|
|
181
182
|
const $$ = this;
|
|
182
183
|
const {config, $el: {gridLines, main}, $T} = $$;
|
|
183
184
|
const isRotated = config.axis_rotated;
|
|
185
|
+
const isX = type === "x";
|
|
184
186
|
|
|
185
|
-
config
|
|
187
|
+
config[`grid_${type}_show`] && $$[`update${type.toUpperCase()}Grid`]();
|
|
186
188
|
|
|
187
|
-
let
|
|
188
|
-
.selectAll(`.${$GRID
|
|
189
|
-
.data(config
|
|
189
|
+
let lines = main.select(`.${$GRID[`${type}gridLines`]}`)
|
|
190
|
+
.selectAll(`.${$GRID[`${type}gridLine`]}`)
|
|
191
|
+
.data(config[`grid_${type}_lines`]);
|
|
190
192
|
|
|
191
193
|
// exit
|
|
192
|
-
$T(
|
|
194
|
+
$T(lines.exit())
|
|
193
195
|
.style("opacity", "0")
|
|
194
196
|
.remove();
|
|
195
197
|
|
|
196
198
|
// enter
|
|
197
|
-
const
|
|
199
|
+
const gridLine = lines.enter().append("g");
|
|
198
200
|
|
|
199
|
-
|
|
201
|
+
gridLine.append("line")
|
|
200
202
|
.style("opacity", "0");
|
|
201
203
|
|
|
202
|
-
|
|
203
|
-
.attr("transform", isRotated ? null : "rotate(-90)")
|
|
204
|
-
.attr("dy", -5)
|
|
205
|
-
.style("opacity", "0");
|
|
204
|
+
lines = gridLine.merge(lines);
|
|
206
205
|
|
|
207
|
-
|
|
206
|
+
lines.each(function(d) {
|
|
207
|
+
const g = d3Select(this);
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
if (g.select("text").empty() && d.text) {
|
|
210
|
+
g.append("text")
|
|
211
|
+
.style("opacity", "0");
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
$T(lines
|
|
216
|
+
.attr("class", d => `${$GRID[`${type}gridLine`]} ${d.class || ""}`.trim())
|
|
211
217
|
.select("text")
|
|
212
218
|
.attr("text-anchor", getGridTextAnchor)
|
|
219
|
+
.attr("transform", () => (isX ?
|
|
220
|
+
(isRotated ? null : "rotate(-90)") :
|
|
221
|
+
(isRotated ? "rotate(-90)" : null)
|
|
222
|
+
))
|
|
213
223
|
.attr("dx", getGridTextDx)
|
|
214
|
-
)
|
|
215
|
-
.text(d => d.text)
|
|
216
|
-
.style("opacity", null);
|
|
217
|
-
|
|
218
|
-
gridLines.x = xLines;
|
|
219
|
-
},
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Update Y Grid lines
|
|
223
|
-
* @private
|
|
224
|
-
*/
|
|
225
|
-
updateYGridLines(): void {
|
|
226
|
-
const $$ = this;
|
|
227
|
-
const {config, state: {width, height}, $el, $T} = $$;
|
|
228
|
-
const isRotated = config.axis_rotated;
|
|
229
|
-
|
|
230
|
-
config.grid_y_show && $$.updateYGrid();
|
|
231
|
-
|
|
232
|
-
let ygridLines = $el.main.select(`.${$GRID.ygridLines}`)
|
|
233
|
-
.selectAll(`.${$GRID.ygridLine}`)
|
|
234
|
-
.data(config.grid_y_lines);
|
|
235
|
-
|
|
236
|
-
// exit
|
|
237
|
-
$T(ygridLines.exit())
|
|
238
|
-
.style("opacity", "0")
|
|
239
|
-
.remove();
|
|
240
|
-
|
|
241
|
-
// enter
|
|
242
|
-
const ygridLine = ygridLines.enter().append("g");
|
|
243
|
-
|
|
244
|
-
ygridLine.append("line")
|
|
245
|
-
.style("opacity", "0");
|
|
246
|
-
|
|
247
|
-
ygridLine.append("text")
|
|
248
|
-
.attr("transform", isRotated ? "rotate(-90)" : "")
|
|
249
|
-
.style("opacity", "0");
|
|
250
|
-
|
|
251
|
-
ygridLines = ygridLine.merge(ygridLines);
|
|
252
|
-
|
|
253
|
-
// update
|
|
254
|
-
const yv = $$.yv.bind($$);
|
|
255
|
-
|
|
256
|
-
$T(ygridLines
|
|
257
|
-
.attr("class", d => `${$GRID.ygridLine} ${d.class || ""}`.trim())
|
|
258
|
-
.select("line"))
|
|
259
|
-
.attr("x1", isRotated ? yv : 0)
|
|
260
|
-
.attr("x2", isRotated ? yv : width)
|
|
261
|
-
.attr("y1", isRotated ? 0 : yv)
|
|
262
|
-
.attr("y2", isRotated ? height : yv)
|
|
263
|
-
.style("opacity", null);
|
|
264
|
-
|
|
265
|
-
$T(ygridLines.select("text")
|
|
266
|
-
.attr("text-anchor", getGridTextAnchor)
|
|
267
|
-
.attr("dx", getGridTextDx))
|
|
268
224
|
.attr("dy", -5)
|
|
269
|
-
|
|
270
|
-
.
|
|
271
|
-
|
|
272
|
-
|
|
225
|
+
)
|
|
226
|
+
.text(function(d) {
|
|
227
|
+
return d.text ?? this.remove();
|
|
228
|
+
});
|
|
273
229
|
|
|
274
|
-
|
|
230
|
+
gridLines[type] = lines;
|
|
275
231
|
},
|
|
276
232
|
|
|
277
233
|
redrawGrid(withTransition: boolean): any[] {
|
|
@@ -283,24 +239,39 @@ export default {
|
|
|
283
239
|
$T
|
|
284
240
|
} = $$;
|
|
285
241
|
const xv = $$.xv.bind($$);
|
|
242
|
+
const yv = $$.yv.bind($$);
|
|
286
243
|
|
|
287
|
-
let
|
|
288
|
-
let
|
|
244
|
+
let xLines = gridLines.x.select("line");
|
|
245
|
+
let xTexts = gridLines.x.select("text");
|
|
289
246
|
|
|
290
|
-
|
|
247
|
+
let yLines = gridLines.y.select("line");
|
|
248
|
+
let yTexts = gridLines.y.select("text");
|
|
249
|
+
|
|
250
|
+
xLines = $T(xLines, withTransition)
|
|
291
251
|
.attr("x1", isRotated ? 0 : xv)
|
|
292
252
|
.attr("x2", isRotated ? width : xv)
|
|
293
253
|
.attr("y1", isRotated ? xv : 0)
|
|
294
254
|
.attr("y2", isRotated ? xv : height);
|
|
295
255
|
|
|
296
|
-
|
|
256
|
+
xTexts = $T(xTexts, withTransition)
|
|
297
257
|
.attr("x", getGridTextX(!isRotated, width, height))
|
|
298
|
-
.attr("y", xv)
|
|
299
|
-
|
|
258
|
+
.attr("y", xv);
|
|
259
|
+
|
|
260
|
+
yLines = $T(yLines, withTransition)
|
|
261
|
+
.attr("x1", isRotated ? yv : 0)
|
|
262
|
+
.attr("x2", isRotated ? yv : width)
|
|
263
|
+
.attr("y1", isRotated ? 0 : yv)
|
|
264
|
+
.attr("y2", isRotated ? height : yv);
|
|
265
|
+
|
|
266
|
+
yTexts = $T(yTexts, withTransition)
|
|
267
|
+
.attr("x", getGridTextX(isRotated, width, height))
|
|
268
|
+
.attr("y", yv);
|
|
300
269
|
|
|
301
270
|
return [
|
|
302
|
-
|
|
303
|
-
|
|
271
|
+
xLines.style("opacity", null),
|
|
272
|
+
xTexts.style("opacity", null),
|
|
273
|
+
yLines.style("opacity", null),
|
|
274
|
+
yTexts.style("opacity", null)
|
|
304
275
|
];
|
|
305
276
|
},
|
|
306
277
|
|
|
@@ -503,5 +474,5 @@ export default {
|
|
|
503
474
|
const gridLines = `grid_${forX ? "x" : "y"}_lines`;
|
|
504
475
|
|
|
505
476
|
config[gridLines] = config[gridLines].filter(toShow);
|
|
506
|
-
}
|
|
477
|
+
}
|
|
507
478
|
};
|
|
@@ -35,11 +35,6 @@ export default {
|
|
|
35
35
|
$$.updateDimension(true);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// update circleY based on updated parameters
|
|
39
|
-
if (!treemap && (!$$.hasArcType() || state.hasRadar)) {
|
|
40
|
-
$$.updateCircleY && ($$.circleY = $$.updateCircleY());
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
// Data empty label positioning and text.
|
|
44
39
|
config.data_empty_label_text && main.select(`text.${$TEXT.text}.${$COMMON.empty}`)
|
|
45
40
|
.attr("x", state.width / 2)
|
|
@@ -206,7 +201,7 @@ export default {
|
|
|
206
201
|
list.push($$.redrawText(xForText, yForText, flow, withTransition));
|
|
207
202
|
}
|
|
208
203
|
|
|
209
|
-
if (($$.hasPointType() || hasRadar) &&
|
|
204
|
+
if (($$.hasPointType() || hasRadar) && !$$.isPointFocusOnly()) {
|
|
210
205
|
$$.redrawCircle && list.push($$.redrawCircle(cx, cy, withTransition, flowFn));
|
|
211
206
|
}
|
|
212
207
|
|