billboard.js 3.11.2 → 3.12.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 +2 -6
- package/dist/billboard.css +5 -1
- package/dist/billboard.js +19431 -24292
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +26 -3
- package/dist/billboard.pkgd.js +22301 -29057
- package/dist/billboard.pkgd.min.js +33 -3
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
- package/dist/plugin/billboardjs-plugin-sparkline.js +423 -1134
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +660 -1524
- package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
- package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
- package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
- package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +339 -1324
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1701 -3424
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2385 -4462
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1783 -3467
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2031 -3979
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
- package/dist/theme/dark.css +5 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +5 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +5 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +5 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +5 -1
- package/dist/theme/modern.min.css +3 -4
- package/dist-esm/billboard.js +9051 -8666
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +19 -25
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +149 -148
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +295 -286
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +235 -234
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +40 -41
- package/package.json +26 -46
- package/src/Chart/api/axis.ts +6 -13
- package/src/Chart/api/chart.ts +12 -11
- package/src/Chart/api/data.ts +8 -7
- package/src/Chart/api/export.ts +28 -21
- package/src/Chart/api/flow.ts +4 -2
- package/src/Chart/api/grid.ts +1 -5
- package/src/Chart/api/load.ts +2 -2
- package/src/Chart/api/regions.ts +29 -5
- package/src/Chart/api/selection.ts +2 -2
- package/src/Chart/api/show.ts +2 -3
- package/src/Chart/api/subchart.ts +2 -2
- package/src/Chart/api/tooltip.ts +5 -7
- package/src/Chart/api/x.ts +2 -2
- package/src/Chart/api/zoom.ts +2 -2
- package/src/ChartInternal/Axis/Axis.ts +119 -44
- package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
- package/src/ChartInternal/ChartInternal.ts +79 -51
- package/src/ChartInternal/data/IData.ts +22 -29
- package/src/ChartInternal/data/convert.helper.ts +66 -68
- package/src/ChartInternal/data/convert.ts +11 -11
- package/src/ChartInternal/data/data.ts +40 -23
- package/src/ChartInternal/data/load.ts +7 -6
- package/src/ChartInternal/interactions/drag.ts +2 -1
- package/src/ChartInternal/interactions/eventrect.ts +54 -25
- package/src/ChartInternal/interactions/flow.ts +14 -4
- package/src/ChartInternal/interactions/interaction.ts +34 -12
- package/src/ChartInternal/interactions/subchart.ts +27 -25
- package/src/ChartInternal/interactions/zoom.ts +29 -18
- package/src/ChartInternal/internals/category.ts +1 -1
- package/src/ChartInternal/internals/class.ts +5 -5
- package/src/ChartInternal/internals/clip.ts +9 -10
- package/src/ChartInternal/internals/color.ts +70 -42
- package/src/ChartInternal/internals/domain.ts +59 -28
- package/src/ChartInternal/internals/format.ts +5 -5
- package/src/ChartInternal/internals/grid.ts +130 -47
- package/src/ChartInternal/internals/legend.ts +99 -66
- package/src/ChartInternal/internals/redraw.ts +3 -2
- package/src/ChartInternal/internals/region.ts +5 -3
- package/src/ChartInternal/internals/scale.ts +28 -15
- package/src/ChartInternal/internals/selection.ts +14 -13
- package/src/ChartInternal/internals/size.axis.ts +18 -10
- package/src/ChartInternal/internals/size.ts +97 -66
- package/src/ChartInternal/internals/style.ts +21 -19
- package/src/ChartInternal/internals/text.ts +64 -39
- package/src/ChartInternal/internals/title.ts +2 -2
- package/src/ChartInternal/internals/tooltip.ts +83 -34
- package/src/ChartInternal/internals/transform.ts +2 -2
- package/src/ChartInternal/internals/type.ts +12 -12
- package/src/ChartInternal/shape/arc.ts +78 -44
- package/src/ChartInternal/shape/area.ts +19 -22
- package/src/ChartInternal/shape/bar.ts +41 -31
- package/src/ChartInternal/shape/bubble.ts +5 -5
- package/src/ChartInternal/shape/candlestick.ts +15 -13
- package/src/ChartInternal/shape/gauge.ts +16 -9
- package/src/ChartInternal/shape/line.ts +62 -46
- package/src/ChartInternal/shape/point.common.ts +1 -4
- package/src/ChartInternal/shape/point.ts +52 -32
- package/src/ChartInternal/shape/polar.ts +4 -2
- package/src/ChartInternal/shape/radar.ts +40 -22
- package/src/ChartInternal/shape/shape.ts +84 -58
- package/src/ChartInternal/shape/treemap.ts +29 -20
- package/src/Plugin/bubblecompare/index.ts +1 -3
- package/src/Plugin/sparkline/index.ts +3 -4
- package/src/Plugin/stanford/ColorScale.ts +3 -2
- package/src/Plugin/stanford/Elements.ts +15 -6
- package/src/Plugin/stanford/Options.ts +5 -5
- package/src/Plugin/stanford/index.ts +13 -9
- package/src/Plugin/tableview/Options.ts +1 -1
- package/src/Plugin/tableview/const.ts +1 -4
- package/src/Plugin/tableview/index.ts +11 -9
- package/src/Plugin/textoverlap/index.ts +4 -6
- package/src/config/Options/Options.ts +3 -3
- package/src/config/Options/axis/axis.ts +36 -0
- package/src/config/Options/axis/x.ts +12 -13
- package/src/config/Options/axis/y.ts +13 -13
- package/src/config/Options/axis/y2.ts +23 -10
- package/src/config/Options/common/color.ts +4 -4
- package/src/config/Options/common/grid.ts +4 -4
- package/src/config/Options/common/legend.ts +13 -14
- package/src/config/Options/common/main.ts +23 -23
- package/src/config/Options/common/point.ts +17 -18
- package/src/config/Options/common/title.ts +2 -2
- package/src/config/Options/common/tooltip.ts +13 -11
- package/src/config/Options/data/axis.ts +2 -2
- package/src/config/Options/data/data.ts +45 -45
- package/src/config/Options/interaction/interaction.ts +1 -1
- package/src/config/Options/interaction/subchart.ts +2 -2
- package/src/config/Options/interaction/zoom.ts +9 -9
- package/src/config/Options/shape/arc.ts +10 -13
- package/src/config/Options/shape/area.ts +5 -7
- package/src/config/Options/shape/bar.ts +8 -10
- package/src/config/Options/shape/bubble.ts +1 -1
- package/src/config/Options/shape/candlestick.ts +2 -2
- package/src/config/Options/shape/donut.ts +4 -4
- package/src/config/Options/shape/gauge.ts +6 -6
- package/src/config/Options/shape/line.ts +3 -3
- package/src/config/Options/shape/pie.ts +5 -5
- package/src/config/Options/shape/polar.ts +3 -3
- package/src/config/Options/shape/radar.ts +2 -2
- package/src/config/Options/shape/scatter.ts +1 -1
- package/src/config/Options/shape/treemap.ts +1 -1
- package/src/config/Store/Element.ts +8 -5
- package/src/config/Store/State.ts +19 -13
- package/src/config/classes.ts +6 -4
- package/src/config/config.ts +1 -1
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/interaction.ts +3 -7
- package/src/config/resolver/shape.ts +11 -12
- package/src/core.ts +2 -3
- package/src/index.esm.ts +2 -6
- package/src/index.ts +2 -2
- package/src/module/Cache.ts +2 -3
- package/src/module/browser.ts +15 -10
- package/src/module/error.ts +9 -8
- package/src/module/generator.ts +3 -5
- package/src/module/util.ts +60 -37
- package/src/module/worker.ts +14 -11
- package/src/scss/billboard.scss +6 -0
- package/src/scss/theme/dark.scss +6 -0
- package/src/scss/theme/datalab.scss +6 -0
- package/src/scss/theme/graph.scss +6 -0
- package/src/scss/theme/insight.scss +6 -0
- package/src/scss/theme/modern.scss +6 -0
- package/types/axis.d.ts +7 -0
- package/types/options.d.ts +7 -0
- package/types/options.shape.d.ts +7 -0
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {drag as d3Drag} from "d3-drag";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
zoom as d3Zoom,
|
|
8
|
+
zoomIdentity as d3ZoomIdentity,
|
|
9
|
+
zoomTransform as d3ZoomTransform
|
|
10
|
+
} from "d3-zoom";
|
|
7
11
|
import {$COMMON, $ZOOM} from "../../config/classes";
|
|
8
12
|
import {callFn, diffDomain, getPointer, isFunction} from "../../module/util";
|
|
9
13
|
|
|
@@ -79,7 +83,8 @@ export default {
|
|
|
79
83
|
* @private
|
|
80
84
|
*/
|
|
81
85
|
// @ts-ignore
|
|
82
|
-
zoom.updateTransformScale = (transform: d3ZoomTransform,
|
|
86
|
+
zoom.updateTransformScale = (transform: d3ZoomTransform,
|
|
87
|
+
correctTransform: boolean): void => {
|
|
83
88
|
const isRotated = config.axis_rotated;
|
|
84
89
|
|
|
85
90
|
// in case of resize, update range of orgXScale
|
|
@@ -102,7 +107,8 @@ export default {
|
|
|
102
107
|
const tX = isRotated ? transform.x : t;
|
|
103
108
|
const tY = isRotated ? t : transform.y;
|
|
104
109
|
|
|
105
|
-
$$.$el.eventRect.property("__zoom",
|
|
110
|
+
$$.$el.eventRect.property("__zoom",
|
|
111
|
+
d3ZoomIdentity.translate(tX, tY).scale(transform.k));
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
if (!$$.state.xTickOffset) {
|
|
@@ -172,7 +178,8 @@ export default {
|
|
|
172
178
|
if (
|
|
173
179
|
!config.zoom_enabled ||
|
|
174
180
|
$$.filterTargetsToShow($$.data.targets).length === 0 ||
|
|
175
|
-
(!scale.zoom && sourceEvent?.type.indexOf("touch") > -1 &&
|
|
181
|
+
(!scale.zoom && sourceEvent?.type.indexOf("touch") > -1 &&
|
|
182
|
+
sourceEvent?.touches.length === 1)
|
|
176
183
|
) {
|
|
177
184
|
return;
|
|
178
185
|
}
|
|
@@ -197,8 +204,8 @@ export default {
|
|
|
197
204
|
// - when .unzoom() is called (event.transform === d3ZoomIdentity)
|
|
198
205
|
const doTransition = config.transition_duration > 0 &&
|
|
199
206
|
!config.subchart_show && (
|
|
200
|
-
|
|
201
|
-
|
|
207
|
+
state.dragging || isUnZoom || !event.sourceEvent
|
|
208
|
+
);
|
|
202
209
|
|
|
203
210
|
$$.redraw({
|
|
204
211
|
withTransition: doTransition,
|
|
@@ -236,9 +243,11 @@ export default {
|
|
|
236
243
|
}
|
|
237
244
|
|
|
238
245
|
// if click, do nothing. otherwise, click interaction will be canceled.
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
if (
|
|
247
|
+
config.zoom_type === "drag" && (
|
|
248
|
+
e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY
|
|
249
|
+
)
|
|
250
|
+
) {
|
|
242
251
|
return;
|
|
243
252
|
}
|
|
244
253
|
|
|
@@ -268,15 +277,17 @@ export default {
|
|
|
268
277
|
const xDomain = subX.domain();
|
|
269
278
|
const delta = 0.015; // arbitrary value
|
|
270
279
|
|
|
271
|
-
const isfullyShown = $$.config.axis_x_inverted ?
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
+
const isfullyShown = $$.config.axis_x_inverted ?
|
|
281
|
+
(
|
|
282
|
+
zoomDomain[0] >= xDomain[0] || (zoomDomain[0] + delta) >= xDomain[0]
|
|
283
|
+
) && (
|
|
284
|
+
xDomain[1] >= zoomDomain[1] || xDomain[1] >= (zoomDomain[1] + delta)
|
|
285
|
+
) :
|
|
286
|
+
(
|
|
287
|
+
zoomDomain[0] <= xDomain[0] || (zoomDomain[0] - delta) <= xDomain[0]
|
|
288
|
+
) && (
|
|
289
|
+
xDomain[1] <= zoomDomain[1] || xDomain[1] <= (zoomDomain[1] - delta)
|
|
290
|
+
);
|
|
280
291
|
|
|
281
292
|
// check if the zoomed chart is fully shown, then reset scale when zoom is out as initial
|
|
282
293
|
if (force || isfullyShown) {
|
|
@@ -94,14 +94,15 @@ export default {
|
|
|
94
94
|
const target = this.getTargetSelectorSuffix(id);
|
|
95
95
|
|
|
96
96
|
// select target & circle
|
|
97
|
-
return `${prefix}.${CLASS.target + target} ${postfix}, ${prefix}.${
|
|
97
|
+
return `${prefix}.${CLASS.target + target} ${postfix}, ${prefix}.${
|
|
98
|
+
CLASS.circles + target
|
|
99
|
+
} ${postfix}`;
|
|
98
100
|
},
|
|
99
101
|
|
|
100
102
|
selectorTargets(idsValue, prefix: string): string[] | null {
|
|
101
103
|
const ids = idsValue || [];
|
|
102
104
|
|
|
103
|
-
return ids.length ?
|
|
104
|
-
ids.map(id => this.selectorTarget(id, prefix)) : null;
|
|
105
|
+
return ids.length ? ids.map(id => this.selectorTarget(id, prefix)) : null;
|
|
105
106
|
},
|
|
106
107
|
|
|
107
108
|
selectorLegend(id: string): string {
|
|
@@ -109,7 +110,6 @@ export default {
|
|
|
109
110
|
},
|
|
110
111
|
|
|
111
112
|
selectorLegends(ids): string[] | null {
|
|
112
|
-
return ids?.length ?
|
|
113
|
-
ids.map(id => this.selectorLegend(id)) : null;
|
|
113
|
+
return ids?.length ? ids.map(id => this.selectorLegend(id)) : null;
|
|
114
114
|
}
|
|
115
115
|
};
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {document, window} from "../../module/browser";
|
|
6
5
|
|
|
7
6
|
export default {
|
|
8
7
|
initClip(): void {
|
|
@@ -27,17 +26,15 @@ export default {
|
|
|
27
26
|
const $$ = this;
|
|
28
27
|
const {config} = $$;
|
|
29
28
|
|
|
30
|
-
if (
|
|
29
|
+
if (
|
|
30
|
+
(!config.clipPath && /-clip$/.test(id)) ||
|
|
31
31
|
(!config.axis_x_clipPath && /-clip-xaxis$/.test(id)) ||
|
|
32
|
-
(!config.axis_y_clipPath && /-clip-yaxis$/.test(id))
|
|
32
|
+
(!config.axis_y_clipPath && /-clip-yaxis$/.test(id))
|
|
33
|
+
) {
|
|
33
34
|
return null;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
window.navigator.appVersion
|
|
38
|
-
.toLowerCase().indexOf("msie 9.") >= 0 : false;
|
|
39
|
-
|
|
40
|
-
return `url(${(isIE9 ? "" : document.URL.split("#")[0])}#${id})`;
|
|
37
|
+
return `url(#${id})`;
|
|
41
38
|
},
|
|
42
39
|
|
|
43
40
|
appendClip(parent, id: string): void {
|
|
@@ -83,7 +80,8 @@ export default {
|
|
|
83
80
|
const left = Math.max(30, margin.left) - (isRotated ? 20 : 0);
|
|
84
81
|
const isInner = config.axis_y_inner;
|
|
85
82
|
|
|
86
|
-
const x = isInner && !isRotated ?
|
|
83
|
+
const x = isInner && !isRotated ?
|
|
84
|
+
(config.axis_y_label.text ? -20 : -1) :
|
|
87
85
|
(isRotated ? -(1 + left) : -(left - 1));
|
|
88
86
|
const y = -(isRotated ? 20 : margin.top);
|
|
89
87
|
const w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0);
|
|
@@ -109,7 +107,8 @@ export default {
|
|
|
109
107
|
clip.idXAxisTickTexts = clipId;
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
if (
|
|
110
|
+
if (
|
|
111
|
+
!config.axis_x_tick_multiline &&
|
|
113
112
|
$$.getAxisTickRotate("x") &&
|
|
114
113
|
newXAxisHeight !== xAxisHeight
|
|
115
114
|
) {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {select as d3Select} from "d3-selection";
|
|
6
5
|
import {scaleOrdinal as d3ScaleOrdinal} from "d3-scale";
|
|
7
|
-
import {
|
|
6
|
+
import {select as d3Select} from "d3-selection";
|
|
7
|
+
import {d3Selection} from "../../../types";
|
|
8
8
|
import {$ARC, $COLOR, $SHAPE} from "../../config/classes";
|
|
9
|
+
import {document} from "../../module/browser";
|
|
9
10
|
import {KEY} from "../../module/Cache";
|
|
10
|
-
import {
|
|
11
|
+
import {isFunction, isObject, isString, notEmpty} from "../../module/util";
|
|
11
12
|
import type {IArcData, IDataRow} from "../data/IData";
|
|
12
|
-
import {d3Selection} from "../../../types";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Set pattern's background color
|
|
@@ -72,7 +72,18 @@ function getColorFromCss(element: d3Selection): string[] {
|
|
|
72
72
|
|
|
73
73
|
// Replacement of d3.schemeCategory10.
|
|
74
74
|
// Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
|
|
75
|
-
const schemeCategory10 = [
|
|
75
|
+
const schemeCategory10 = [
|
|
76
|
+
"#1f77b4",
|
|
77
|
+
"#ff7f0e",
|
|
78
|
+
"#2ca02c",
|
|
79
|
+
"#d62728",
|
|
80
|
+
"#9467bd",
|
|
81
|
+
"#8c564b",
|
|
82
|
+
"#e377c2",
|
|
83
|
+
"#7f7f7f",
|
|
84
|
+
"#bcbd22",
|
|
85
|
+
"#17becf"
|
|
86
|
+
];
|
|
76
87
|
|
|
77
88
|
export default {
|
|
78
89
|
generateColor(): Function {
|
|
@@ -82,7 +93,8 @@ export default {
|
|
|
82
93
|
const callback = config.data_color;
|
|
83
94
|
const ids: string[] = [];
|
|
84
95
|
|
|
85
|
-
let pattern = notEmpty(config.color_pattern) ?
|
|
96
|
+
let pattern = notEmpty(config.color_pattern) ?
|
|
97
|
+
config.color_pattern :
|
|
86
98
|
d3ScaleOrdinal(getColorFromCss($el.chart) || schemeCategory10).range();
|
|
87
99
|
|
|
88
100
|
const originalColorPattern = pattern;
|
|
@@ -114,24 +126,24 @@ export default {
|
|
|
114
126
|
if (isFunction(colors[id])) {
|
|
115
127
|
color = colors[id].bind($$.api)(d);
|
|
116
128
|
|
|
117
|
-
|
|
129
|
+
// if specified, choose that color
|
|
118
130
|
} else if (colors[id]) {
|
|
119
131
|
color = colors[id];
|
|
120
132
|
|
|
121
|
-
|
|
133
|
+
// if not specified, choose from pattern
|
|
122
134
|
} else {
|
|
123
135
|
if (ids.indexOf(id) < 0) {
|
|
124
136
|
ids.push(id);
|
|
125
137
|
}
|
|
126
138
|
|
|
127
|
-
color = isLine ?
|
|
139
|
+
color = isLine ?
|
|
140
|
+
originalColorPattern[ids.indexOf(id) % originalColorPattern.length] :
|
|
128
141
|
pattern[ids.indexOf(id) % pattern.length];
|
|
129
142
|
|
|
130
143
|
colors[id] = color;
|
|
131
144
|
}
|
|
132
145
|
|
|
133
|
-
return isFunction(callback) ?
|
|
134
|
-
callback.bind($$.api)(color, d) : color;
|
|
146
|
+
return isFunction(callback) ? callback.bind($$.api)(color, d) : color;
|
|
135
147
|
};
|
|
136
148
|
},
|
|
137
149
|
|
|
@@ -143,52 +155,66 @@ export default {
|
|
|
143
155
|
const asValue = threshold.unit === "value";
|
|
144
156
|
const max = threshold.max || 100;
|
|
145
157
|
const values = threshold.values &&
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
threshold.values.length ?
|
|
159
|
+
threshold.values :
|
|
160
|
+
[];
|
|
161
|
+
|
|
162
|
+
return notEmpty(threshold) ?
|
|
163
|
+
function(value) {
|
|
164
|
+
const v = asValue ? value : (value * 100 / max);
|
|
165
|
+
let color = colors[colors.length - 1];
|
|
166
|
+
|
|
167
|
+
for (let i = 0, l = values.length; i < l; i++) {
|
|
168
|
+
if (v <= values[i]) {
|
|
169
|
+
color = colors[i];
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
156
172
|
}
|
|
157
|
-
}
|
|
158
173
|
|
|
159
|
-
|
|
160
|
-
|
|
174
|
+
return color;
|
|
175
|
+
} :
|
|
176
|
+
null;
|
|
161
177
|
},
|
|
162
178
|
|
|
163
179
|
/**
|
|
164
180
|
* Append data backgound color filter definition
|
|
165
|
-
* @param {string} color Color string
|
|
181
|
+
* @param {string|object} color Color string
|
|
182
|
+
* @param {object} attr filter attribute
|
|
166
183
|
* @private
|
|
167
184
|
*/
|
|
168
|
-
|
|
185
|
+
generateTextBGColorFilter(color: string | object, attr = {
|
|
186
|
+
x: 0,
|
|
187
|
+
y: 0,
|
|
188
|
+
width: 1,
|
|
189
|
+
height: 1
|
|
190
|
+
}): void {
|
|
169
191
|
const $$ = this;
|
|
170
|
-
const {$el,
|
|
171
|
-
const backgroundColors = color || config.data_labels_backgroundColors;
|
|
192
|
+
const {$el, state} = $$;
|
|
172
193
|
|
|
173
|
-
if (
|
|
194
|
+
if (color) {
|
|
174
195
|
let ids: string[] = [];
|
|
175
196
|
|
|
176
|
-
if (isString(
|
|
197
|
+
if (isString(color)) {
|
|
177
198
|
ids.push("");
|
|
178
|
-
} else if (isObject(
|
|
179
|
-
ids = Object.keys(
|
|
199
|
+
} else if (isObject(color)) {
|
|
200
|
+
ids = Object.keys(color);
|
|
180
201
|
}
|
|
181
202
|
|
|
182
203
|
ids.forEach(v => {
|
|
183
|
-
const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${
|
|
204
|
+
const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${
|
|
205
|
+
isString(color) ? $$.getTargetSelectorSuffix(color) : ""
|
|
206
|
+
}`;
|
|
184
207
|
|
|
185
208
|
$el.defs.append("filter")
|
|
186
|
-
.attr("x",
|
|
187
|
-
.attr("y",
|
|
188
|
-
.attr("width",
|
|
189
|
-
.attr("height",
|
|
209
|
+
.attr("x", attr.x)
|
|
210
|
+
.attr("y", attr.y)
|
|
211
|
+
.attr("width", attr.width)
|
|
212
|
+
.attr("height", attr.height)
|
|
190
213
|
.attr("id", id)
|
|
191
|
-
.html(
|
|
214
|
+
.html(
|
|
215
|
+
`<feFlood flood-color="${v === "" ? color : color[v]}" />
|
|
216
|
+
<feComposite in="SourceGraphic" />`
|
|
217
|
+
);
|
|
192
218
|
});
|
|
193
219
|
}
|
|
194
220
|
},
|
|
@@ -221,8 +247,8 @@ export default {
|
|
|
221
247
|
if ((radialGradient || supportedType) && defs.select(`#${id}`).empty()) {
|
|
222
248
|
const color = $$.color(d);
|
|
223
249
|
const gradient = {
|
|
224
|
-
defs: <null|d3Selection>null,
|
|
225
|
-
stops: <[number, string|Function|null, number][]>[]
|
|
250
|
+
defs: <null | d3Selection>null,
|
|
251
|
+
stops: <[number, string | Function | null, number][]>[]
|
|
226
252
|
};
|
|
227
253
|
|
|
228
254
|
if (radialGradient) {
|
|
@@ -256,9 +282,11 @@ export default {
|
|
|
256
282
|
.attr("y2", y[1]);
|
|
257
283
|
}
|
|
258
284
|
|
|
259
|
-
gradient.stops.forEach((v: [number, string|Function|null, number]) => {
|
|
285
|
+
gradient.stops.forEach((v: [number, string | Function | null, number]) => {
|
|
260
286
|
const [offset, stopColor, stopOpacity] = v;
|
|
261
|
-
const colorValue = isFunction(stopColor) ?
|
|
287
|
+
const colorValue = isFunction(stopColor) ?
|
|
288
|
+
stopColor.bind($$.api)(d.id) :
|
|
289
|
+
stopColor;
|
|
262
290
|
|
|
263
291
|
gradient.defs && gradient.defs.append("stop")
|
|
264
292
|
.attr("offset", offset)
|
|
@@ -3,8 +3,20 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {TYPE, TYPE_BY_CATEGORY} from "../../config/const";
|
|
6
|
+
import {
|
|
7
|
+
brushEmpty,
|
|
8
|
+
diffDomain,
|
|
9
|
+
getBrushSelection,
|
|
10
|
+
getMinMax,
|
|
11
|
+
isDefined,
|
|
12
|
+
isNumber,
|
|
13
|
+
isObject,
|
|
14
|
+
isValue,
|
|
15
|
+
notEmpty,
|
|
16
|
+
parseDate,
|
|
17
|
+
sortValue
|
|
18
|
+
} from "../../module/util";
|
|
6
19
|
import type {IData, TDomainRange} from "../data/IData";
|
|
7
|
-
import {brushEmpty, getBrushSelection, getMinMax, isDefined, notEmpty, isValue, isObject, isNumber, diffDomain, parseDate, sortValue} from "../../module/util";
|
|
8
20
|
|
|
9
21
|
export default {
|
|
10
22
|
getYDomainMinMax(targets, type: "min" | "max"): number | Date | undefined {
|
|
@@ -88,8 +100,7 @@ export default {
|
|
|
88
100
|
return scale[axisId].domain();
|
|
89
101
|
} else {
|
|
90
102
|
return axisId === "y2" ?
|
|
91
|
-
scale.y.domain() :
|
|
92
|
-
// When all data bounds to y2, y Axis domain is called prior y2.
|
|
103
|
+
scale.y.domain() : // When all data bounds to y2, y Axis domain is called prior y2.
|
|
93
104
|
// So, it needs to call to get y2 domain here
|
|
94
105
|
$$.getYDomain(targets, "y2", xDomain);
|
|
95
106
|
}
|
|
@@ -114,15 +125,19 @@ export default {
|
|
|
114
125
|
|
|
115
126
|
// MEMO: avoid inverting domain unexpectedly
|
|
116
127
|
yDomainMin = isValue(yMin) ? yMin : (
|
|
117
|
-
isValue(yMax) ?
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
isValue(yMax) ?
|
|
129
|
+
(
|
|
130
|
+
yDomainMin <= yMax ? yDomainMin : yMax - 10
|
|
131
|
+
) :
|
|
132
|
+
yDomainMin
|
|
120
133
|
);
|
|
121
134
|
|
|
122
135
|
yDomainMax = isValue(yMax) ? yMax : (
|
|
123
|
-
isValue(yMin) ?
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
isValue(yMin) ?
|
|
137
|
+
(
|
|
138
|
+
yMin <= yDomainMax ? yDomainMax : yMin + 10
|
|
139
|
+
) :
|
|
140
|
+
yDomainMax
|
|
126
141
|
);
|
|
127
142
|
|
|
128
143
|
if (isNaN(yDomainMin)) { // set minimum to zero when not number
|
|
@@ -196,7 +211,8 @@ export default {
|
|
|
196
211
|
isAllNegative && (padding.top = -yDomainMax);
|
|
197
212
|
}
|
|
198
213
|
|
|
199
|
-
const domain = isLog ?
|
|
214
|
+
const domain = isLog ?
|
|
215
|
+
[yDomainMin, yDomainMax].map(v => (v < 0 ? 0 : v)) :
|
|
200
216
|
[yDomainMin - padding.bottom, yDomainMax + padding.top];
|
|
201
217
|
|
|
202
218
|
return isInverted ? domain.reverse() : domain;
|
|
@@ -205,14 +221,17 @@ export default {
|
|
|
205
221
|
getXDomainMinMax(targets, type) {
|
|
206
222
|
const $$ = this;
|
|
207
223
|
const configValue = $$.config[`axis_x_${type}`];
|
|
208
|
-
const dataValue = getMinMax(type,
|
|
224
|
+
const dataValue = getMinMax(type,
|
|
225
|
+
targets.map(t => getMinMax(type, t.values.map(v => v.x))));
|
|
209
226
|
let value = isObject(configValue) ? configValue.value : configValue;
|
|
210
227
|
|
|
211
228
|
value = isDefined(value) && $$.axis?.isTimeSeries() ? parseDate.bind(this)(value) : value;
|
|
212
229
|
|
|
213
|
-
if (
|
|
214
|
-
(
|
|
215
|
-
|
|
230
|
+
if (
|
|
231
|
+
isObject(configValue) && configValue.fit && (
|
|
232
|
+
(type === "min" && value < dataValue) || (type === "max" && value > dataValue)
|
|
233
|
+
)
|
|
234
|
+
) {
|
|
216
235
|
value = undefined;
|
|
217
236
|
}
|
|
218
237
|
|
|
@@ -246,7 +265,8 @@ export default {
|
|
|
246
265
|
}
|
|
247
266
|
|
|
248
267
|
let {left = defaultValue, right = defaultValue} = isNumber(padding) ?
|
|
249
|
-
{left: padding, right: padding} :
|
|
268
|
+
{left: padding, right: padding} :
|
|
269
|
+
padding;
|
|
250
270
|
|
|
251
271
|
// when the unit is pixel, convert pixels to axis scale value
|
|
252
272
|
if (padding.unit === "px") {
|
|
@@ -274,7 +294,7 @@ export default {
|
|
|
274
294
|
* @returns {Array} x Axis domain
|
|
275
295
|
* @private
|
|
276
296
|
*/
|
|
277
|
-
getXDomain(targets: IData[]): (Date|number)[] {
|
|
297
|
+
getXDomain(targets: IData[]): (Date | number)[] {
|
|
278
298
|
const $$ = this;
|
|
279
299
|
const {axis, config, scale: {x}} = $$;
|
|
280
300
|
const isInverted = config.axis_x_inverted;
|
|
@@ -302,11 +322,15 @@ export default {
|
|
|
302
322
|
}
|
|
303
323
|
|
|
304
324
|
if (firstX || firstX === 0) {
|
|
305
|
-
min = isTimeSeries ?
|
|
325
|
+
min = isTimeSeries ?
|
|
326
|
+
new Date(firstX.getTime() - padding.left) :
|
|
327
|
+
firstX - padding.left;
|
|
306
328
|
}
|
|
307
329
|
|
|
308
330
|
if (lastX || lastX === 0) {
|
|
309
|
-
max = isTimeSeries ?
|
|
331
|
+
max = isTimeSeries ?
|
|
332
|
+
new Date(lastX.getTime() + padding.right) :
|
|
333
|
+
lastX + padding.right;
|
|
310
334
|
}
|
|
311
335
|
}
|
|
312
336
|
|
|
@@ -330,7 +354,8 @@ export default {
|
|
|
330
354
|
|
|
331
355
|
if (withUpdateXDomain) {
|
|
332
356
|
const domainValue = domain || (!$$.brush || brushEmpty($$)) ?
|
|
333
|
-
org.xDomain :
|
|
357
|
+
org.xDomain :
|
|
358
|
+
getBrushSelection($$).map(subX.invert);
|
|
334
359
|
|
|
335
360
|
x.domain(domainValue);
|
|
336
361
|
// zoomEnabled && $$.zoom.updateScaleExtent();
|
|
@@ -411,7 +436,9 @@ export default {
|
|
|
411
436
|
const isInverted = config.axis_x_inverted;
|
|
412
437
|
|
|
413
438
|
// need to add offset to original value for 'category' type
|
|
414
|
-
const domain = domainValue.map((v, i) =>
|
|
439
|
+
const domain = domainValue.map((v, i) =>
|
|
440
|
+
Number(v) + (i === 0 ? +isInverted : +!isInverted)
|
|
441
|
+
);
|
|
415
442
|
|
|
416
443
|
return domain as T;
|
|
417
444
|
}
|
|
@@ -427,7 +454,7 @@ export default {
|
|
|
427
454
|
* @returns {number}
|
|
428
455
|
* @private
|
|
429
456
|
*/
|
|
430
|
-
convertPixelToScale(type: "x"|"y", pixels: number, domainLength: number): number {
|
|
457
|
+
convertPixelToScale(type: "x" | "y", pixels: number, domainLength: number): number {
|
|
431
458
|
const $$ = this;
|
|
432
459
|
const {config, state} = $$;
|
|
433
460
|
const isRotated = config.axis_rotated;
|
|
@@ -461,13 +488,17 @@ export default {
|
|
|
461
488
|
isInverted && target.reverse();
|
|
462
489
|
|
|
463
490
|
if (target[0] < target[1]) {
|
|
464
|
-
return domain.every((v, i) =>
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
491
|
+
return domain.every((v, i) =>
|
|
492
|
+
(
|
|
493
|
+
i === 0 ?
|
|
494
|
+
(
|
|
495
|
+
isInverted ? +v <= min : +v >= min
|
|
496
|
+
) :
|
|
497
|
+
(
|
|
498
|
+
isInverted ? +v >= max : +v <= max
|
|
499
|
+
)
|
|
500
|
+
) && !(domain.every((v, i) => v === current[i]))
|
|
501
|
+
);
|
|
471
502
|
}
|
|
472
503
|
}
|
|
473
504
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {isArray, isValue, isFunction, isObjectType, isObject} from "../../module/util";
|
|
6
5
|
import type {AxisType} from "../../../types/types";
|
|
6
|
+
import {isArray, isFunction, isObject, isObjectType, isValue} from "../../module/util";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Get formatted
|
|
@@ -16,8 +16,7 @@ import type {AxisType} from "../../../types/types";
|
|
|
16
16
|
function getFormat($$, typeValue: AxisType, v: number): number | string {
|
|
17
17
|
const {config} = $$;
|
|
18
18
|
const type = `axis_${typeValue}_tick_format`;
|
|
19
|
-
const format = config[type] ?
|
|
20
|
-
config[type] : $$.defaultValueFormat;
|
|
19
|
+
const format = config[type] ? config[type] : $$.defaultValueFormat;
|
|
21
20
|
|
|
22
21
|
return format.call($$.api, v);
|
|
23
22
|
}
|
|
@@ -50,7 +49,7 @@ export default {
|
|
|
50
49
|
};
|
|
51
50
|
},
|
|
52
51
|
|
|
53
|
-
defaultValueFormat(v: number|number[]): number|string {
|
|
52
|
+
defaultValueFormat(v: number | number[]): number | string {
|
|
54
53
|
return isArray(v) ? v.join("~") : (isValue(v) ? +v : "");
|
|
55
54
|
},
|
|
56
55
|
|
|
@@ -85,7 +84,8 @@ export default {
|
|
|
85
84
|
} else if (isObjectType(dataLabels.format)) {
|
|
86
85
|
if (dataLabels.format[targetId]) {
|
|
87
86
|
format = dataLabels.format[targetId] === true ?
|
|
88
|
-
defaultFormat :
|
|
87
|
+
defaultFormat :
|
|
88
|
+
dataLabels.format[targetId];
|
|
89
89
|
} else {
|
|
90
90
|
format = () => "";
|
|
91
91
|
}
|