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
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import {select as d3Select} from "d3-selection"; // selection
|
|
6
6
|
import {$REGION} from "../../config/classes";
|
|
7
7
|
import {isValue, parseDate} from "../../module/util";
|
|
8
|
-
import type {AxisType} from "../../../types/types";
|
|
8
|
+
import type {AxisType, RegionsType} from "../../../types/types";
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
|
-
initRegion() {
|
|
11
|
+
initRegion(): void {
|
|
12
12
|
const $$ = this;
|
|
13
13
|
const {$el} = $$;
|
|
14
14
|
|
|
@@ -38,7 +38,8 @@ export default {
|
|
|
38
38
|
.style("opacity", "0")
|
|
39
39
|
.remove();
|
|
40
40
|
|
|
41
|
-
const regionsEnter = regions
|
|
41
|
+
const regionsEnter = regions
|
|
42
|
+
.enter()
|
|
42
43
|
.append("g");
|
|
43
44
|
|
|
44
45
|
regionsEnter
|
|
@@ -48,12 +49,22 @@ export default {
|
|
|
48
49
|
region.list = regionsEnter
|
|
49
50
|
.merge(regions)
|
|
50
51
|
.attr("class", $$.classRegion.bind($$));
|
|
52
|
+
|
|
53
|
+
region.list.each(function(d) {
|
|
54
|
+
const g = d3Select(this);
|
|
55
|
+
|
|
56
|
+
if (g.select("text").empty() && d.label?.text) {
|
|
57
|
+
d3Select(this).append("text")
|
|
58
|
+
.style("opacity", "0");
|
|
59
|
+
}
|
|
60
|
+
});
|
|
51
61
|
},
|
|
52
62
|
|
|
53
|
-
redrawRegion(withTransition) {
|
|
63
|
+
redrawRegion(withTransition: boolean) {
|
|
54
64
|
const $$ = this;
|
|
55
65
|
const {$el: {region}, $T} = $$;
|
|
56
66
|
let regions = region.list.select("rect");
|
|
67
|
+
let label = region.list.selectAll("text");
|
|
57
68
|
|
|
58
69
|
regions = $T(regions, withTransition)
|
|
59
70
|
.attr("x", $$.regionX.bind($$))
|
|
@@ -61,6 +72,17 @@ export default {
|
|
|
61
72
|
.attr("width", $$.regionWidth.bind($$))
|
|
62
73
|
.attr("height", $$.regionHeight.bind($$));
|
|
63
74
|
|
|
75
|
+
label = $T(label, withTransition)
|
|
76
|
+
.attr("transform", d => {
|
|
77
|
+
const {x = 0, y = 0, rotated = false} = d.label ?? {};
|
|
78
|
+
|
|
79
|
+
return `translate(${$$.regionX.bind($$)(d) + x}, ${$$.regionY.bind($$)(d) + y})${rotated ? ` rotate(-90)` : ``}`;
|
|
80
|
+
})
|
|
81
|
+
.attr("text-anchor", d => (d.label?.rotated ? "end" : null))
|
|
82
|
+
.attr("dy", "1em")
|
|
83
|
+
.style("fill", d => d.label?.color ?? null)
|
|
84
|
+
.text(d => d.label?.text);
|
|
85
|
+
|
|
64
86
|
return [
|
|
65
87
|
regions
|
|
66
88
|
.style("fill-opacity", d => (isValue(d.opacity) ? d.opacity : null))
|
|
@@ -69,11 +91,12 @@ export default {
|
|
|
69
91
|
d3Select(this.parentNode)
|
|
70
92
|
.selectAll("rect:not([x])")
|
|
71
93
|
.remove();
|
|
72
|
-
})
|
|
94
|
+
}),
|
|
95
|
+
label.style("opacity", null)
|
|
73
96
|
];
|
|
74
97
|
},
|
|
75
98
|
|
|
76
|
-
getRegionXY(type: AxisType, d): number {
|
|
99
|
+
getRegionXY(type: AxisType, d: RegionsType): number {
|
|
77
100
|
const $$ = this;
|
|
78
101
|
const {config, scale} = $$;
|
|
79
102
|
const isRotated = config.axis_rotated;
|
|
@@ -99,15 +122,15 @@ export default {
|
|
|
99
122
|
return pos;
|
|
100
123
|
},
|
|
101
124
|
|
|
102
|
-
regionX(d): number {
|
|
125
|
+
regionX(d: RegionsType): number {
|
|
103
126
|
return this.getRegionXY("x", d);
|
|
104
127
|
},
|
|
105
128
|
|
|
106
|
-
regionY(d): number {
|
|
129
|
+
regionY(d: RegionsType): number {
|
|
107
130
|
return this.getRegionXY("y", d);
|
|
108
131
|
},
|
|
109
132
|
|
|
110
|
-
getRegionSize(type, d): number {
|
|
133
|
+
getRegionSize(type: "width" | "height", d: RegionsType): number {
|
|
111
134
|
const $$ = this;
|
|
112
135
|
const {config, scale, state} = $$;
|
|
113
136
|
const isRotated = config.axis_rotated;
|
|
@@ -134,15 +157,15 @@ export default {
|
|
|
134
157
|
return end < start ? 0 : end - start;
|
|
135
158
|
},
|
|
136
159
|
|
|
137
|
-
regionWidth(d): number {
|
|
160
|
+
regionWidth(d: RegionsType): number {
|
|
138
161
|
return this.getRegionSize("width", d);
|
|
139
162
|
},
|
|
140
163
|
|
|
141
|
-
regionHeight(d): number {
|
|
164
|
+
regionHeight(d: RegionsType): number {
|
|
142
165
|
return this.getRegionSize("height", d);
|
|
143
166
|
},
|
|
144
167
|
|
|
145
|
-
isRegionOnX(d): boolean {
|
|
168
|
+
isRegionOnX(d: RegionsType): boolean {
|
|
146
169
|
return !d.axis || d.axis === "x";
|
|
147
170
|
},
|
|
148
171
|
};
|
|
@@ -160,7 +160,7 @@ export default {
|
|
|
160
160
|
let toggledShape;
|
|
161
161
|
|
|
162
162
|
if (!config.data_selection_multiple) {
|
|
163
|
-
const focusOnly =
|
|
163
|
+
const focusOnly = $$.isPointFocusOnly();
|
|
164
164
|
let selector = `.${focusOnly ? $SELECT.selectedCircles : $SHAPE.shapes}`;
|
|
165
165
|
|
|
166
166
|
if (config.data_selection_grouped) {
|
|
@@ -291,9 +291,6 @@ export default {
|
|
|
291
291
|
const anchorString = getRotateAnchor(angle);
|
|
292
292
|
const rotateString = angle ? `rotate(${angle})` : "";
|
|
293
293
|
|
|
294
|
-
|
|
295
|
-
// $$.meetsLabelThreshold(ratio,
|
|
296
|
-
|
|
297
294
|
$$.$el.text
|
|
298
295
|
.style("fill", $$.getStylePropValue($$.updateTextColor))
|
|
299
296
|
.attr("filter", $$.updateTextBacgroundColor.bind($$))
|
|
@@ -452,7 +449,7 @@ export default {
|
|
|
452
449
|
*/
|
|
453
450
|
getXForText(points, d: IDataRow, textElement): number {
|
|
454
451
|
const $$ = this;
|
|
455
|
-
const {config
|
|
452
|
+
const {config} = $$;
|
|
456
453
|
const isRotated = config.axis_rotated;
|
|
457
454
|
const isTreemapType = $$.isTreemapType(d);
|
|
458
455
|
let xPos = points[0][0];
|
|
@@ -484,17 +481,6 @@ export default {
|
|
|
484
481
|
}
|
|
485
482
|
}
|
|
486
483
|
|
|
487
|
-
// show labels regardless of the domain if value is null
|
|
488
|
-
if (d.value === null) {
|
|
489
|
-
if (xPos > state.width) {
|
|
490
|
-
const {width} = getBoundingRect(textElement);
|
|
491
|
-
|
|
492
|
-
xPos = state.width - width;
|
|
493
|
-
} else if (xPos < 0) {
|
|
494
|
-
xPos = 4;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
484
|
if (isRotated || isTreemapType) {
|
|
499
485
|
xPos += $$.getCenteredTextPos(d, points, textElement, "x");
|
|
500
486
|
}
|
|
@@ -572,17 +558,6 @@ export default {
|
|
|
572
558
|
}
|
|
573
559
|
}
|
|
574
560
|
|
|
575
|
-
// show labels regardless of the domain if value is null
|
|
576
|
-
if (d.value === null && !isRotated) {
|
|
577
|
-
const boxHeight = rect.height;
|
|
578
|
-
|
|
579
|
-
if (yPos < boxHeight) {
|
|
580
|
-
yPos = boxHeight;
|
|
581
|
-
} else if (yPos > state.height) {
|
|
582
|
-
yPos = state.height - 4;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
|
|
586
561
|
if (!isRotated || isTreemapType) {
|
|
587
562
|
yPos += $$.getCenteredTextPos(d, points, textElement, "y");
|
|
588
563
|
}
|
|
@@ -12,7 +12,7 @@ import {$TEXT} from "../../config/classes";
|
|
|
12
12
|
* @returns {string|number} text-anchor value or position in pixel
|
|
13
13
|
* @private
|
|
14
14
|
*/
|
|
15
|
-
function
|
|
15
|
+
function getTextXPos(pos = "left", width?: number | any): number | "start" | "middle" | "end" {
|
|
16
16
|
const isNum = isNumber(width);
|
|
17
17
|
let position;
|
|
18
18
|
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
|
|
42
42
|
const text = $el.title
|
|
43
43
|
.append("text")
|
|
44
|
-
.style("text-anchor",
|
|
44
|
+
.style("text-anchor", getTextXPos(config.title_position))
|
|
45
45
|
.attr("class", $TEXT.title);
|
|
46
46
|
|
|
47
47
|
setTextValue(text, config.title_text, [0.3, 1.5]);
|
|
@@ -57,55 +57,14 @@ export default {
|
|
|
57
57
|
const {config, state: {current}, $el: {title}} = $$;
|
|
58
58
|
|
|
59
59
|
if (title) {
|
|
60
|
-
const
|
|
60
|
+
const x = getTextXPos(config.title_position, current.width);
|
|
61
|
+
const y = (config.title_padding.top || 0) +
|
|
62
|
+
$$.getTextRect($$.$el.title, $TEXT.title).height;
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
title.attr("transform", `translate(${getTextPos(config.title_position, current.width)}, ${y})`);
|
|
64
|
-
} else {
|
|
65
|
-
title.attr("x", $$.xForTitle.call($$)).attr("y", y);
|
|
66
|
-
}
|
|
64
|
+
title.attr("transform", `translate(${x}, ${y})`);
|
|
67
65
|
}
|
|
68
66
|
},
|
|
69
67
|
|
|
70
|
-
/**
|
|
71
|
-
* Returns the x attribute value of the title
|
|
72
|
-
* @returns {number} x attribute value
|
|
73
|
-
* @private
|
|
74
|
-
*/
|
|
75
|
-
xForTitle(): number {
|
|
76
|
-
const $$ = this;
|
|
77
|
-
const {config, state: {current}} = $$;
|
|
78
|
-
const position = config.title_position || "left";
|
|
79
|
-
const textRectWidth = $$.getTextRect($$.$el.title, $TEXT.title).width;
|
|
80
|
-
let x;
|
|
81
|
-
|
|
82
|
-
if (/(right|center)/.test(position)) {
|
|
83
|
-
x = current.width - textRectWidth;
|
|
84
|
-
|
|
85
|
-
if (position.indexOf("right") >= 0) {
|
|
86
|
-
x = current.width - textRectWidth - config.title_padding.right;
|
|
87
|
-
} else if (position.indexOf("center") >= 0) {
|
|
88
|
-
x = (current.width - textRectWidth) / 2;
|
|
89
|
-
}
|
|
90
|
-
} else { // left
|
|
91
|
-
x = (config.title_padding.left || 0);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return x;
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Returns the y attribute value of the title
|
|
99
|
-
* @returns {number} y attribute value
|
|
100
|
-
* @private
|
|
101
|
-
*/
|
|
102
|
-
yForTitle(): number {
|
|
103
|
-
const $$ = this;
|
|
104
|
-
|
|
105
|
-
return ($$.config.title_padding.top || 0) +
|
|
106
|
-
$$.getTextRect($$.$el.title, $TEXT.title).height;
|
|
107
|
-
},
|
|
108
|
-
|
|
109
68
|
/**
|
|
110
69
|
* Get title padding
|
|
111
70
|
* @returns {number} padding value
|
|
@@ -113,7 +72,10 @@ export default {
|
|
|
113
72
|
*/
|
|
114
73
|
getTitlePadding(): number {
|
|
115
74
|
const $$ = this;
|
|
75
|
+
const {$el, config} = $$;
|
|
116
76
|
|
|
117
|
-
return
|
|
77
|
+
return (config.title_padding.top || 0) +
|
|
78
|
+
$$.getTextRect($el.title, $TEXT.title).height +
|
|
79
|
+
(config.title_padding.bottom || 0);
|
|
118
80
|
},
|
|
119
81
|
};
|
|
@@ -6,7 +6,7 @@ import {select as d3Select} from "d3-selection";
|
|
|
6
6
|
import {document} from "../../module/browser";
|
|
7
7
|
import {$ARC, $TOOLTIP} from "../../config/classes";
|
|
8
8
|
import type {IArcData, IDataRow} from "../data/IData";
|
|
9
|
-
import {getPointer, isFunction, isObject, isString, isValue, callFn,
|
|
9
|
+
import {getPointer, isEmpty, isFunction, isObject, isString, isValue, callFn, sanitize, tplProcess, isUndefined, parseDate} from "../../module/util";
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
12
|
/**
|
|
@@ -31,50 +31,36 @@ export default {
|
|
|
31
31
|
$$.bindTooltipResizePos();
|
|
32
32
|
},
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Show tooltip at initialization.
|
|
36
|
+
* Is called only when tooltip.init.show=true option is set
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
34
39
|
initShowTooltip(): void {
|
|
35
40
|
const $$ = this;
|
|
36
41
|
const {config, $el, state: {hasAxis, hasRadar}} = $$;
|
|
37
42
|
|
|
38
43
|
// Show tooltip if needed
|
|
39
44
|
if (config.tooltip_init_show) {
|
|
40
|
-
const isArc = !(hasAxis
|
|
45
|
+
const isArc = !(hasAxis || hasRadar);
|
|
41
46
|
|
|
42
47
|
if ($$.axis?.isTimeSeries() && isString(config.tooltip_init_x)) {
|
|
43
|
-
const targets = $$.data.targets[0];
|
|
44
|
-
let i;
|
|
45
|
-
let val;
|
|
46
|
-
|
|
47
48
|
config.tooltip_init_x = parseDate.call($$, config.tooltip_init_x);
|
|
48
|
-
|
|
49
|
-
for (i = 0; (val = targets.values[i]); i++) {
|
|
50
|
-
if ((val.x - config.tooltip_init_x) === 0) {
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
config.tooltip_init_x = i;
|
|
56
49
|
}
|
|
57
50
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
$$.api.tooltip.show({
|
|
52
|
+
data: {
|
|
53
|
+
[isArc ? "index" : "x"]: config.tooltip_init_x
|
|
54
|
+
}
|
|
62
55
|
});
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
data = [data[config.tooltip_init_x]];
|
|
66
|
-
}
|
|
57
|
+
const position = config.tooltip_init_position;
|
|
67
58
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
$$.axis?.getXAxisTickFormat(),
|
|
71
|
-
$$.getDefaultValueFormat(),
|
|
72
|
-
$$.color
|
|
73
|
-
));
|
|
59
|
+
if (!config.tooltip_contents.bindto && !isEmpty(position)) {
|
|
60
|
+
const {top = 0, left = 50} = position;
|
|
74
61
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.style("left", config.tooltip_init_position.left)
|
|
62
|
+
$el.tooltip.style("top", isString(top) ? top : `${top}px`)
|
|
63
|
+
.style("left", isString(left) ? left : `${left}px`)
|
|
78
64
|
.style("display", null);
|
|
79
65
|
}
|
|
80
66
|
}
|
|
@@ -107,17 +93,23 @@ export default {
|
|
|
107
93
|
const $$ = this;
|
|
108
94
|
const {api, config, state, $el} = $$;
|
|
109
95
|
|
|
110
|
-
|
|
96
|
+
// get formatter function
|
|
97
|
+
const [titleFn, nameFn, valueFn] = ["title", "name", "value"].map(v => {
|
|
111
98
|
const fn = config[`tooltip_format_${v}`];
|
|
112
99
|
|
|
113
100
|
return isFunction(fn) ? fn.bind(api) : fn;
|
|
114
101
|
});
|
|
115
102
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
103
|
+
// determine fotmatter function with sanitization
|
|
104
|
+
const titleFormat = (...arg) => sanitize((titleFn || defaultTitleFormat)(...arg));
|
|
105
|
+
const nameFormat = (...arg) => sanitize((nameFn || (name => name))(...arg));
|
|
106
|
+
const valueFormat = (...arg) => {
|
|
107
|
+
const fn = valueFn || (
|
|
108
|
+
state.hasTreemap || $$.isStackNormalized() ? (v, ratio) => `${(ratio * 100).toFixed(2)}%` : defaultValueFormat
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
return sanitize(fn(...arg));
|
|
112
|
+
};
|
|
121
113
|
|
|
122
114
|
const order = config.tooltip_order;
|
|
123
115
|
const getRowValue = row => ($$.axis && $$.isBubbleZType(row) ? $$.getBubbleZData(row.value, "z") : $$.getBaseValue(row));
|
|
@@ -172,8 +164,7 @@ export default {
|
|
|
172
164
|
}
|
|
173
165
|
|
|
174
166
|
if (isUndefined(text)) {
|
|
175
|
-
const title = (state.hasAxis || state.hasRadar) &&
|
|
176
|
-
sanitise(titleFormat ? titleFormat(row.x) : row.x);
|
|
167
|
+
const title = (state.hasAxis || state.hasRadar) && titleFormat(row.x);
|
|
177
168
|
|
|
178
169
|
text = tplProcess(tpl[0], {
|
|
179
170
|
CLASS_TOOLTIP: $TOOLTIP.tooltip,
|
|
@@ -188,25 +179,30 @@ export default {
|
|
|
188
179
|
row.ratio = $$.getRatio(...param);
|
|
189
180
|
}
|
|
190
181
|
|
|
191
|
-
param
|
|
192
|
-
|
|
182
|
+
// arrange param to be passed to formatter
|
|
183
|
+
param = [row.ratio, row.id, row.index];
|
|
193
184
|
|
|
194
185
|
if ($$.isAreaRangeType(row)) {
|
|
195
|
-
const [high, low] = ["high", "low"].map(v =>
|
|
196
|
-
|
|
197
|
-
));
|
|
186
|
+
const [high, low] = ["high", "low"].map(v => valueFormat($$.getRangedData(row, v), ...param));
|
|
187
|
+
const mid = valueFormat(getRowValue(row), ...param);
|
|
198
188
|
|
|
199
|
-
value = `<b>Mid:</b> ${
|
|
189
|
+
value = `<b>Mid:</b> ${mid} <b>High:</b> ${high} <b>Low:</b> ${low}`;
|
|
200
190
|
} else if ($$.isCandlestickType(row)) {
|
|
201
|
-
const [open, high, low, close, volume] = ["open", "high", "low", "close", "volume"].map(v =>
|
|
202
|
-
|
|
203
|
-
|
|
191
|
+
const [open, high, low, close, volume] = ["open", "high", "low", "close", "volume"].map(v => {
|
|
192
|
+
const value = $$.getRangedData(row, v, "candlestick");
|
|
193
|
+
|
|
194
|
+
return value ? valueFormat(
|
|
195
|
+
$$.getRangedData(row, v, "candlestick"), ...param
|
|
196
|
+
) : undefined;
|
|
197
|
+
});
|
|
204
198
|
|
|
205
199
|
value = `<b>Open:</b> ${open} <b>High:</b> ${high} <b>Low:</b> ${low} <b>Close:</b> ${close}${volume ? ` <b>Volume:</b> ${volume}` : ""}`;
|
|
206
200
|
} else if ($$.isBarRangeType(row)) {
|
|
207
|
-
const [start, end] = row
|
|
201
|
+
const {value: [start, end], id, index} = row;
|
|
208
202
|
|
|
209
|
-
value = `${valueFormat(start)} ~ ${valueFormat(end)}`;
|
|
203
|
+
value = `${valueFormat(start, undefined, id, index)} ~ ${valueFormat(end, undefined, id, index)}`;
|
|
204
|
+
} else {
|
|
205
|
+
value = valueFormat(getRowValue(row), ...param);
|
|
210
206
|
}
|
|
211
207
|
|
|
212
208
|
if (value !== undefined) {
|
|
@@ -215,7 +211,7 @@ export default {
|
|
|
215
211
|
continue;
|
|
216
212
|
}
|
|
217
213
|
|
|
218
|
-
const name =
|
|
214
|
+
const name = nameFormat(row.name, ...param);
|
|
219
215
|
const color = getBgColor(row);
|
|
220
216
|
const contentValue = {
|
|
221
217
|
CLASS_TOOLTIP_NAME: $TOOLTIP.tooltipName + $$.getTargetSelectorSuffix(row.id),
|
|
@@ -267,7 +263,7 @@ export default {
|
|
|
267
263
|
const $$ = this;
|
|
268
264
|
const {config, scale, state, $el: {eventRect, tooltip}} = $$;
|
|
269
265
|
const {bindto} = config.tooltip_contents;
|
|
270
|
-
const datum = tooltip?.datum
|
|
266
|
+
const datum = tooltip?.datum();
|
|
271
267
|
|
|
272
268
|
if (!bindto && datum) {
|
|
273
269
|
const [x, y] = getPointer(state.event, eventTarget ?? eventRect?.node()); // get mouse event position
|
|
@@ -368,7 +364,7 @@ export default {
|
|
|
368
364
|
* @param {SVGElement} eventTarget Event element
|
|
369
365
|
* @private
|
|
370
366
|
*/
|
|
371
|
-
showTooltip(selectedData: IDataRow[], eventTarget
|
|
367
|
+
showTooltip(selectedData: IDataRow[], eventTarget: SVGElement): void {
|
|
372
368
|
const $$ = this;
|
|
373
369
|
const {config, $el: {tooltip}} = $$;
|
|
374
370
|
const dataToShow = selectedData.filter(d => d && isValue($$.getBaseValue(d)));
|
|
@@ -377,7 +373,7 @@ export default {
|
|
|
377
373
|
return;
|
|
378
374
|
}
|
|
379
375
|
|
|
380
|
-
let datum = tooltip
|
|
376
|
+
let datum = tooltip.datum();
|
|
381
377
|
const dataStr = JSON.stringify(selectedData);
|
|
382
378
|
|
|
383
379
|
if (!datum || datum.current !== dataStr) {
|
|
@@ -445,7 +441,7 @@ export default {
|
|
|
445
441
|
const {api, config, $el: {tooltip}} = $$;
|
|
446
442
|
|
|
447
443
|
if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
|
|
448
|
-
const selectedData = JSON.parse(tooltip
|
|
444
|
+
const selectedData = JSON.parse(tooltip.datum().current ?? {});
|
|
449
445
|
|
|
450
446
|
callFn(config.tooltip_onhide, api, selectedData);
|
|
451
447
|
|
|
@@ -1041,8 +1041,8 @@ export default {
|
|
|
1041
1041
|
// touch events
|
|
1042
1042
|
if (isTouch && $$.hasArcType() && !$$.radars) {
|
|
1043
1043
|
const getEventArc = event => {
|
|
1044
|
-
const
|
|
1045
|
-
const eventArc = d3Select(document.elementFromPoint(
|
|
1044
|
+
const {clientX, clientY} = event.changedTouches?.[0] ?? {clientX: 0, clientY: 0};
|
|
1045
|
+
const eventArc = d3Select(document.elementFromPoint(clientX, clientY));
|
|
1046
1046
|
|
|
1047
1047
|
return eventArc;
|
|
1048
1048
|
};
|
|
@@ -35,7 +35,6 @@ export default {
|
|
|
35
35
|
const $$ = this;
|
|
36
36
|
const {$el} = $$;
|
|
37
37
|
const classChart = $$.getChartClass("Candlestick");
|
|
38
|
-
const classFocus = $$.classFocus.bind($$);
|
|
39
38
|
|
|
40
39
|
if (!$el.candlestick) {
|
|
41
40
|
$$.initCandlestick();
|
|
@@ -43,8 +42,7 @@ export default {
|
|
|
43
42
|
|
|
44
43
|
const mainUpdate = $$.$el.main.select(`.${$CANDLESTICK.chartCandlesticks}`)
|
|
45
44
|
.selectAll(`.${$CANDLESTICK.chartCandlestick}`)
|
|
46
|
-
.data(targets)
|
|
47
|
-
.attr("class", d => classChart(d) + classFocus(d));
|
|
45
|
+
.data(targets);
|
|
48
46
|
|
|
49
47
|
mainUpdate.enter().append("g")
|
|
50
48
|
.attr("class", classChart)
|
|
@@ -80,10 +78,6 @@ export default {
|
|
|
80
78
|
candlestickEnter.append("line");
|
|
81
79
|
candlestickEnter.append("path");
|
|
82
80
|
|
|
83
|
-
if (!$root.candlestick) {
|
|
84
|
-
$root.candlestick = {};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
81
|
$root.candlestick = candlestick.merge(candlestickEnter)
|
|
88
82
|
.style("opacity", initialOpacity);
|
|
89
83
|
},
|
|
@@ -157,8 +151,6 @@ export default {
|
|
|
157
151
|
*/
|
|
158
152
|
generateGetCandlestickPoints(indices, isSub = false): (d, i) => number[][] {
|
|
159
153
|
const $$ = this;
|
|
160
|
-
const {config} = $$;
|
|
161
|
-
|
|
162
154
|
const axis = isSub ? $$.axis.subX : $$.axis.x;
|
|
163
155
|
const targetsNum = $$.getIndicesMax(indices) + 1;
|
|
164
156
|
const barW: IOffset = $$.getBarW("candlestick", axis, targetsNum);
|
|
@@ -174,7 +166,7 @@ export default {
|
|
|
174
166
|
const value = $$.getCandlestickData(d);
|
|
175
167
|
let points;
|
|
176
168
|
|
|
177
|
-
if (value) {
|
|
169
|
+
if (value && isNumber(value.open) && isNumber(value.close)) {
|
|
178
170
|
const posX = {
|
|
179
171
|
start: x(d),
|
|
180
172
|
end: 0
|
|
@@ -192,13 +184,6 @@ export default {
|
|
|
192
184
|
low: y(value.low)
|
|
193
185
|
};
|
|
194
186
|
|
|
195
|
-
// fix posY not to overflow opposite quadrant
|
|
196
|
-
if (config.axis_rotated && (
|
|
197
|
-
(d.value > 0 && posY.start < y0) || (d.value < 0 && y0 < posY.start)
|
|
198
|
-
)) {
|
|
199
|
-
posY.start = y0;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
187
|
posY.start -= (y0 - offset);
|
|
203
188
|
|
|
204
189
|
points = [
|
|
@@ -43,7 +43,7 @@ export default {
|
|
|
43
43
|
let opacity = config.point_opacity;
|
|
44
44
|
|
|
45
45
|
if (isUndefined(opacity)) {
|
|
46
|
-
opacity = config.point_show && !
|
|
46
|
+
opacity = config.point_show && !this.isPointFocusOnly() ? null : "0";
|
|
47
47
|
|
|
48
48
|
opacity = isValue(this.getBaseValue(d)) ?
|
|
49
49
|
(this.isBubbleType(d) || this.isScatterType(d) ?
|
|
@@ -126,10 +126,12 @@ export default {
|
|
|
126
126
|
updateCircle(isSub = false): void {
|
|
127
127
|
const $$ = this;
|
|
128
128
|
const {config, state, $el} = $$;
|
|
129
|
-
const focusOnly =
|
|
129
|
+
const focusOnly = $$.isPointFocusOnly();
|
|
130
130
|
const $root = isSub ? $el.subchart : $el;
|
|
131
131
|
|
|
132
132
|
if (config.point_show && !state.toggling) {
|
|
133
|
+
config.point_radialGradient && $$.updateLinearGradient();
|
|
134
|
+
|
|
133
135
|
const circles = $root.main.selectAll(`.${$CIRCLE.circles}`)
|
|
134
136
|
.selectAll(`.${$CIRCLE.circle}`)
|
|
135
137
|
.data(d => (
|
|
@@ -142,7 +144,7 @@ export default {
|
|
|
142
144
|
|
|
143
145
|
circles.enter()
|
|
144
146
|
.filter(Boolean)
|
|
145
|
-
.append($$.point("create", this, $$.pointR.bind($$), $$.
|
|
147
|
+
.append($$.point("create", this, $$.pointR.bind($$), $$.updateCircleColor.bind($$)));
|
|
146
148
|
|
|
147
149
|
$root.circle = $root.main.selectAll(`.${$CIRCLE.circles} .${$CIRCLE.circle}`)
|
|
148
150
|
.style("stroke", $$.getStylePropValue($$.color))
|
|
@@ -150,6 +152,20 @@ export default {
|
|
|
150
152
|
}
|
|
151
153
|
},
|
|
152
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Update circle color
|
|
157
|
+
* @param {object} d Data object
|
|
158
|
+
* @returns {string} Color string
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
updateCircleColor(d: IDataRow): string {
|
|
162
|
+
const $$ = this;
|
|
163
|
+
const fn = $$.getStylePropValue($$.color);
|
|
164
|
+
|
|
165
|
+
return $$.config.point_radialGradient ?
|
|
166
|
+
$$.getGradienColortUrl(d.id) : (fn ? fn(d) : null);
|
|
167
|
+
},
|
|
168
|
+
|
|
153
169
|
redrawCircle(cx: Function, cy: Function, withTransition: boolean, flow, isSub = false) {
|
|
154
170
|
const $$ = this;
|
|
155
171
|
const {state: {rendered}, $el, $T} = $$;
|
|
@@ -160,7 +176,7 @@ export default {
|
|
|
160
176
|
return [];
|
|
161
177
|
}
|
|
162
178
|
|
|
163
|
-
const fn = $$.point("update", $$, cx, cy, $$.
|
|
179
|
+
const fn = $$.point("update", $$, cx, cy, $$.updateCircleColor.bind($$), withTransition, flow, selectedCircles);
|
|
164
180
|
const posAttr = $$.isCirclePoint() ? "c" : "";
|
|
165
181
|
|
|
166
182
|
const t = getRandom();
|
|
@@ -191,10 +207,10 @@ export default {
|
|
|
191
207
|
*/
|
|
192
208
|
showCircleFocus(d?: IDataRow[]): void {
|
|
193
209
|
const $$ = this;
|
|
194
|
-
const {
|
|
210
|
+
const {state: {hasRadar, resizing, toggling, transiting}, $el} = $$;
|
|
195
211
|
let {circle} = $el;
|
|
196
212
|
|
|
197
|
-
if (transiting === false &&
|
|
213
|
+
if (transiting === false && $$.isPointFocusOnly() && circle) {
|
|
198
214
|
const cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$);
|
|
199
215
|
const cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$);
|
|
200
216
|
const withTransition = toggling || isUndefined(d);
|
|
@@ -234,9 +250,9 @@ export default {
|
|
|
234
250
|
*/
|
|
235
251
|
hideCircleFocus(): void {
|
|
236
252
|
const $$ = this;
|
|
237
|
-
const {
|
|
253
|
+
const {$el: {circle}} = $$;
|
|
238
254
|
|
|
239
|
-
if (
|
|
255
|
+
if ($$.isPointFocusOnly() && circle) {
|
|
240
256
|
$$.unexpandCircles();
|
|
241
257
|
circle.style("visibility", "hidden");
|
|
242
258
|
}
|
|
@@ -342,6 +358,18 @@ export default {
|
|
|
342
358
|
selectR(d) : (selectR || $$.pointR(d) * 4);
|
|
343
359
|
},
|
|
344
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Check if point.focus.only option can be applied.
|
|
363
|
+
* @returns {boolean}
|
|
364
|
+
* @private
|
|
365
|
+
*/
|
|
366
|
+
isPointFocusOnly(): boolean {
|
|
367
|
+
const $$ = this;
|
|
368
|
+
|
|
369
|
+
return $$.config.point_focus_only &&
|
|
370
|
+
!$$.hasType("bubble") && !$$.hasType("scatter") && !$$.hasArcType(null, ["radar"]);
|
|
371
|
+
},
|
|
372
|
+
|
|
345
373
|
isWithinCircle(node: SVGElement, r?: number): boolean {
|
|
346
374
|
const mouse = getPointer(this.state.event, node);
|
|
347
375
|
const element = d3Select(node);
|
|
@@ -296,7 +296,7 @@ export default {
|
|
|
296
296
|
bindRadarEvent(): void {
|
|
297
297
|
const $$ = this;
|
|
298
298
|
const {config, state, $el: {radar, svg}} = $$;
|
|
299
|
-
const focusOnly =
|
|
299
|
+
const focusOnly = $$.isPointFocusOnly();
|
|
300
300
|
const {inputType, transiting} = state;
|
|
301
301
|
|
|
302
302
|
if (config.interaction_enabled) {
|