billboard.js 3.10.2 → 3.11.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +411 -184
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +2680 -2567
- package/dist/billboard.pkgd.min.js +2 -4
- 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 +27 -13
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +27 -13
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +27 -13
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +27 -13
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2261 -2361
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2286 -2372
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2287 -2373
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2288 -2374
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2288 -2374
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +2 -2
- package/dist-esm/billboard.js +381 -170
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -4
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +6 -9
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +3 -4
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +3 -4
- package/package.json +39 -43
- package/src/Chart/api/zoom.ts +5 -20
- package/src/ChartInternal/Axis/Axis.ts +12 -7
- package/src/ChartInternal/Axis/AxisRenderer.ts +14 -0
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/data/data.ts +21 -11
- package/src/ChartInternal/data/load.ts +37 -1
- package/src/ChartInternal/interactions/eventrect.ts +11 -4
- package/src/ChartInternal/interactions/interaction.ts +2 -1
- package/src/ChartInternal/interactions/zoom.ts +28 -0
- package/src/ChartInternal/internals/clip.ts +1 -2
- package/src/ChartInternal/internals/domain.ts +24 -1
- package/src/ChartInternal/internals/format.ts +15 -4
- package/src/ChartInternal/internals/legend.ts +28 -2
- package/src/ChartInternal/internals/scale.ts +3 -3
- package/src/ChartInternal/internals/size.axis.ts +11 -19
- package/src/ChartInternal/internals/size.ts +14 -6
- package/src/ChartInternal/internals/text.ts +3 -3
- package/src/ChartInternal/internals/tooltip.ts +14 -8
- package/src/ChartInternal/internals/transform.ts +3 -3
- package/src/ChartInternal/internals/type.ts +1 -1
- package/src/ChartInternal/shape/arc.ts +1 -1
- package/src/ChartInternal/shape/radar.ts +58 -45
- package/src/ChartInternal/shape/shape.ts +2 -0
- package/src/config/Options/axis/x.ts +27 -1
- package/src/config/Options/axis/y2.ts +13 -0
- package/src/config/Options/common/legend.ts +17 -0
- package/src/module/Cache.ts +1 -0
- package/src/module/util.ts +14 -0
- package/types/options.d.ts +28 -4
|
@@ -116,6 +116,9 @@ export default {
|
|
|
116
116
|
// copy current initial x scale in case of rescale option is used
|
|
117
117
|
!org.xScale && (org.xScale = scale.x.copy());
|
|
118
118
|
scale.x.domain(domain);
|
|
119
|
+
} else if (org.xScale) {
|
|
120
|
+
scale.x.domain(org.xScale.domain());
|
|
121
|
+
org.xScale = null;
|
|
119
122
|
}
|
|
120
123
|
};
|
|
121
124
|
|
|
@@ -285,6 +288,31 @@ export default {
|
|
|
285
288
|
}
|
|
286
289
|
},
|
|
287
290
|
|
|
291
|
+
/**
|
|
292
|
+
* Set zoom transform to event rect
|
|
293
|
+
* @param {Function} x x Axis scale function
|
|
294
|
+
* @param {Array} domain Domain value to be set
|
|
295
|
+
* @private
|
|
296
|
+
*/
|
|
297
|
+
updateCurrentZoomTransform(x, domain: [number, number]): void {
|
|
298
|
+
const $$ = this;
|
|
299
|
+
const {$el: {eventRect}, config} = $$;
|
|
300
|
+
const isRotated = config.axis_rotated;
|
|
301
|
+
|
|
302
|
+
// Get transform from given domain value
|
|
303
|
+
// https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
|
|
304
|
+
const translate = [-x(domain[0]), 0];
|
|
305
|
+
const transform = d3ZoomIdentity
|
|
306
|
+
.scale(x.range()[1] / (
|
|
307
|
+
x(domain[1]) - x(domain[0])
|
|
308
|
+
))
|
|
309
|
+
.translate(
|
|
310
|
+
...(isRotated ? translate.reverse() : translate) as [number, number]
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
eventRect.call($$.zoom.transform, transform);
|
|
314
|
+
},
|
|
315
|
+
|
|
288
316
|
/**
|
|
289
317
|
* Attach zoom event on <rect>
|
|
290
318
|
* @private
|
|
@@ -59,7 +59,6 @@ export default {
|
|
|
59
59
|
|
|
60
60
|
// less than 20 is not enough to show the axis label 'outer' without legend
|
|
61
61
|
const h = (isRotated ? (margin.top + height) + 10 : margin.bottom) + 20;
|
|
62
|
-
|
|
63
62
|
const x = isRotated ? -(1 + left) : -(left - 1);
|
|
64
63
|
const y = -15; // -Math.max(15, margin.top);
|
|
65
64
|
const w = isRotated ? margin.left + 20 : width + 10 + left;
|
|
@@ -88,7 +87,7 @@ export default {
|
|
|
88
87
|
(isRotated ? -(1 + left) : -(left - 1));
|
|
89
88
|
const y = -(isRotated ? 20 : margin.top);
|
|
90
89
|
const w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0);
|
|
91
|
-
const h = (isRotated ? margin.bottom +
|
|
90
|
+
const h = (isRotated ? margin.bottom + 10 : (margin.top + height)) + 10;
|
|
92
91
|
|
|
93
92
|
node
|
|
94
93
|
.attr("x", x)
|
|
@@ -396,6 +396,29 @@ export default {
|
|
|
396
396
|
return [min, max];
|
|
397
397
|
},
|
|
398
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Return zoom domain from given domain
|
|
401
|
+
* - 'category' type need to add offset to original value
|
|
402
|
+
* @param {Array} domainValue domain value
|
|
403
|
+
* @returns {Array} Zoom domain
|
|
404
|
+
* @private
|
|
405
|
+
*/
|
|
406
|
+
getZoomDomainValue<T = TDomainRange>(domainValue: T): T | undefined {
|
|
407
|
+
const $$ = this;
|
|
408
|
+
const {config, axis} = $$;
|
|
409
|
+
|
|
410
|
+
if (axis.isCategorized() && Array.isArray(domainValue)) {
|
|
411
|
+
const isInverted = config.axis_x_inverted;
|
|
412
|
+
|
|
413
|
+
// need to add offset to original value for 'category' type
|
|
414
|
+
const domain = domainValue.map((v, i) => Number(v) + (i === 0 ? +isInverted : +!isInverted));
|
|
415
|
+
|
|
416
|
+
return domain as T;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return domainValue;
|
|
420
|
+
},
|
|
421
|
+
|
|
399
422
|
/**
|
|
400
423
|
* Converts pixels to axis' scale values
|
|
401
424
|
* @param {string} type Axis type
|
|
@@ -427,7 +450,7 @@ export default {
|
|
|
427
450
|
* @returns {boolean}
|
|
428
451
|
* @private
|
|
429
452
|
*/
|
|
430
|
-
withinRange<T = TDomainRange>(domain: T, current
|
|
453
|
+
withinRange<T = TDomainRange>(domain: T, current = [0, 0], range: T): boolean {
|
|
431
454
|
const $$ = this;
|
|
432
455
|
const isInverted = $$.config.axis_x_inverted;
|
|
433
456
|
const [min, max] = range as number[];
|
|
@@ -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 {isValue, isFunction, isObjectType} from "../../module/util";
|
|
5
|
+
import {isArray, isValue, isFunction, isObjectType, isObject} from "../../module/util";
|
|
6
6
|
import type {AxisType} from "../../../types/types";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -50,8 +50,8 @@ export default {
|
|
|
50
50
|
};
|
|
51
51
|
},
|
|
52
52
|
|
|
53
|
-
defaultValueFormat(v): number|string {
|
|
54
|
-
return isValue(v) ? +v : "";
|
|
53
|
+
defaultValueFormat(v: number|number[]): number|string {
|
|
54
|
+
return isArray(v) ? v.join("~") : (isValue(v) ? +v : "");
|
|
55
55
|
},
|
|
56
56
|
|
|
57
57
|
defaultArcValueFormat(v, ratio): string {
|
|
@@ -65,7 +65,18 @@ export default {
|
|
|
65
65
|
dataLabelFormat(targetId: string): Function {
|
|
66
66
|
const $$ = this;
|
|
67
67
|
const dataLabels = $$.config.data_labels;
|
|
68
|
-
const defaultFormat = v =>
|
|
68
|
+
const defaultFormat = v => {
|
|
69
|
+
const delimiter = "~";
|
|
70
|
+
let res = v;
|
|
71
|
+
|
|
72
|
+
if (isArray(v)) {
|
|
73
|
+
res = v.join(delimiter);
|
|
74
|
+
} else if (isObject(v)) {
|
|
75
|
+
res = Object.values(v).join(delimiter);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return res;
|
|
79
|
+
};
|
|
69
80
|
let format = defaultFormat;
|
|
70
81
|
|
|
71
82
|
// find format according to axis id
|
|
@@ -27,6 +27,22 @@ function getLegendColor(id: string): string {
|
|
|
27
27
|
return color;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Get formatted text value
|
|
32
|
+
* @param {string} id Legend text id
|
|
33
|
+
* @returns {string} Formatted legend text
|
|
34
|
+
*/
|
|
35
|
+
function getFormattedText<T = string>(id: T): T {
|
|
36
|
+
const {config} = this;
|
|
37
|
+
let text = config.data_names[id] ?? id;
|
|
38
|
+
|
|
39
|
+
if (isFunction(config.legend_format)) {
|
|
40
|
+
text = config.legend_format(text);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return text;
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
export default {
|
|
31
47
|
/**
|
|
32
48
|
* Initialize the legend.
|
|
@@ -570,9 +586,15 @@ export default {
|
|
|
570
586
|
.append("rect");
|
|
571
587
|
}
|
|
572
588
|
|
|
589
|
+
if (config.legend_tooltip) {
|
|
590
|
+
legend.selectAll("title")
|
|
591
|
+
.data(targetIdz)
|
|
592
|
+
.text(id => id);
|
|
593
|
+
}
|
|
594
|
+
|
|
573
595
|
const texts = legend.selectAll("text")
|
|
574
596
|
.data(targetIdz)
|
|
575
|
-
.text(
|
|
597
|
+
.text(getFormattedText.bind($$)) // MEMO: needed for update
|
|
576
598
|
.each(function(id, i) {
|
|
577
599
|
updatePositions(this, id, i);
|
|
578
600
|
});
|
|
@@ -722,8 +744,12 @@ export default {
|
|
|
722
744
|
|
|
723
745
|
$$.setLegendItem(l);
|
|
724
746
|
|
|
747
|
+
if (config.legend_tooltip) {
|
|
748
|
+
l.append("title").text(id => id);
|
|
749
|
+
}
|
|
750
|
+
|
|
725
751
|
l.append("text")
|
|
726
|
-
.text(
|
|
752
|
+
.text(getFormattedText.bind($$))
|
|
727
753
|
.each(function(id, i) {
|
|
728
754
|
updatePositions(this, id, i);
|
|
729
755
|
})
|
|
@@ -39,8 +39,8 @@ export function getScale(type = "linear", min = 0, max = 1): any {
|
|
|
39
39
|
export default {
|
|
40
40
|
/**
|
|
41
41
|
* Get x Axis scale function
|
|
42
|
-
* @param {number} min Min value
|
|
43
|
-
* @param {number} max Max value
|
|
42
|
+
* @param {number} min Min range value
|
|
43
|
+
* @param {number} max Max range value
|
|
44
44
|
* @param {Array} domain Domain value
|
|
45
45
|
* @param {Function} offset The offset getter to be sum
|
|
46
46
|
* @returns {Function} scale
|
|
@@ -48,7 +48,7 @@ export default {
|
|
|
48
48
|
*/
|
|
49
49
|
getXScale(min: number, max: number, domain: number[], offset: Function) {
|
|
50
50
|
const $$ = this;
|
|
51
|
-
const scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
|
|
51
|
+
const scale = ($$.state.loading !== "append" && $$.scale.zoom) || getScale($$.axis.getAxisType("x"), min, max);
|
|
52
52
|
|
|
53
53
|
return $$.getCustomizedXScale(
|
|
54
54
|
domain ? scale.domain(domain) : scale,
|
|
@@ -42,7 +42,7 @@ export default {
|
|
|
42
42
|
getHorizontalAxisHeight(id: AxisType): number {
|
|
43
43
|
const $$ = this;
|
|
44
44
|
const {config, state} = $$;
|
|
45
|
-
const {
|
|
45
|
+
const {rotatedPadding, isLegendRight, isLegendInset} = state;
|
|
46
46
|
const isRotated = config.axis_rotated;
|
|
47
47
|
const isFitPadding = config.padding?.mode === "fit";
|
|
48
48
|
const isInner = config[`axis_${id}_inner`];
|
|
@@ -70,21 +70,12 @@ export default {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const maxtickSize = $$.axis.getMaxTickSize(id);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
) {
|
|
79
|
-
h += maxtickSize.width *
|
|
80
|
-
Math.cos(Math.PI * (90 - Math.abs(rotate)) / 180);
|
|
81
|
-
|
|
82
|
-
if (!config.axis_x_tick_multiline && current.height) {
|
|
83
|
-
if (h > current.height / 2) {
|
|
84
|
-
h = current.height / 2;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
} else if (maxtickSize.height > defaultHeight && config.legend_show) {
|
|
73
|
+
|
|
74
|
+
const isXAxisTickRotated = config.axis_x_tick_rotate > 0 && (
|
|
75
|
+
!config.axis_x_tick_autorotate || $$.needToRotateXAxisTickTexts()
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
if ((config.axis_x_tick_multiline || isXAxisTickRotated) && maxtickSize.height > defaultHeight) {
|
|
88
79
|
h += maxtickSize.height - defaultHeight;
|
|
89
80
|
}
|
|
90
81
|
|
|
@@ -140,10 +131,10 @@ export default {
|
|
|
140
131
|
}
|
|
141
132
|
|
|
142
133
|
if ($el.svg &&
|
|
134
|
+
config.axis_x_tick_autorotate &&
|
|
143
135
|
config.axis_x_tick_fit &&
|
|
144
136
|
!config.axis_x_tick_multiline &&
|
|
145
137
|
!config.axis_x_tick_culling &&
|
|
146
|
-
config.axis_x_tick_autorotate &&
|
|
147
138
|
allowedXAxisTypes
|
|
148
139
|
) {
|
|
149
140
|
rotate = $$.needToRotateXAxisTickTexts() ?
|
|
@@ -161,8 +152,9 @@ export default {
|
|
|
161
152
|
*/
|
|
162
153
|
needToRotateXAxisTickTexts(): boolean {
|
|
163
154
|
const $$ = this;
|
|
164
|
-
const {state: {axis, current}} = $$;
|
|
165
|
-
const
|
|
155
|
+
const {state: {axis, current, isLegendRight, legendItemWidth}} = $$;
|
|
156
|
+
const legendWidth = isLegendRight && legendItemWidth;
|
|
157
|
+
const xAxisLength = current.width - legendWidth -
|
|
166
158
|
$$.getCurrentPaddingByDirection("left") - $$.getCurrentPaddingByDirection("right");
|
|
167
159
|
const tickCountWithPadding = axis.x.tickCount +
|
|
168
160
|
axis.x.padding.left + axis.x.padding.right;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import {document} from "../../module/browser";
|
|
6
6
|
import {$AXIS, $SUBCHART} from "../../config/classes";
|
|
7
|
+
import {KEY} from "../../module/Cache";
|
|
7
8
|
import {ceil10, capitalize, isNumber, isEmpty, isString, isUndefined} from "../../module/util";
|
|
8
9
|
|
|
9
10
|
export default {
|
|
@@ -169,10 +170,11 @@ export default {
|
|
|
169
170
|
* Get padding by the direction.
|
|
170
171
|
* @param {string} type "top" | "bottom" | "left" | "right"
|
|
171
172
|
* @param {boolean} [withoutRecompute=false] If set true, do not recompute the padding value.
|
|
173
|
+
* @param {boolean} [withXAxisTickTextOverflow=false] If set true, calculate x axis tick text overflow.
|
|
172
174
|
* @returns {number} padding value
|
|
173
175
|
* @private
|
|
174
176
|
*/
|
|
175
|
-
getCurrentPaddingByDirection(type: "top" | "bottom" | "left" | "right", withoutRecompute = false): number {
|
|
177
|
+
getCurrentPaddingByDirection(type: "top" | "bottom" | "left" | "right", withoutRecompute = false, withXAxisTickTextOverflow = false): number {
|
|
176
178
|
const $$ = this;
|
|
177
179
|
const {config, $el, state: {hasAxis}} = $$;
|
|
178
180
|
const isRotated = config.axis_rotated;
|
|
@@ -219,6 +221,8 @@ export default {
|
|
|
219
221
|
padding += isRotated ? (
|
|
220
222
|
!isFitPadding && isUndefined(paddingOption) ? 10 : 2
|
|
221
223
|
) : !isAxisShow || isAxisInner ? (isFitPadding ? 2 : 1) : 0;
|
|
224
|
+
|
|
225
|
+
padding += withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
|
|
222
226
|
} else if (type === "left" && isRotated && isUndefined(paddingOption)) {
|
|
223
227
|
padding = !config.axis_x_show ?
|
|
224
228
|
1 : (isFitPadding ? axisSize : Math.max(axisSize, 40));
|
|
@@ -238,10 +242,12 @@ export default {
|
|
|
238
242
|
return padding + (axisSize * axesLen) - gap;
|
|
239
243
|
},
|
|
240
244
|
|
|
241
|
-
getCurrentPadding(
|
|
245
|
+
getCurrentPadding(withXAxisTickTextOverflow = false): {
|
|
246
|
+
top: number, bottom: number, left: number, right: number
|
|
247
|
+
} {
|
|
242
248
|
const $$ = this;
|
|
243
249
|
const [top, bottom, left, right] = ["top", "bottom", "left", "right"]
|
|
244
|
-
.map(v => $$.getCurrentPaddingByDirection(v));
|
|
250
|
+
.map(v => $$.getCurrentPaddingByDirection(v, null, withXAxisTickTextOverflow));
|
|
245
251
|
|
|
246
252
|
return {top, bottom, left, right};
|
|
247
253
|
},
|
|
@@ -299,7 +305,8 @@ export default {
|
|
|
299
305
|
}
|
|
300
306
|
|
|
301
307
|
const legendSize = {
|
|
302
|
-
right: config.legend_show && state.isLegendRight ?
|
|
308
|
+
right: config.legend_show && state.isLegendRight ?
|
|
309
|
+
$$.getLegendWidth() + (isFitPadding ? 0 : 20) : 0,
|
|
303
310
|
bottom: !config.legend_show || state.isLegendRight || state.isLegendInset ? 0 : currLegend.height
|
|
304
311
|
};
|
|
305
312
|
|
|
@@ -314,7 +321,7 @@ export default {
|
|
|
314
321
|
const gaugeHeight = $$.hasType("gauge") && config.arc_needle_show &&
|
|
315
322
|
!config.gauge_fullCircle && !config.gauge_label_show ? 10 : 0;
|
|
316
323
|
|
|
317
|
-
const padding = $$.getCurrentPadding();
|
|
324
|
+
const padding = $$.getCurrentPadding(true);
|
|
318
325
|
|
|
319
326
|
// for main
|
|
320
327
|
state.margin = !isNonAxis && isRotated ? {
|
|
@@ -383,8 +390,9 @@ export default {
|
|
|
383
390
|
if ($$.hasArcType()) {
|
|
384
391
|
const hasGauge = $$.hasType("gauge");
|
|
385
392
|
const isLegendRight = config.legend_show && state.isLegendRight;
|
|
393
|
+
const textWidth = (state.hasRadar && $$.cache.get(KEY.radarTextWidth)) ?? 0;
|
|
386
394
|
|
|
387
|
-
state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0);
|
|
395
|
+
state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0) - textWidth;
|
|
388
396
|
state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10);
|
|
389
397
|
|
|
390
398
|
if (hasGauge && !config.gauge_fullCircle) {
|
|
@@ -255,7 +255,7 @@ export default {
|
|
|
255
255
|
* @returns {string|null}
|
|
256
256
|
* @private
|
|
257
257
|
*/
|
|
258
|
-
|
|
258
|
+
updateTextBackgroundColor(d: IDataRow | IArcData): string | null {
|
|
259
259
|
const $$ = this;
|
|
260
260
|
const {$el, config} = $$;
|
|
261
261
|
const backgroundColor = config.data_labels_backgroundColors;
|
|
@@ -293,7 +293,7 @@ export default {
|
|
|
293
293
|
|
|
294
294
|
$$.$el.text
|
|
295
295
|
.style("fill", $$.getStylePropValue($$.updateTextColor))
|
|
296
|
-
.attr("filter", $$.
|
|
296
|
+
.attr("filter", $$.updateTextBackgroundColor.bind($$))
|
|
297
297
|
.style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$))
|
|
298
298
|
.each(function(d: IDataRow, i: number) {
|
|
299
299
|
// do not apply transition for newly added text elements
|
|
@@ -410,7 +410,7 @@ export default {
|
|
|
410
410
|
const rect = getBoundingRect(textElement);
|
|
411
411
|
|
|
412
412
|
if (isBarType) {
|
|
413
|
-
const isPositive = d
|
|
413
|
+
const isPositive = $$.getRangedData(d, null, "bar") >= 0;
|
|
414
414
|
|
|
415
415
|
if (isRotated) {
|
|
416
416
|
const w = (
|
|
@@ -198,9 +198,9 @@ export default {
|
|
|
198
198
|
|
|
199
199
|
value = `<b>Open:</b> ${open} <b>High:</b> ${high} <b>Low:</b> ${low} <b>Close:</b> ${close}${volume ? ` <b>Volume:</b> ${volume}` : ""}`;
|
|
200
200
|
} else if ($$.isBarRangeType(row)) {
|
|
201
|
-
const {value:
|
|
201
|
+
const {value: rangeValue, id, index} = row;
|
|
202
202
|
|
|
203
|
-
value = `${valueFormat(
|
|
203
|
+
value = `${valueFormat(rangeValue, undefined, id, index)}`;
|
|
204
204
|
} else {
|
|
205
205
|
value = valueFormat(getRowValue(row), ...param);
|
|
206
206
|
}
|
|
@@ -329,6 +329,7 @@ export default {
|
|
|
329
329
|
const {width, height, current, isLegendRight, inputType} = state;
|
|
330
330
|
const hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
|
|
331
331
|
const hasTreemap = state.hasTreemap;
|
|
332
|
+
const hasRadar = state.hasRadar;
|
|
332
333
|
const isRotated = config.axis_rotated;
|
|
333
334
|
const hasArcType = $$.hasArcType();
|
|
334
335
|
const svgLeft = $$.getSvgLeft(true);
|
|
@@ -337,14 +338,19 @@ export default {
|
|
|
337
338
|
let {x, y} = currPos;
|
|
338
339
|
|
|
339
340
|
// Determine tooltip position
|
|
340
|
-
if (
|
|
341
|
-
|
|
341
|
+
if (hasRadar) {
|
|
342
|
+
x += x >= (width / 2) ? 15 : -(tWidth + 15);
|
|
343
|
+
y += 15;
|
|
344
|
+
} else if (hasArcType) {
|
|
345
|
+
const raw = inputType === "touch";
|
|
342
346
|
|
|
343
347
|
if (!raw) {
|
|
344
348
|
x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
|
|
345
|
-
y += hasGauge ? height : height / 2;
|
|
349
|
+
y += hasGauge ? height : (height / 2) + tHeight;
|
|
346
350
|
}
|
|
347
|
-
} else if (
|
|
351
|
+
} else if (hasTreemap) {
|
|
352
|
+
y += tHeight;
|
|
353
|
+
} else {
|
|
348
354
|
const padding = {
|
|
349
355
|
top: $$.getCurrentPaddingByDirection("top", true),
|
|
350
356
|
left: $$.getCurrentPaddingByDirection("left", true)
|
|
@@ -366,9 +372,9 @@ export default {
|
|
|
366
372
|
}
|
|
367
373
|
|
|
368
374
|
if (y + tHeight > current.height) {
|
|
369
|
-
const gap = hasTreemap ?
|
|
375
|
+
const gap = hasTreemap ? tHeight + 10 : 30;
|
|
370
376
|
|
|
371
|
-
y -= hasGauge ? tHeight *
|
|
377
|
+
y -= hasGauge ? tHeight * 1.5 : tHeight + gap;
|
|
372
378
|
}
|
|
373
379
|
|
|
374
380
|
const pos = {top: y, left: x};
|
|
@@ -37,7 +37,7 @@ export default {
|
|
|
37
37
|
y = isRotated ? state.height + padding : 0;
|
|
38
38
|
} else if (target === "y2") {
|
|
39
39
|
x = isRotated ? 0 : state.width + padding;
|
|
40
|
-
y = isRotated ?
|
|
40
|
+
y = isRotated ? -padding - 1 : 0;
|
|
41
41
|
} else if (target === "subX") {
|
|
42
42
|
x = 0;
|
|
43
43
|
y = isRotated ? 0 : state.height2;
|
|
@@ -48,10 +48,10 @@ export default {
|
|
|
48
48
|
x = state.arcWidth / 2;
|
|
49
49
|
y = state.arcHeight / 2;
|
|
50
50
|
} else if (target === "radar") {
|
|
51
|
-
const [width] = $$.getRadarSize();
|
|
51
|
+
const [width, height] = $$.getRadarSize();
|
|
52
52
|
|
|
53
53
|
x = state.width / 2 - width;
|
|
54
|
-
y =
|
|
54
|
+
y = state.height / 2 - height;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
return `translate(${x}, ${y})`;
|
|
@@ -119,7 +119,7 @@ export default {
|
|
|
119
119
|
*/
|
|
120
120
|
isTypeOf(d, type): boolean {
|
|
121
121
|
const id = isString(d) ? d : d.id;
|
|
122
|
-
const dataType = this.config.data_types[id] || this.config.data_type;
|
|
122
|
+
const dataType = this.config && (this.config.data_types?.[id] || this.config.data_type);
|
|
123
123
|
|
|
124
124
|
return isArray(type) ?
|
|
125
125
|
type.indexOf(dataType) >= 0 : dataType === type;
|
|
@@ -440,7 +440,7 @@ export default {
|
|
|
440
440
|
if ($$.shouldShowArcLabel()) {
|
|
441
441
|
selection
|
|
442
442
|
.style("fill", $$.updateTextColor.bind($$))
|
|
443
|
-
.attr("filter", $$.
|
|
443
|
+
.attr("filter", $$.updateTextBackgroundColor.bind($$))
|
|
444
444
|
.each(function(d) {
|
|
445
445
|
const node = d3Select(this);
|
|
446
446
|
const updated = $$.updateAngle(d);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
6
|
import {KEY} from "../../module/Cache";
|
|
7
7
|
import {$AXIS, $COMMON, $LEVEL, $RADAR, $SHAPE, $TEXT} from "../../config/classes";
|
|
8
|
-
import {getMinMax, getRange, isDefined, isEmpty, isNumber, isUndefined, setTextValue, toArray} from "../../module/util";
|
|
8
|
+
import {getMinMax, getPathBox, getRange, isDefined, isEmpty, isNumber, isUndefined, setTextValue, toArray} from "../../module/util";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Get the position value
|
|
@@ -27,7 +27,8 @@ function getPosition(isClockwise: boolean, type: "x" | "y", edge: number, pos: n
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// cache key
|
|
30
|
-
const
|
|
30
|
+
const cacheKeyPoints = KEY.radarPoints;
|
|
31
|
+
const cacheKeyTextWidth = KEY.radarTextWidth;
|
|
31
32
|
|
|
32
33
|
export default {
|
|
33
34
|
initRadar(): void {
|
|
@@ -51,6 +52,14 @@ export default {
|
|
|
51
52
|
.attr("class", $SHAPE.shapes);
|
|
52
53
|
|
|
53
54
|
current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
|
|
55
|
+
|
|
56
|
+
if (config.radar_axis_text_show) {
|
|
57
|
+
config.interaction_enabled && $$.bindRadarEvent();
|
|
58
|
+
|
|
59
|
+
// it needs to calculate dimension at the initialization
|
|
60
|
+
$$.updateRadarLevel();
|
|
61
|
+
$$.updateRadarAxes();
|
|
62
|
+
}
|
|
54
63
|
}
|
|
55
64
|
},
|
|
56
65
|
|
|
@@ -58,7 +67,7 @@ export default {
|
|
|
58
67
|
const $$ = this;
|
|
59
68
|
const {config, state: {arcWidth, arcHeight}} = $$;
|
|
60
69
|
const padding = config.axis_x_categories.length < 4 ? -20 : 10;
|
|
61
|
-
const size = (Math.min(arcWidth, arcHeight) - padding) / 2;
|
|
70
|
+
const size = ((Math.min(arcWidth, arcHeight) - padding) / 2);
|
|
62
71
|
|
|
63
72
|
return [size, size];
|
|
64
73
|
},
|
|
@@ -102,7 +111,7 @@ export default {
|
|
|
102
111
|
const targets = $$.data.targets;
|
|
103
112
|
|
|
104
113
|
const [width, height] = $$.getRadarSize();
|
|
105
|
-
const points = $$.cache.get(
|
|
114
|
+
const points = $$.cache.get(cacheKeyPoints) || {};
|
|
106
115
|
const size = points._size;
|
|
107
116
|
|
|
108
117
|
// recalculate position only when the previous dimension has been changed
|
|
@@ -114,7 +123,7 @@ export default {
|
|
|
114
123
|
});
|
|
115
124
|
|
|
116
125
|
points._size = {width, height};
|
|
117
|
-
$$.cache.add(
|
|
126
|
+
$$.cache.add(cacheKeyPoints, points);
|
|
118
127
|
}
|
|
119
128
|
},
|
|
120
129
|
|
|
@@ -136,7 +145,7 @@ export default {
|
|
|
136
145
|
},
|
|
137
146
|
|
|
138
147
|
generateGetRadarPoints(): Function {
|
|
139
|
-
const points = this.cache.get(
|
|
148
|
+
const points = this.cache.get(cacheKeyPoints);
|
|
140
149
|
|
|
141
150
|
return (d, i) => {
|
|
142
151
|
const point = points[d.id][i];
|
|
@@ -250,6 +259,7 @@ export default {
|
|
|
250
259
|
// axis text
|
|
251
260
|
if (config.radar_axis_text_show) {
|
|
252
261
|
const {x = 0, y = 0} = config.radar_axis_text_position;
|
|
262
|
+
const textWidth = $$.cache.get(cacheKeyTextWidth) || 0;
|
|
253
263
|
|
|
254
264
|
axis.select("text")
|
|
255
265
|
.style("text-anchor", "middle")
|
|
@@ -288,67 +298,70 @@ export default {
|
|
|
288
298
|
|
|
289
299
|
return `translate(${posX} ${posY})`;
|
|
290
300
|
});
|
|
291
|
-
}
|
|
292
301
|
|
|
293
|
-
|
|
302
|
+
if (!textWidth) {
|
|
303
|
+
const widths = [radar.axes, radar.levels].map(v => getPathBox(v.node()).width);
|
|
304
|
+
|
|
305
|
+
if (widths.every(v => v > 0)) {
|
|
306
|
+
$$.cache.add(cacheKeyTextWidth, widths[0] - widths[1]);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
294
310
|
},
|
|
295
311
|
|
|
296
312
|
bindRadarEvent(): void {
|
|
297
313
|
const $$ = this;
|
|
298
|
-
const {
|
|
314
|
+
const {state, $el: {radar, svg}} = $$;
|
|
299
315
|
const focusOnly = $$.isPointFocusOnly();
|
|
300
316
|
const {inputType, transiting} = state;
|
|
317
|
+
const isMouse = inputType === "mouse";
|
|
301
318
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const hide = event => {
|
|
306
|
-
state.event = event;
|
|
319
|
+
const hide = event => {
|
|
320
|
+
state.event = event;
|
|
307
321
|
|
|
308
|
-
|
|
322
|
+
// const index = getIndex(event);
|
|
309
323
|
|
|
310
|
-
|
|
311
|
-
|
|
324
|
+
const index = $$.getDataIndexFromEvent(event);
|
|
325
|
+
const noIndex = isUndefined(index);
|
|
312
326
|
|
|
313
|
-
|
|
314
|
-
|
|
327
|
+
if (isMouse || noIndex) {
|
|
328
|
+
$$.hideTooltip();
|
|
315
329
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
330
|
+
focusOnly ?
|
|
331
|
+
$$.hideCircleFocus() :
|
|
332
|
+
$$.unexpandCircles();
|
|
319
333
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
334
|
+
if (isMouse) {
|
|
335
|
+
$$.setOverOut(false, index);
|
|
336
|
+
} else if (noIndex) {
|
|
337
|
+
$$.callOverOutForTouch();
|
|
325
338
|
}
|
|
326
|
-
}
|
|
339
|
+
}
|
|
340
|
+
};
|
|
327
341
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
342
|
+
radar.axes
|
|
343
|
+
.on(isMouse ? "mouseover " : "touchstart", event => {
|
|
344
|
+
if (transiting) { // skip while transiting
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
333
347
|
|
|
334
|
-
|
|
335
|
-
|
|
348
|
+
state.event = event;
|
|
349
|
+
const index = $$.getDataIndexFromEvent(event);
|
|
336
350
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
351
|
+
$$.selectRectForSingle(svg.node(), index);
|
|
352
|
+
isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
|
|
353
|
+
})
|
|
354
|
+
.on("mouseout", isMouse ? hide : null);
|
|
341
355
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
356
|
+
if (!isMouse) {
|
|
357
|
+
svg.on("touchstart", hide);
|
|
345
358
|
}
|
|
346
359
|
},
|
|
347
360
|
|
|
348
361
|
updateRadarShape(): void {
|
|
349
362
|
const $$ = this;
|
|
350
363
|
const targets = $$.data.targets.filter(d => $$.isRadarType(d));
|
|
351
|
-
const points = $$.cache.get(
|
|
364
|
+
const points = $$.cache.get(cacheKeyPoints);
|
|
352
365
|
|
|
353
366
|
const areas = $$.$el.radar.shapes
|
|
354
367
|
.selectAll("polygon")
|
|
@@ -377,7 +390,7 @@ export default {
|
|
|
377
390
|
* @private
|
|
378
391
|
*/
|
|
379
392
|
radarCircleX(d): number {
|
|
380
|
-
return this.cache.get(
|
|
393
|
+
return this.cache.get(cacheKeyPoints)[d.id][d.index][0];
|
|
381
394
|
},
|
|
382
395
|
|
|
383
396
|
/**
|
|
@@ -387,6 +400,6 @@ export default {
|
|
|
387
400
|
* @private
|
|
388
401
|
*/
|
|
389
402
|
radarCircleY(d): number {
|
|
390
|
-
return this.cache.get(
|
|
403
|
+
return this.cache.get(cacheKeyPoints)[d.id][d.index][1];
|
|
391
404
|
}
|
|
392
405
|
};
|