billboard.js 3.15.1 → 3.16.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/dist/billboard.css +2 -1
- package/dist/billboard.js +333 -102
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +9 -9
- package/dist/billboard.pkgd.js +3023 -1556
- package/dist/billboard.pkgd.min.js +19 -19
- 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 +25 -10
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +25 -10
- package/dist/plugin/billboardjs-plugin-stanford.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-tableview.js +18 -7
- package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-textoverlap.js +18 -7
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -4
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2692 -1456
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +4 -4
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2716 -1465
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -7
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2717 -1466
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +14 -14
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2711 -1464
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +7 -7
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2712 -1465
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -7
- package/dist/theme/dark.css +2 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +2 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +2 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +2 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +2 -1
- package/dist/theme/modern.min.css +2 -2
- package/dist-esm/billboard.js +376 -129
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +9 -5
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +9 -5
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +23 -23
- package/src/Chart/api/category.ts +1 -1
- package/src/Chart/api/chart.ts +12 -0
- package/src/Chart/api/export.ts +11 -4
- package/src/ChartInternal/Axis/Axis.ts +20 -6
- package/src/ChartInternal/Axis/AxisRenderer.ts +17 -4
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/data/convert.ts +17 -4
- package/src/ChartInternal/data/data.ts +27 -38
- package/src/ChartInternal/interactions/eventrect.ts +8 -3
- package/src/ChartInternal/interactions/interaction.ts +3 -2
- package/src/ChartInternal/internals/color.ts +2 -2
- package/src/ChartInternal/internals/domain.ts +6 -2
- package/src/ChartInternal/internals/grid.ts +1 -1
- package/src/ChartInternal/internals/size.ts +16 -5
- package/src/ChartInternal/internals/style.ts +1 -1
- package/src/ChartInternal/internals/text.ts +31 -18
- package/src/ChartInternal/internals/tooltip.ts +2 -1
- package/src/ChartInternal/shape/arc.ts +2 -4
- package/src/ChartInternal/shape/bar.ts +113 -14
- package/src/ChartInternal/shape/candlestick.ts +1 -1
- package/src/ChartInternal/shape/funnel.ts +1 -1
- package/src/ChartInternal/shape/line.ts +6 -2
- package/src/ChartInternal/shape/point.ts +13 -9
- package/src/ChartInternal/shape/radar.ts +3 -2
- package/src/ChartInternal/shape/shape.ts +3 -2
- package/src/ChartInternal/shape/treemap.ts +1 -1
- package/src/config/Options/axis/axis.ts +19 -5
- package/src/config/Options/axis/x.ts +22 -1
- package/src/config/Options/axis/y.ts +20 -0
- package/src/config/Options/axis/y2.ts +33 -0
- package/src/config/Options/shape/bar.ts +1 -0
- package/src/config/Store/State.ts +2 -1
- package/src/config/classes.ts +7 -3
- package/src/module/util.ts +45 -20
- package/src/scss/billboard.scss +1 -0
- package/src/scss/theme/dark.scss +1 -0
- package/src/scss/theme/datalab.scss +1 -0
- package/src/scss/theme/graph.scss +1 -0
- package/src/scss/theme/insight.scss +1 -0
- package/src/scss/theme/modern.scss +1 -0
- package/types/axis.d.ts +12 -0
- package/types/chart.d.ts +10 -0
- package/types/options.shape.d.ts +6 -0
|
@@ -89,8 +89,6 @@ export default {
|
|
|
89
89
|
generateColor(): Function {
|
|
90
90
|
const $$ = this;
|
|
91
91
|
const {$el, config} = $$;
|
|
92
|
-
const colors = config.data_colors;
|
|
93
|
-
const callback = config.data_color;
|
|
94
92
|
const ids: string[] = [];
|
|
95
93
|
|
|
96
94
|
let pattern = notEmpty(config.color_pattern) ?
|
|
@@ -115,6 +113,8 @@ export default {
|
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
return function(d: IDataRow | IArcData | string): string {
|
|
116
|
+
const colors = config.data_colors;
|
|
117
|
+
const callback = config.data_color;
|
|
118
118
|
const id: string = (d as IDataRow).id ||
|
|
119
119
|
(d as IArcData).data?.id ||
|
|
120
120
|
d as string;
|
|
@@ -82,7 +82,7 @@ export default {
|
|
|
82
82
|
.some(v => $$.axis.getId(v) === id);
|
|
83
83
|
},
|
|
84
84
|
|
|
85
|
-
getYDomain(targets, axisId:
|
|
85
|
+
getYDomain(targets: IData[], axisId: "y" | "y2", xDomain: TDomainRange) {
|
|
86
86
|
const $$ = this;
|
|
87
87
|
const {axis, config, scale} = $$;
|
|
88
88
|
const pfx = `axis_${axisId}`;
|
|
@@ -180,7 +180,11 @@ export default {
|
|
|
180
180
|
if (showHorizontalDataLabel) {
|
|
181
181
|
const diff = diffDomain(scale.y.range());
|
|
182
182
|
const ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width")
|
|
183
|
-
.map(v =>
|
|
183
|
+
.map(v => {
|
|
184
|
+
const result = v / diff;
|
|
185
|
+
|
|
186
|
+
return isFinite(result) ? result : 0;
|
|
187
|
+
});
|
|
184
188
|
|
|
185
189
|
["bottom", "top"].forEach((v, i) => {
|
|
186
190
|
padding[v] += domainLength * (ratio[i] / (1 - ratio[0] - ratio[1]));
|
|
@@ -371,7 +371,7 @@ export default {
|
|
|
371
371
|
const $$ = this;
|
|
372
372
|
|
|
373
373
|
$$.$el.main.selectAll(
|
|
374
|
-
`line.
|
|
374
|
+
`line.${$AXIS.axisTooltipX}, line.${$AXIS.axisTooltipY}`
|
|
375
375
|
).style("visibility", "hidden");
|
|
376
376
|
|
|
377
377
|
Object.values($$.$el.axisTooltip)
|
|
@@ -5,7 +5,15 @@
|
|
|
5
5
|
import {$AXIS, $SUBCHART} from "../../config/classes";
|
|
6
6
|
import {document} from "../../module/browser";
|
|
7
7
|
import {KEY} from "../../module/Cache";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
capitalize,
|
|
10
|
+
ceil10,
|
|
11
|
+
getBoundingRect,
|
|
12
|
+
isEmpty,
|
|
13
|
+
isNumber,
|
|
14
|
+
isString,
|
|
15
|
+
isUndefined
|
|
16
|
+
} from "../../module/util";
|
|
9
17
|
|
|
10
18
|
export default {
|
|
11
19
|
/**
|
|
@@ -47,7 +55,7 @@ export default {
|
|
|
47
55
|
|
|
48
56
|
while (v < 30 && parent && parent.tagName !== "BODY") {
|
|
49
57
|
try {
|
|
50
|
-
v = parent
|
|
58
|
+
v = getBoundingRect(parent, true)[key];
|
|
51
59
|
} catch {
|
|
52
60
|
if (offsetName in parent) {
|
|
53
61
|
// In IE in certain cases getBoundingClientRect
|
|
@@ -103,12 +111,15 @@ export default {
|
|
|
103
111
|
const label = $el.main.select(`.${leftAxisClass}-label`);
|
|
104
112
|
|
|
105
113
|
if (!label.empty()) {
|
|
106
|
-
labelWidth = label.node()
|
|
114
|
+
labelWidth = getBoundingRect(label.node()).left;
|
|
107
115
|
}
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
const svgRect = leftAxis && hasLeftAxisRect ?
|
|
111
|
-
|
|
118
|
+
const svgRect = leftAxis && hasLeftAxisRect ?
|
|
119
|
+
getBoundingRect(leftAxis, !withoutRecompute) :
|
|
120
|
+
{right: 0};
|
|
121
|
+
const chartRectLeft = getBoundingRect($el.chart.node(), !withoutRecompute).left +
|
|
122
|
+
labelWidth;
|
|
112
123
|
const hasArc = $$.hasArcType();
|
|
113
124
|
const svgLeft = svgRect.right - chartRectLeft -
|
|
114
125
|
(hasArc ? 0 : $$.getCurrentPaddingByDirection("left", withoutRecompute));
|
|
@@ -51,6 +51,6 @@ export default {
|
|
|
51
51
|
getStylePropValue(v: Function | string): string | null {
|
|
52
52
|
const {config: {boost_useCssRule: useCssRule}} = this;
|
|
53
53
|
|
|
54
|
-
return useCssRule ? null : isFunction(v) ? v.bind(this) : v;
|
|
54
|
+
return useCssRule ? null : isFunction(v) ? v.bind(this) : v as string;
|
|
55
55
|
}
|
|
56
56
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {select as d3Select, selectAll as d3SelectAll} from "d3-selection";
|
|
6
|
-
import type {AxisType} from "../../../types/types";
|
|
6
|
+
import type {AxisType, d3Selection} from "../../../types/types";
|
|
7
7
|
import {$COMMON, $TEXT} from "../../config/classes";
|
|
8
8
|
import {KEY} from "../../module/Cache";
|
|
9
9
|
import {
|
|
@@ -155,7 +155,7 @@ export default {
|
|
|
155
155
|
const classFocus = $$.classFocus.bind($$);
|
|
156
156
|
const mainTextUpdate = $$.$el.main.select(`.${$TEXT.chartTexts}`)
|
|
157
157
|
.selectAll(`.${$TEXT.chartText}`)
|
|
158
|
-
.data(targets)
|
|
158
|
+
.data($$.filterNullish(targets))
|
|
159
159
|
.attr("class", d => `${classChartText(d)}${classFocus(d)}`.trim());
|
|
160
160
|
|
|
161
161
|
const mainTextEnter = mainTextUpdate.enter().append("g")
|
|
@@ -348,38 +348,51 @@ export default {
|
|
|
348
348
|
|
|
349
349
|
/**
|
|
350
350
|
* Gets the getBoundingClientRect value of the element
|
|
351
|
-
* @param {HTMLElement|d3.selection}
|
|
351
|
+
* @param {HTMLElement|d3.selection|Array} source Target element
|
|
352
352
|
* @param {string} className Class name
|
|
353
353
|
* @returns {object} value of element.getBoundingClientRect()
|
|
354
354
|
* @private
|
|
355
355
|
*/
|
|
356
|
-
getTextRect(
|
|
356
|
+
getTextRect(source: d3Selection | SVGElement | number[], className: string): DOMRect[] {
|
|
357
357
|
const $$ = this;
|
|
358
|
-
let
|
|
358
|
+
let cacheKey;
|
|
359
|
+
let base;
|
|
360
|
+
let text;
|
|
359
361
|
|
|
360
|
-
if (
|
|
361
|
-
|
|
362
|
+
if (Array.isArray(source)) {
|
|
363
|
+
cacheKey = `${KEY.textRect}-${source.join("_")}`;
|
|
364
|
+
} else {
|
|
365
|
+
base = (source as d3Selection).node?.() ?? source as SVGElement;
|
|
366
|
+
|
|
367
|
+
if (!/text/i.test(base.tagName)) {
|
|
368
|
+
base = base.querySelector("text");
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
text = base.textContent;
|
|
372
|
+
cacheKey = `${KEY.textRect}-${text.replace(/\W/g, "_")}`;
|
|
362
373
|
}
|
|
363
374
|
|
|
364
|
-
const
|
|
365
|
-
const cacheKey = `${KEY.textRect}-${text.replace(/\W/g, "_")}`;
|
|
366
|
-
let rect = $$.cache.get(cacheKey);
|
|
375
|
+
const rect = $$.cache.get(cacheKey) || [];
|
|
367
376
|
|
|
368
|
-
if (
|
|
369
|
-
$$.$el.svg.
|
|
377
|
+
if (rect.length === 0) {
|
|
378
|
+
($$.$el.svg || $$.$el.chart.select("svg"))
|
|
379
|
+
.selectAll(`.${$COMMON.dummy}`)
|
|
380
|
+
.data(text ? [text] : source)
|
|
381
|
+
.enter()
|
|
382
|
+
.append("text")
|
|
370
383
|
.style("visibility", "hidden")
|
|
371
|
-
.style("font", d3Select(base).style("font"))
|
|
372
|
-
.classed(className, true)
|
|
373
|
-
.text(
|
|
374
|
-
.
|
|
375
|
-
rect = getBoundingRect(
|
|
384
|
+
.style("font", base ? d3Select(base).style("font") : null)
|
|
385
|
+
.classed(className || $COMMON.dummy, true)
|
|
386
|
+
.text(d => d)
|
|
387
|
+
.each(function(v, i) {
|
|
388
|
+
rect[i] = getBoundingRect(this);
|
|
376
389
|
})
|
|
377
390
|
.remove();
|
|
378
391
|
|
|
379
392
|
$$.cache.add(cacheKey, rect);
|
|
380
393
|
}
|
|
381
394
|
|
|
382
|
-
return rect;
|
|
395
|
+
return rect.length > 1 ? rect : rect[0];
|
|
383
396
|
},
|
|
384
397
|
|
|
385
398
|
/**
|
|
@@ -7,6 +7,7 @@ import {$ARC, $TOOLTIP} from "../../config/classes";
|
|
|
7
7
|
import {document} from "../../module/browser";
|
|
8
8
|
import {
|
|
9
9
|
callFn,
|
|
10
|
+
getBoundingRect,
|
|
10
11
|
getPointer,
|
|
11
12
|
getTransformCTM,
|
|
12
13
|
hasViewBox,
|
|
@@ -387,7 +388,7 @@ export default {
|
|
|
387
388
|
|
|
388
389
|
// currPos value based on SVG coordinate
|
|
389
390
|
const ctm = getTransformCTM(target, x, y, false);
|
|
390
|
-
const rect = target
|
|
391
|
+
const rect = getBoundingRect(target);
|
|
391
392
|
const size = getTransformCTM(target, 20, 0, false).x;
|
|
392
393
|
|
|
393
394
|
let top = ctm.y;
|
|
@@ -55,9 +55,7 @@ function getRadiusFn(expandRate = 0) {
|
|
|
55
55
|
|
|
56
56
|
return hasMultiArcGauge ?
|
|
57
57
|
state.radius - singleArcWidth * (d.index + 1) :
|
|
58
|
-
isNumber(innerRadius) ?
|
|
59
|
-
innerRadius :
|
|
60
|
-
0;
|
|
58
|
+
(isNumber(innerRadius) ? innerRadius : 0);
|
|
61
59
|
},
|
|
62
60
|
|
|
63
61
|
/**
|
|
@@ -786,7 +784,7 @@ export default {
|
|
|
786
784
|
}
|
|
787
785
|
|
|
788
786
|
return tplProcess(title, {
|
|
789
|
-
NEEDLE_VALUE:
|
|
787
|
+
NEEDLE_VALUE: ~~value
|
|
790
788
|
});
|
|
791
789
|
}
|
|
792
790
|
|
|
@@ -2,20 +2,34 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import {select as d3Select} from "d3-selection";
|
|
6
|
+
import type {d3Selection, DataRow} from "../../../types/types";
|
|
6
7
|
import {$BAR, $COMMON} from "../../config/classes";
|
|
7
8
|
import {getRandom, isNumber} from "../../module/util";
|
|
8
9
|
import type {IBarData} from "../data/IData";
|
|
9
10
|
import type {IOffset} from "./shape";
|
|
10
11
|
|
|
11
12
|
type BarTypeDataRow = DataRow<number | number[]>;
|
|
13
|
+
type BarConnectLine = {x: number, y: number, width: number, height: number};
|
|
14
|
+
type BarPath = (string | BarConnectLine)[];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get the type of connect line for bar chart
|
|
18
|
+
* @param {string} id Data id
|
|
19
|
+
* @returns {string|null} Connect line type or null if not applicable
|
|
20
|
+
*/
|
|
21
|
+
function getConnectLineType(id: string): string | null {
|
|
22
|
+
const connectLine = this.config.bar_connectLine;
|
|
23
|
+
const type = connectLine?.[id] || connectLine;
|
|
24
|
+
|
|
25
|
+
return (/^(start|end)\-(start|end)$/.test(type)) ? type : null;
|
|
26
|
+
}
|
|
12
27
|
|
|
13
28
|
export default {
|
|
14
29
|
initBar(): void {
|
|
15
30
|
const {$el, config, state: {clip}} = this;
|
|
16
31
|
|
|
17
32
|
$el.bar = $el.main.select(`.${$COMMON.chart}`);
|
|
18
|
-
|
|
19
33
|
$el.bar = config.bar_front ? $el.bar.append("g") : $el.bar.insert("g", ":first-child");
|
|
20
34
|
|
|
21
35
|
$el.bar
|
|
@@ -47,12 +61,7 @@ export default {
|
|
|
47
61
|
|
|
48
62
|
const mainBarUpdate = $el.main.select(`.${$BAR.chartBars}`)
|
|
49
63
|
.selectAll(`.${$BAR.chartBar}`)
|
|
50
|
-
.data(
|
|
51
|
-
// remove
|
|
52
|
-
targets.filter(
|
|
53
|
-
v => v.values.some(d => (isNumber(d.value) || $$.isBarRangeType(d)))
|
|
54
|
-
)
|
|
55
|
-
)
|
|
64
|
+
.data($$.filterNullish(targets))
|
|
56
65
|
.attr("class", d => classChartBar(d) + classFocus(d));
|
|
57
66
|
|
|
58
67
|
const mainBarEnter = mainBarUpdate.enter().append("g")
|
|
@@ -64,7 +73,17 @@ export default {
|
|
|
64
73
|
mainBarEnter.append("g")
|
|
65
74
|
.attr("class", classBars)
|
|
66
75
|
.style("cursor", d => (isSelectable?.bind?.($$.api)(d) ? "pointer" : null))
|
|
67
|
-
.call(
|
|
76
|
+
.call(selection => {
|
|
77
|
+
$$.setCssRule(true, ` .${$BAR.bar}`, ["fill"], $$.color)(selection);
|
|
78
|
+
|
|
79
|
+
// add bar connect line
|
|
80
|
+
selection.each(function(d) {
|
|
81
|
+
if (getConnectLineType.call($$, d.id)) {
|
|
82
|
+
d3Select(this).append("path")
|
|
83
|
+
.attr("class", $BAR.barConnectLine);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
68
87
|
},
|
|
69
88
|
|
|
70
89
|
/**
|
|
@@ -106,7 +125,7 @@ export default {
|
|
|
106
125
|
* @returns {string} Color string
|
|
107
126
|
* @private
|
|
108
127
|
*/
|
|
109
|
-
updateBarColor(d: IBarData): string {
|
|
128
|
+
updateBarColor(d: IBarData): string | null {
|
|
110
129
|
const $$ = this;
|
|
111
130
|
const fn = $$.getStylePropValue($$.color);
|
|
112
131
|
|
|
@@ -124,10 +143,32 @@ export default {
|
|
|
124
143
|
redrawBar(drawFn, withTransition?: boolean, isSub = false) {
|
|
125
144
|
const $$ = this;
|
|
126
145
|
const {bar} = isSub ? $$.$el.subchart : $$.$el;
|
|
146
|
+
const barPath: BarConnectLine[] = [];
|
|
127
147
|
|
|
128
148
|
return [
|
|
129
149
|
$$.$T(bar, withTransition, getRandom())
|
|
130
|
-
.attr("d",
|
|
150
|
+
.attr("d", function(d, i, arr) {
|
|
151
|
+
const path = (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d, i);
|
|
152
|
+
const connectLineType = getConnectLineType.call($$, d.id);
|
|
153
|
+
|
|
154
|
+
// for bar.coonectLine option
|
|
155
|
+
if (path.length > 1) {
|
|
156
|
+
barPath.push(path[1]);
|
|
157
|
+
|
|
158
|
+
if (i === arr.length - 1) {
|
|
159
|
+
const barConnectLineNode = $$.$T(
|
|
160
|
+
d3Select(this.parentNode.querySelector(`.${$BAR.barConnectLine}`)),
|
|
161
|
+
withTransition,
|
|
162
|
+
getRandom()
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
$$.updateConnectLine(barConnectLineNode, connectLineType, barPath);
|
|
166
|
+
barPath.splice(0);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return path[0];
|
|
171
|
+
})
|
|
131
172
|
.style("fill", $$.updateBarColor.bind($$))
|
|
132
173
|
.style("clip-path", d => d.clipPath)
|
|
133
174
|
.style("opacity", null)
|
|
@@ -154,7 +195,7 @@ export default {
|
|
|
154
195
|
* @returns {Function}
|
|
155
196
|
* @private
|
|
156
197
|
*/
|
|
157
|
-
generateDrawBar(barIndices, isSub?: boolean): (d: IBarData, i: number) =>
|
|
198
|
+
generateDrawBar(barIndices, isSub?: boolean): (d: IBarData, i: number) => BarPath {
|
|
158
199
|
const $$ = this;
|
|
159
200
|
const {config} = $$;
|
|
160
201
|
const getPoints = $$.generateGetBarPoints(barIndices, isSub);
|
|
@@ -167,7 +208,7 @@ export default {
|
|
|
167
208
|
isNumber(barRadiusRatio) ? w => w * barRadiusRatio : null
|
|
168
209
|
);
|
|
169
210
|
|
|
170
|
-
return (d: IBarData, i: number) => {
|
|
211
|
+
return (d: IBarData, i: number): BarPath => {
|
|
171
212
|
// 4 points that make a bar
|
|
172
213
|
const points = getPoints(d, i);
|
|
173
214
|
|
|
@@ -245,7 +286,25 @@ export default {
|
|
|
245
286
|
points[3][indexY]
|
|
246
287
|
}`;
|
|
247
288
|
|
|
248
|
-
|
|
289
|
+
const coords: BarPath = [`M${points[0][indexX]},${points[0][indexY]}${path}z`];
|
|
290
|
+
|
|
291
|
+
if (getConnectLineType.call($$, d.id)) {
|
|
292
|
+
coords.push(isRotated ?
|
|
293
|
+
{
|
|
294
|
+
x: points[0][indexX],
|
|
295
|
+
y: points[0][indexY],
|
|
296
|
+
width: points[0][indexX] - pos,
|
|
297
|
+
height: points[2][indexY] - points[0][indexY]
|
|
298
|
+
} :
|
|
299
|
+
{
|
|
300
|
+
x: points[0][indexX],
|
|
301
|
+
y: pos,
|
|
302
|
+
width: points[2][indexX] - points[0][indexX],
|
|
303
|
+
height: points[3][indexY] - pos
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return coords;
|
|
249
308
|
};
|
|
250
309
|
},
|
|
251
310
|
|
|
@@ -343,5 +402,45 @@ export default {
|
|
|
343
402
|
[startPosX, offset]
|
|
344
403
|
];
|
|
345
404
|
};
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Update the bar connect line path
|
|
409
|
+
* @param {d3Selection} node d3 selection of bar connect line
|
|
410
|
+
* @param {string} type Type of connect line, one of "start-start", "start-end", "end-start", "end-end"
|
|
411
|
+
* @param {Array} barPath d3 path data for the bar
|
|
412
|
+
*/
|
|
413
|
+
updateConnectLine(
|
|
414
|
+
node: d3Selection,
|
|
415
|
+
type: "start-start" | "start-end" | "end-start" | "end-end",
|
|
416
|
+
barPath: BarConnectLine[]
|
|
417
|
+
): void {
|
|
418
|
+
const path = barPath.map((v: BarConnectLine, i: number, arr: BarConnectLine[]): string => {
|
|
419
|
+
const isRotated = this.config.axis_rotated;
|
|
420
|
+
const isStart = /^start-(start|end)$/.test(type);
|
|
421
|
+
const isEnd = /^end-(start|end)$/.test(type);
|
|
422
|
+
const path: string[] = [];
|
|
423
|
+
|
|
424
|
+
const x = isRotated ? (isEnd ? v.x - v.width : v.x) : (v.x + v.width);
|
|
425
|
+
const y = isRotated ? v.y + v.height : isStart ? v.y + v.height : v.y;
|
|
426
|
+
|
|
427
|
+
if (i === 0) {
|
|
428
|
+
path.push(`${x},${y}`);
|
|
429
|
+
} else {
|
|
430
|
+
path.push(
|
|
431
|
+
isRotated ?
|
|
432
|
+
`L${v.x - (/\w+-end$/.test(type) ? v.width : 0)},${v.y}` :
|
|
433
|
+
`L${v.x},${v.y + (/\w+-start$/.test(type) ? v.height : 0)}`
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
if (i < arr.length - 1) {
|
|
437
|
+
path.push(`M${x},${y}`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return path.join(" ");
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
node.attr("d", `M${path.join("")}z`);
|
|
346
445
|
}
|
|
347
446
|
};
|
|
@@ -42,7 +42,7 @@ export default {
|
|
|
42
42
|
|
|
43
43
|
const mainUpdate = $$.$el.main.select(`.${$CANDLESTICK.chartCandlesticks}`)
|
|
44
44
|
.selectAll(`.${$CANDLESTICK.chartCandlestick}`)
|
|
45
|
-
.data(targets);
|
|
45
|
+
.data($$.filterNullish(targets));
|
|
46
46
|
|
|
47
47
|
mainUpdate.enter().append("g")
|
|
48
48
|
.attr("class", classChart)
|
|
@@ -103,7 +103,7 @@ export default {
|
|
|
103
103
|
|
|
104
104
|
const mainLineUpdate = main.select(`.${$LINE.chartLines}`)
|
|
105
105
|
.selectAll(`.${$LINE.chartLine}`)
|
|
106
|
-
.data(targets)
|
|
106
|
+
.data($$.filterNullish(targets))
|
|
107
107
|
.attr("class", d => classChartLine(d) + classFocus(d));
|
|
108
108
|
|
|
109
109
|
const mainLineEnter = mainLineUpdate.enter().append("g")
|
|
@@ -254,6 +254,10 @@ export default {
|
|
|
254
254
|
const regions = config.data_regions[d.id];
|
|
255
255
|
|
|
256
256
|
if (regions) {
|
|
257
|
+
if ($$.isAreaRangeType(d)) {
|
|
258
|
+
values = values.map(dv => ({...dv, value: $$.getRangedData(dv, "mid")}));
|
|
259
|
+
}
|
|
260
|
+
|
|
257
261
|
path = $$.lineWithRegions(values, scale.zoom || x, y, regions);
|
|
258
262
|
} else {
|
|
259
263
|
if ($$.isStepType(d)) {
|
|
@@ -440,7 +444,7 @@ export default {
|
|
|
440
444
|
}
|
|
441
445
|
|
|
442
446
|
if (dashArray.dash.length) {
|
|
443
|
-
// if not last x tick, then should draw rest of path that is not
|
|
447
|
+
// if not last x tick, then should draw rest of path that is not drawn yet
|
|
444
448
|
!isLastX && dashArray.dash.push(getLength(tempNode, path));
|
|
445
449
|
|
|
446
450
|
tempNode.remove();
|
|
@@ -6,6 +6,7 @@ import {select as d3Select} from "d3-selection";
|
|
|
6
6
|
import type {d3Selection} from "../../../types/types";
|
|
7
7
|
import {$CIRCLE, $COMMON, $SELECT} from "../../config/classes";
|
|
8
8
|
import {
|
|
9
|
+
getBBox,
|
|
9
10
|
getBoundingRect,
|
|
10
11
|
getPointer,
|
|
11
12
|
getRandom,
|
|
@@ -82,7 +83,7 @@ export default {
|
|
|
82
83
|
|
|
83
84
|
// only for scatter & bubble type should generate seprate <g> node
|
|
84
85
|
if (!targets) {
|
|
85
|
-
targets = data.targets
|
|
86
|
+
targets = $$.filterNullish(data.targets)
|
|
86
87
|
.filter(d => this.isScatterType(d) || this.isBubbleType(d));
|
|
87
88
|
|
|
88
89
|
const mainCircle = $el.main.select(`.${$CIRCLE.chartCircles}`)
|
|
@@ -134,12 +135,15 @@ export default {
|
|
|
134
135
|
|
|
135
136
|
const circles = $root.main.selectAll(`.${$CIRCLE.circles}`)
|
|
136
137
|
.selectAll(`.${$CIRCLE.circle}`)
|
|
137
|
-
.data(d =>
|
|
138
|
-
($$.isLineType(d) && $$.shouldDrawPointsForLine(d)) ||
|
|
139
|
-
|
|
138
|
+
.data(d => {
|
|
139
|
+
const data = ($$.isLineType(d) && $$.shouldDrawPointsForLine(d)) ||
|
|
140
|
+
$$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ?
|
|
140
141
|
(focusOnly ? [d.values[0]] : d.values) :
|
|
141
|
-
[]
|
|
142
|
-
|
|
142
|
+
[];
|
|
143
|
+
|
|
144
|
+
// return data;
|
|
145
|
+
return $$.filterNullish(data);
|
|
146
|
+
});
|
|
143
147
|
|
|
144
148
|
circles.exit().remove();
|
|
145
149
|
|
|
@@ -161,7 +165,7 @@ export default {
|
|
|
161
165
|
* @returns {string} Color string
|
|
162
166
|
* @private
|
|
163
167
|
*/
|
|
164
|
-
updateCircleColor(d: IDataRow): string {
|
|
168
|
+
updateCircleColor(d: IDataRow): string | null {
|
|
165
169
|
const $$ = this;
|
|
166
170
|
const fn = $$.getStylePropValue($$.color);
|
|
167
171
|
|
|
@@ -298,7 +302,7 @@ export default {
|
|
|
298
302
|
if (this.tagName === "circle") {
|
|
299
303
|
point.attr("r", r);
|
|
300
304
|
} else {
|
|
301
|
-
const {width, height} =
|
|
305
|
+
const {width, height} = getBBox(this);
|
|
302
306
|
const x = ratio * (+point.attr("x") + width / 2);
|
|
303
307
|
const y = ratio * (+point.attr("y") + height / 2);
|
|
304
308
|
|
|
@@ -484,7 +488,7 @@ export default {
|
|
|
484
488
|
|
|
485
489
|
update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
|
486
490
|
const $$ = this;
|
|
487
|
-
const {width, height} = element.node()
|
|
491
|
+
const {width, height} = getBBox(element.node());
|
|
488
492
|
|
|
489
493
|
const xPosFn2 = d => (isValue(d.value) ? xPosFn(d) - width / 2 : 0);
|
|
490
494
|
const yPosFn2 = d => (isValue(d.value) ? yPosFn(d) - height / 2 : 0);
|
|
@@ -6,6 +6,7 @@ import {select as d3Select} from "d3-selection";
|
|
|
6
6
|
import {$AXIS, $COMMON, $LEVEL, $RADAR, $SHAPE, $TEXT} from "../../config/classes";
|
|
7
7
|
import {KEY} from "../../module/Cache";
|
|
8
8
|
import {
|
|
9
|
+
getBoundingRect,
|
|
9
10
|
getMinMax,
|
|
10
11
|
getPathBox,
|
|
11
12
|
getRange,
|
|
@@ -293,7 +294,7 @@ export default {
|
|
|
293
294
|
.attr("transform", function(d) {
|
|
294
295
|
if (isUndefined(this.width)) {
|
|
295
296
|
// cache evaluated axis text width
|
|
296
|
-
this.width = this
|
|
297
|
+
this.width = getBoundingRect(this, true).width / 2;
|
|
297
298
|
}
|
|
298
299
|
|
|
299
300
|
let posX = $$.getRadarPosition("x", d.index, undefined, 1);
|
|
@@ -387,7 +388,7 @@ export default {
|
|
|
387
388
|
|
|
388
389
|
const areas = $$.$el.radar.shapes
|
|
389
390
|
.selectAll("polygon")
|
|
390
|
-
.data(targets);
|
|
391
|
+
.data($$.filterNullish(targets));
|
|
391
392
|
|
|
392
393
|
const areasEnter = areas.enter().append("g")
|
|
393
394
|
.attr("class", $$.getChartClass("Radar"));
|
|
@@ -27,6 +27,7 @@ import type {d3Selection} from "../../../types/types";
|
|
|
27
27
|
import CLASS from "../../config/classes";
|
|
28
28
|
import {
|
|
29
29
|
capitalize,
|
|
30
|
+
getBBox,
|
|
30
31
|
getPointer,
|
|
31
32
|
getRectSegList,
|
|
32
33
|
getUnique,
|
|
@@ -204,7 +205,7 @@ export default {
|
|
|
204
205
|
return ind;
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
return notEmpty(xs) ? indices[xs[id]] : indices;
|
|
208
|
+
return notEmpty(xs) ? indices[xs[id]] : indices as IDataIndice;
|
|
208
209
|
},
|
|
209
210
|
|
|
210
211
|
/**
|
|
@@ -590,7 +591,7 @@ export default {
|
|
|
590
591
|
const x = Math.min(seg0.x, seg1.x);
|
|
591
592
|
const y = Math.min(seg0.y, seg1.y);
|
|
592
593
|
const offset = this.config.bar_sensitivity;
|
|
593
|
-
const {width, height} =
|
|
594
|
+
const {width, height} = getBBox(that, true);
|
|
594
595
|
const sx = x - offset;
|
|
595
596
|
const ex = x + width + offset;
|
|
596
597
|
const sy = y + height + offset;
|
|
@@ -212,7 +212,7 @@ export default {
|
|
|
212
212
|
const treemapData = getHierachyData.call($$, $$.getTreemapData(targets ?? $$.data.targets));
|
|
213
213
|
|
|
214
214
|
// using $el.treemap reference can alter data, so select treemap <g> again
|
|
215
|
-
treemap.data(treemapData);
|
|
215
|
+
treemap.data($$.filterNullish(treemapData));
|
|
216
216
|
},
|
|
217
217
|
|
|
218
218
|
/**
|
|
@@ -18,27 +18,41 @@ export default {
|
|
|
18
18
|
* @memberof Options
|
|
19
19
|
* @type {boolean|Function}
|
|
20
20
|
* @default true
|
|
21
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.AxisEvalTextSize)
|
|
21
22
|
* @example
|
|
22
23
|
* axis: {
|
|
23
24
|
* // will evaluate getting text size every time.
|
|
24
25
|
* evalTextSize: false.
|
|
25
26
|
*
|
|
26
27
|
* // set a custom evaluator
|
|
27
|
-
* evalTextSize: function(textElement) {
|
|
28
|
+
* evalTextSize: function(textElement, axisId) {
|
|
28
29
|
* // set some character to be evaluated
|
|
29
|
-
*
|
|
30
|
+
* // NOTE: The dummy textElement is a descendant of given axisId('x', 'y' or 'y2').
|
|
31
|
+
* textElement.textContent = "0";
|
|
30
32
|
*
|
|
31
33
|
* // get the size
|
|
32
|
-
*
|
|
34
|
+
* const box = textElement.getBBox();
|
|
33
35
|
*
|
|
34
36
|
* // clear text
|
|
35
|
-
*
|
|
37
|
+
* textElement.textContent = "";
|
|
36
38
|
*
|
|
37
39
|
* return { w: 7, h: 12};
|
|
40
|
+
* },
|
|
41
|
+
*
|
|
42
|
+
* // set a custom evaluator by returning fixed value
|
|
43
|
+
* evalTextSize: function(textElement, axisId) {
|
|
44
|
+
* return {
|
|
45
|
+
* x: {w: 7, h: 12},
|
|
46
|
+
* y: {w: 15.75, h: 30},
|
|
47
|
+
* y2: {w: 9.5, h: 18}
|
|
48
|
+
* }[axisId];
|
|
38
49
|
* }
|
|
39
50
|
* }
|
|
40
51
|
*/
|
|
41
|
-
axis_evalTextSize: <
|
|
52
|
+
axis_evalTextSize: <
|
|
53
|
+
| boolean
|
|
54
|
+
| ((text: SVGTextElement, axisId: "x" | "y" | "y2") => {w: number, h: number})
|
|
55
|
+
>true,
|
|
42
56
|
|
|
43
57
|
/**
|
|
44
58
|
* Switch x and y axis position.
|