billboard.js 3.11.3 → 3.12.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 +1 -5
- package/dist/billboard.css +13 -1
- package/dist/billboard.js +19672 -24210
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +26 -3
- package/dist/billboard.pkgd.js +24515 -30430
- 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 +429 -1134
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +666 -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 +1387 -1854
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2760 -3959
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3504 -5057
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2906 -4072
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3076 -4506
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
- package/dist/theme/dark.css +12 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +12 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +12 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +12 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +12 -1
- package/dist/theme/modern.min.css +3 -4
- package/dist-esm/billboard.js +9297 -8527
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +20 -27
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +155 -149
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +302 -289
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +236 -236
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +41 -43
- package/package.json +29 -49
- 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 +8 -9
- 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 +87 -55
- package/src/ChartInternal/data/IData.ts +31 -31
- package/src/ChartInternal/data/convert.helper.ts +66 -68
- package/src/ChartInternal/data/convert.ts +11 -11
- package/src/ChartInternal/data/data.ts +51 -27
- package/src/ChartInternal/data/load.ts +7 -6
- package/src/ChartInternal/interactions/drag.ts +2 -1
- package/src/ChartInternal/interactions/eventrect.ts +84 -32
- package/src/ChartInternal/interactions/flow.ts +14 -4
- package/src/ChartInternal/interactions/interaction.ts +51 -22
- 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 +6 -6
- package/src/ChartInternal/internals/clip.ts +8 -4
- 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 +131 -47
- package/src/ChartInternal/internals/legend.ts +93 -61
- package/src/ChartInternal/internals/redraw.ts +6 -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 +98 -67
- package/src/ChartInternal/internals/style.ts +21 -19
- package/src/ChartInternal/internals/text.ts +79 -43
- package/src/ChartInternal/internals/title.ts +2 -2
- package/src/ChartInternal/internals/tooltip.ts +78 -32
- package/src/ChartInternal/internals/transform.ts +4 -4
- package/src/ChartInternal/internals/type.ts +17 -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/funnel.ts +317 -0
- 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 +54 -34
- 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 +31 -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 +34 -14
- 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 +12 -13
- 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 +48 -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/funnel.ts +38 -0
- 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 +20 -13
- package/src/config/classes.ts +14 -4
- package/src/config/config.ts +1 -1
- package/src/config/const.ts +2 -0
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/interaction.ts +3 -7
- package/src/config/resolver/shape.ts +17 -12
- package/src/core.ts +2 -3
- package/src/index.esm.ts +3 -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 +62 -39
- package/src/module/worker.ts +14 -11
- package/src/scss/billboard.scss +18 -0
- package/src/scss/theme/dark.scss +17 -0
- package/src/scss/theme/datalab.scss +17 -0
- package/src/scss/theme/graph.scss +17 -0
- package/src/scss/theme/insight.scss +17 -0
- package/src/scss/theme/modern.scss +17 -0
- package/types/axis.d.ts +17 -0
- package/types/bb.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/options.d.ts +9 -0
- package/types/options.shape.d.ts +26 -1
- package/types/types.d.ts +1 -0
|
@@ -3,10 +3,22 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
|
-
import {document} from "../../module/browser";
|
|
7
6
|
import {$ARC, $TOOLTIP} from "../../config/classes";
|
|
7
|
+
import {document} from "../../module/browser";
|
|
8
|
+
import {
|
|
9
|
+
callFn,
|
|
10
|
+
getPointer,
|
|
11
|
+
isEmpty,
|
|
12
|
+
isFunction,
|
|
13
|
+
isObject,
|
|
14
|
+
isString,
|
|
15
|
+
isUndefined,
|
|
16
|
+
isValue,
|
|
17
|
+
parseDate,
|
|
18
|
+
sanitize,
|
|
19
|
+
tplProcess
|
|
20
|
+
} from "../../module/util";
|
|
8
21
|
import type {IArcData, IDataRow} from "../data/IData";
|
|
9
|
-
import {getPointer, isEmpty, isFunction, isObject, isString, isValue, callFn, sanitize, tplProcess, isUndefined, parseDate} from "../../module/util";
|
|
10
22
|
|
|
11
23
|
export default {
|
|
12
24
|
/**
|
|
@@ -77,7 +89,8 @@ export default {
|
|
|
77
89
|
const {api, config} = $$;
|
|
78
90
|
|
|
79
91
|
return isFunction(config.tooltip_contents) ?
|
|
80
|
-
config.tooltip_contents.bind(api)(...args) :
|
|
92
|
+
config.tooltip_contents.bind(api)(...args) :
|
|
93
|
+
$$.getTooltipContent(...args);
|
|
81
94
|
},
|
|
82
95
|
|
|
83
96
|
/**
|
|
@@ -105,14 +118,19 @@ export default {
|
|
|
105
118
|
const nameFormat = (...arg) => sanitize((nameFn || (name => name))(...arg));
|
|
106
119
|
const valueFormat = (...arg) => {
|
|
107
120
|
const fn = valueFn || (
|
|
108
|
-
state.hasTreemap || $$.isStackNormalized() ?
|
|
121
|
+
state.hasTreemap || $$.isStackNormalized() ?
|
|
122
|
+
(v, ratio) => `${(ratio * 100).toFixed(2)}%` :
|
|
123
|
+
defaultValueFormat
|
|
109
124
|
);
|
|
110
125
|
|
|
111
126
|
return sanitize(fn(...arg));
|
|
112
127
|
};
|
|
113
128
|
|
|
114
129
|
const order = config.tooltip_order;
|
|
115
|
-
const getRowValue =
|
|
130
|
+
const getRowValue =
|
|
131
|
+
row => ($$.axis && $$.isBubbleZType(row) ?
|
|
132
|
+
$$.getBubbleZData(row.value, "z") :
|
|
133
|
+
$$.getBaseValue(row));
|
|
116
134
|
const getBgColor = $$.levelColor ? row => $$.levelColor(row.value) : row => color(row);
|
|
117
135
|
const contents = config.tooltip_contents;
|
|
118
136
|
const tplStr = contents.template;
|
|
@@ -168,9 +186,11 @@ export default {
|
|
|
168
186
|
|
|
169
187
|
text = tplProcess(tpl[0], {
|
|
170
188
|
CLASS_TOOLTIP: $TOOLTIP.tooltip,
|
|
171
|
-
TITLE: isValue(title) ?
|
|
172
|
-
|
|
173
|
-
|
|
189
|
+
TITLE: isValue(title) ?
|
|
190
|
+
(
|
|
191
|
+
tplStr ? title : `<tr><th colspan="2">${title}</th></tr>`
|
|
192
|
+
) :
|
|
193
|
+
""
|
|
174
194
|
});
|
|
175
195
|
}
|
|
176
196
|
|
|
@@ -183,20 +203,29 @@ export default {
|
|
|
183
203
|
param = [row.ratio, row.id, row.index];
|
|
184
204
|
|
|
185
205
|
if ($$.isAreaRangeType(row)) {
|
|
186
|
-
const [high, low] = ["high", "low"].map(v =>
|
|
206
|
+
const [high, low] = ["high", "low"].map(v =>
|
|
207
|
+
valueFormat($$.getRangedData(row, v), ...param)
|
|
208
|
+
);
|
|
187
209
|
const mid = valueFormat(getRowValue(row), ...param);
|
|
188
210
|
|
|
189
211
|
value = `<b>Mid:</b> ${mid} <b>High:</b> ${high} <b>Low:</b> ${low}`;
|
|
190
212
|
} else if ($$.isCandlestickType(row)) {
|
|
191
|
-
const [open, high, low, close, volume] = ["open", "high", "low", "close", "volume"]
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
213
|
+
const [open, high, low, close, volume] = ["open", "high", "low", "close", "volume"]
|
|
214
|
+
.map(v => {
|
|
215
|
+
const value = $$.getRangedData(row, v, "candlestick");
|
|
216
|
+
|
|
217
|
+
return value ?
|
|
218
|
+
valueFormat(
|
|
219
|
+
$$.getRangedData(row, v, "candlestick"),
|
|
220
|
+
...param
|
|
221
|
+
) :
|
|
222
|
+
undefined;
|
|
223
|
+
});
|
|
198
224
|
|
|
199
|
-
value =
|
|
225
|
+
value =
|
|
226
|
+
`<b>Open:</b> ${open} <b>High:</b> ${high} <b>Low:</b> ${low} <b>Close:</b> ${close}${
|
|
227
|
+
volume ? ` <b>Volume:</b> ${volume}` : ""
|
|
228
|
+
}`;
|
|
200
229
|
} else if ($$.isBarRangeType(row)) {
|
|
201
230
|
const {value: rangeValue, id, index} = row;
|
|
202
231
|
|
|
@@ -211,11 +240,13 @@ export default {
|
|
|
211
240
|
continue;
|
|
212
241
|
}
|
|
213
242
|
|
|
214
|
-
const name = nameFormat(row.name, ...param);
|
|
243
|
+
const name = nameFormat(row.name ?? row.id, ...param);
|
|
215
244
|
const color = getBgColor(row);
|
|
216
245
|
const contentValue = {
|
|
217
246
|
CLASS_TOOLTIP_NAME: $TOOLTIP.tooltipName + $$.getTargetSelectorSuffix(row.id),
|
|
218
|
-
COLOR: (tplStr || !$$.patterns) ?
|
|
247
|
+
COLOR: (tplStr || !$$.patterns) ?
|
|
248
|
+
color :
|
|
249
|
+
`<svg><rect style="fill:${color}" width="10" height="10"></rect></svg>`,
|
|
219
250
|
NAME: name,
|
|
220
251
|
VALUE: value
|
|
221
252
|
};
|
|
@@ -245,7 +276,9 @@ export default {
|
|
|
245
276
|
return (tplStr || `<table class="{=CLASS_TOOLTIP}"><tbody>
|
|
246
277
|
{=TITLE}
|
|
247
278
|
{{<tr class="{=CLASS_TOOLTIP_NAME}">
|
|
248
|
-
<td class="name">${
|
|
279
|
+
<td class="name">${
|
|
280
|
+
this.patterns ? `{=COLOR}` : `<span style="background-color:{=COLOR}"></span>`
|
|
281
|
+
}{=NAME}</td>
|
|
249
282
|
<td class="value">{=VALUE}</td>
|
|
250
283
|
</tr>}}
|
|
251
284
|
</tbody></table>`)
|
|
@@ -270,15 +303,21 @@ export default {
|
|
|
270
303
|
const data = dataToShow ?? JSON.parse(datum.current);
|
|
271
304
|
const [x, y] = getPointer(state.event, eventTarget ?? eventRect?.node()); // get mouse event position
|
|
272
305
|
const currPos: {
|
|
273
|
-
x: number,
|
|
306
|
+
x: number,
|
|
307
|
+
y: number,
|
|
308
|
+
xAxis?: number,
|
|
309
|
+
yAxis?: number | (
|
|
274
310
|
(value: number, id?: string, axisId?: string) => number
|
|
275
|
-
)
|
|
311
|
+
)
|
|
312
|
+
} = {x, y};
|
|
276
313
|
|
|
277
314
|
if (state.hasAxis && scale.x && datum && "x" in datum) {
|
|
278
315
|
const getYPos = (value = 0, id?: string, axisId = "y"): number => {
|
|
279
316
|
const scaleFn = scale[id ? $$.axis?.getId(id) : axisId];
|
|
280
317
|
|
|
281
|
-
return scaleFn ?
|
|
318
|
+
return scaleFn ?
|
|
319
|
+
scaleFn(value) + (isRotated ? state.margin.left : state.margin.top) :
|
|
320
|
+
0;
|
|
282
321
|
};
|
|
283
322
|
|
|
284
323
|
currPos.xAxis = scale.x(datum.x) + (
|
|
@@ -298,7 +337,10 @@ export default {
|
|
|
298
337
|
// Get tooltip position
|
|
299
338
|
const pos = config.tooltip_position?.bind($$.api)(
|
|
300
339
|
data,
|
|
301
|
-
width,
|
|
340
|
+
width,
|
|
341
|
+
height,
|
|
342
|
+
eventRect?.node(),
|
|
343
|
+
currPos
|
|
302
344
|
) ?? $$.getTooltipPosition.bind($$)(width, height, currPos);
|
|
303
345
|
|
|
304
346
|
["top", "left"].forEach(v => {
|
|
@@ -322,11 +364,12 @@ export default {
|
|
|
322
364
|
* @returns {object} top, left value
|
|
323
365
|
* @private
|
|
324
366
|
*/
|
|
325
|
-
getTooltipPosition(tWidth: number, tHeight: number,
|
|
326
|
-
{top: number, left: number} {
|
|
367
|
+
getTooltipPosition(tWidth: number, tHeight: number,
|
|
368
|
+
currPos: {[key: string]: number}): {top: number, left: number} {
|
|
327
369
|
const $$ = this;
|
|
328
370
|
const {config, scale, state} = $$;
|
|
329
|
-
const {width, height, current, hasRadar, hasTreemap, isLegendRight, inputType} =
|
|
371
|
+
const {width, height, current, hasFunnel, hasRadar, hasTreemap, isLegendRight, inputType} =
|
|
372
|
+
state;
|
|
330
373
|
const hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
|
|
331
374
|
const isRotated = config.axis_rotated;
|
|
332
375
|
const hasArcType = $$.hasArcType();
|
|
@@ -352,7 +395,7 @@ export default {
|
|
|
352
395
|
x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
|
|
353
396
|
y += (hasGauge ? height : (height / 2) + tHeight) + titlePadding;
|
|
354
397
|
}
|
|
355
|
-
} else if (hasTreemap) {
|
|
398
|
+
} else if (hasFunnel || hasTreemap) {
|
|
356
399
|
y += tHeight;
|
|
357
400
|
} else {
|
|
358
401
|
const padding = {
|
|
@@ -372,7 +415,7 @@ export default {
|
|
|
372
415
|
|
|
373
416
|
// when tooltip left + tWidth > chart's width
|
|
374
417
|
if ((x + tWidth + 15) > chartRight) {
|
|
375
|
-
x -= tWidth + (hasTreemap || hasArcType ? 0 : (isRotated ? size * 2 : 38));
|
|
418
|
+
x -= tWidth + (hasFunnel || hasTreemap || hasArcType ? 0 : (isRotated ? size * 2 : 38));
|
|
376
419
|
}
|
|
377
420
|
|
|
378
421
|
if (y + tHeight > current.height) {
|
|
@@ -475,7 +518,9 @@ export default {
|
|
|
475
518
|
const $$ = this;
|
|
476
519
|
const {api, config, $el: {tooltip}} = $$;
|
|
477
520
|
|
|
478
|
-
if (
|
|
521
|
+
if (
|
|
522
|
+
tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)
|
|
523
|
+
) {
|
|
479
524
|
const selectedData = JSON.parse(tooltip.datum().current ?? {});
|
|
480
525
|
|
|
481
526
|
callFn(config.tooltip_onhide, api, selectedData);
|
|
@@ -561,7 +606,7 @@ export default {
|
|
|
561
606
|
}
|
|
562
607
|
}
|
|
563
608
|
|
|
564
|
-
|
|
609
|
+
// for Arc & Treemap
|
|
565
610
|
} else {
|
|
566
611
|
const {clientX, clientY} = event;
|
|
567
612
|
|
|
@@ -571,7 +616,8 @@ export default {
|
|
|
571
616
|
|
|
572
617
|
if (data) {
|
|
573
618
|
const d = $$.hasArcType() ?
|
|
574
|
-
$$.convertToArcData($$.updateAngle(data)) :
|
|
619
|
+
$$.convertToArcData($$.updateAngle(data)) :
|
|
620
|
+
data?.data;
|
|
575
621
|
|
|
576
622
|
hasTreemap && (target = svg.node());
|
|
577
623
|
d && $$.showTooltip([d], target);
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import {$ARC, $AXIS} from "../../config/classes";
|
|
6
6
|
import {asHalfPixel} from "../../module/util";
|
|
7
7
|
|
|
8
|
-
type TranslateParam = "main" | "context" | "legend" | "x" | "y" | "y2" | "subX" | "arc" | "radar"
|
|
8
|
+
type TranslateParam = "main" | "context" | "legend" | "x" | "y" | "y2" | "subX" | "arc" | "radar"
|
|
9
|
+
| "polar";
|
|
9
10
|
|
|
10
11
|
export default {
|
|
11
12
|
getTranslate(target: TranslateParam, index = 0): string {
|
|
@@ -73,7 +74,6 @@ export default {
|
|
|
73
74
|
transitions.axisY :
|
|
74
75
|
$T(main.select(`.${$AXIS.axisY}`), withTransition);
|
|
75
76
|
|
|
76
|
-
|
|
77
77
|
const y2Axis = transitions?.axisY2 ?
|
|
78
78
|
transitions.axisY2 :
|
|
79
79
|
$T(main.select(`.${$AXIS.axisY2}`), withTransition);
|
|
@@ -91,9 +91,9 @@ export default {
|
|
|
91
91
|
|
|
92
92
|
transformAll(withTransition: boolean, transitions): void {
|
|
93
93
|
const $$ = this;
|
|
94
|
-
const {config, state: {hasAxis, hasTreemap}, $el} = $$;
|
|
94
|
+
const {config, state: {hasAxis, hasFunnel, hasTreemap}, $el} = $$;
|
|
95
95
|
|
|
96
|
-
!hasTreemap && $$.transformMain(withTransition, transitions);
|
|
96
|
+
!hasFunnel && !hasTreemap && $$.transformMain(withTransition, transitions);
|
|
97
97
|
|
|
98
98
|
hasAxis && config.subchart_show &&
|
|
99
99
|
$$.transformContext(withTransition, transitions);
|
|
@@ -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, isNumber, isString} from "../../module/util";
|
|
6
5
|
import {TYPE, TYPE_BY_CATEGORY} from "../../config/const";
|
|
6
|
+
import {isArray, isNumber, isString} from "../../module/util";
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
/**
|
|
@@ -21,7 +21,7 @@ export default {
|
|
|
21
21
|
const {config, state: {withoutFadeIn}} = $$;
|
|
22
22
|
|
|
23
23
|
$$.mapToTargetIds(targetIds).forEach(id => {
|
|
24
|
-
withoutFadeIn[id] =
|
|
24
|
+
withoutFadeIn[id] = type === config.data_types[id];
|
|
25
25
|
config.data_types[id] = type;
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -121,8 +121,7 @@ export default {
|
|
|
121
121
|
const id = isString(d) ? d : d.id;
|
|
122
122
|
const dataType = this.config && (this.config.data_types?.[id] || this.config.data_type);
|
|
123
123
|
|
|
124
|
-
return isArray(type) ?
|
|
125
|
-
type.indexOf(dataType) >= 0 : dataType === type;
|
|
124
|
+
return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
|
|
126
125
|
},
|
|
127
126
|
|
|
128
127
|
hasPointType(): boolean {
|
|
@@ -193,6 +192,10 @@ export default {
|
|
|
193
192
|
return this.isTypeOf(d, "pie");
|
|
194
193
|
},
|
|
195
194
|
|
|
195
|
+
isFunnelType(d): boolean {
|
|
196
|
+
return this.isTypeOf(d, "funnel");
|
|
197
|
+
},
|
|
198
|
+
|
|
196
199
|
isGaugeType(d): boolean {
|
|
197
200
|
return this.isTypeOf(d, "gauge");
|
|
198
201
|
},
|
|
@@ -251,17 +254,19 @@ export default {
|
|
|
251
254
|
*/
|
|
252
255
|
labelishData(d) {
|
|
253
256
|
return this.isBarType(d) ||
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
this.isLineType(d) ||
|
|
258
|
+
this.isScatterType(d) ||
|
|
259
|
+
this.isBubbleType(d) ||
|
|
260
|
+
this.isCandlestickType(d) ||
|
|
261
|
+
this.isFunnelType(d) ||
|
|
262
|
+
this.isRadarType(d) ||
|
|
263
|
+
this.isTreemapType(d) ?
|
|
264
|
+
d.values.filter(v => isNumber(v.value) || Boolean(v.value)) :
|
|
265
|
+
[];
|
|
260
266
|
},
|
|
261
267
|
|
|
262
268
|
barLineBubbleData(d) {
|
|
263
|
-
return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ?
|
|
264
|
-
d.values : [];
|
|
269
|
+
return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
|
|
265
270
|
},
|
|
266
271
|
|
|
267
272
|
// https://github.com/d3/d3-shape#curves
|
|
@@ -2,16 +2,23 @@
|
|
|
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
|
-
import {
|
|
7
|
-
arc as d3Arc,
|
|
8
|
-
pie as d3Pie
|
|
9
|
-
} from "d3-shape";
|
|
10
5
|
import {interpolate as d3Interpolate} from "d3-interpolate";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {callFn, endall, isDefined, isFunction, isNumber, isObject, isUndefined, setTextValue, tplProcess} from "../../module/util";
|
|
6
|
+
import {select as d3Select} from "d3-selection";
|
|
7
|
+
import {arc as d3Arc, pie as d3Pie} from "d3-shape";
|
|
14
8
|
import type {d3Selection} from "../../../types/types";
|
|
9
|
+
import {$ARC, $COMMON, $FOCUS, $GAUGE} from "../../config/classes";
|
|
10
|
+
import {document} from "../../module/browser";
|
|
11
|
+
import {
|
|
12
|
+
callFn,
|
|
13
|
+
endall,
|
|
14
|
+
isDefined,
|
|
15
|
+
isFunction,
|
|
16
|
+
isNumber,
|
|
17
|
+
isObject,
|
|
18
|
+
isUndefined,
|
|
19
|
+
setTextValue,
|
|
20
|
+
tplProcess
|
|
21
|
+
} from "../../module/util";
|
|
15
22
|
import type {IArcData, IArcDataRow, IData} from "../data/IData";
|
|
16
23
|
|
|
17
24
|
/**
|
|
@@ -27,11 +34,14 @@ function getRadiusFn(expandRate = 0) {
|
|
|
27
34
|
const {config, state} = $$;
|
|
28
35
|
const hasMultiArcGauge = $$.hasMultiArcGauge();
|
|
29
36
|
const singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
|
|
30
|
-
const expandWidth = expandRate ?
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
const expandWidth = expandRate ?
|
|
38
|
+
(
|
|
39
|
+
Math.min(
|
|
40
|
+
state.radiusExpanded * expandRate - state.radius,
|
|
41
|
+
singleArcWidth * 0.8 - (1 - expandRate) * 100
|
|
42
|
+
)
|
|
43
|
+
) :
|
|
44
|
+
0;
|
|
35
45
|
|
|
36
46
|
return {
|
|
37
47
|
/**
|
|
@@ -45,7 +55,9 @@ function getRadiusFn(expandRate = 0) {
|
|
|
45
55
|
|
|
46
56
|
return hasMultiArcGauge ?
|
|
47
57
|
state.radius - singleArcWidth * (d.index + 1) :
|
|
48
|
-
isNumber(innerRadius) ?
|
|
58
|
+
isNumber(innerRadius) ?
|
|
59
|
+
innerRadius :
|
|
60
|
+
0;
|
|
49
61
|
},
|
|
50
62
|
|
|
51
63
|
/**
|
|
@@ -98,7 +110,8 @@ function getRadiusFn(expandRate = 0) {
|
|
|
98
110
|
corner = ratio * outerRadius;
|
|
99
111
|
} else {
|
|
100
112
|
corner = isNumber(cornerRadius) ?
|
|
101
|
-
cornerRadius :
|
|
113
|
+
cornerRadius :
|
|
114
|
+
cornerRadius.call($$.api, id, value, outerRadius);
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
return corner;
|
|
@@ -115,14 +128,17 @@ function getRadiusFn(expandRate = 0) {
|
|
|
115
128
|
function getAttrTweenFn(fn: (d: IArcData) => string) {
|
|
116
129
|
return function(d: IArcData): (t: number) => string {
|
|
117
130
|
const getAngleKeyValue = ({startAngle = 0, endAngle = 0, padAngle = 0}) => ({
|
|
118
|
-
startAngle,
|
|
131
|
+
startAngle,
|
|
132
|
+
endAngle,
|
|
133
|
+
padAngle
|
|
119
134
|
});
|
|
120
135
|
|
|
121
136
|
// d3.interpolate interpolates id value, if id is given as color string(ex. gold, silver, etc)
|
|
122
137
|
// to avoid unexpected behavior, interpolate only angle values
|
|
123
138
|
// https://github.com/naver/billboard.js/issues/3321
|
|
124
139
|
const interpolate = d3Interpolate(
|
|
125
|
-
getAngleKeyValue(this._current),
|
|
140
|
+
getAngleKeyValue(this._current),
|
|
141
|
+
getAngleKeyValue(d)
|
|
126
142
|
);
|
|
127
143
|
|
|
128
144
|
this._current = d;
|
|
@@ -144,8 +160,7 @@ export default {
|
|
|
144
160
|
const padding = config[`${dataType}_padding`];
|
|
145
161
|
const startingAngle = config[`${dataType}_startingAngle`] || 0;
|
|
146
162
|
const padAngle = (
|
|
147
|
-
padding ? padding * 0.01 :
|
|
148
|
-
config[`${dataType}_padAngle`]
|
|
163
|
+
padding ? padding * 0.01 : config[`${dataType}_padAngle`]
|
|
149
164
|
) || 0;
|
|
150
165
|
|
|
151
166
|
$$.pie = d3Pie()
|
|
@@ -186,7 +201,8 @@ export default {
|
|
|
186
201
|
// NOTE: inner/outerRadius can be an object by user setting, only for 'pie' type
|
|
187
202
|
state.outerRadius = config.pie_outerRadius;
|
|
188
203
|
state.innerRadius = $$.hasType("donut") || $$.hasType("gauge") ?
|
|
189
|
-
state.radius * state.innerRadiusRatio :
|
|
204
|
+
state.radius * state.innerRadiusRatio :
|
|
205
|
+
innerRadius;
|
|
190
206
|
},
|
|
191
207
|
|
|
192
208
|
/**
|
|
@@ -225,7 +241,7 @@ export default {
|
|
|
225
241
|
const $$ = this;
|
|
226
242
|
const {config} = $$;
|
|
227
243
|
const arcLengthInPercent = config.gauge_arcLength * 3.6;
|
|
228
|
-
let len =
|
|
244
|
+
let len = 2 * (arcLengthInPercent / 360);
|
|
229
245
|
|
|
230
246
|
if (arcLengthInPercent < -360) {
|
|
231
247
|
len = -2;
|
|
@@ -280,7 +296,8 @@ export default {
|
|
|
280
296
|
|
|
281
297
|
const gStart = $$.getStartingAngle();
|
|
282
298
|
const radius = config.gauge_fullCircle || (forRange && !hasGauge) ?
|
|
283
|
-
$$.getArcLength() :
|
|
299
|
+
$$.getArcLength() :
|
|
300
|
+
gStart * -2;
|
|
284
301
|
|
|
285
302
|
if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
|
|
286
303
|
const {gauge_min: gMin, gauge_max: gMax} = config;
|
|
@@ -428,14 +445,14 @@ export default {
|
|
|
428
445
|
`${range}${isPercent ? "%" : ""}`
|
|
429
446
|
);
|
|
430
447
|
})
|
|
431
|
-
.merge(rangeText)
|
|
432
|
-
);
|
|
448
|
+
.merge(rangeText));
|
|
433
449
|
|
|
434
450
|
if ((!state.rendered || (state.rendered && !fixed)) && totalSum > 0) {
|
|
435
451
|
rangeText.attr("transform", (d, i) => $$.transformForArcLabel(pieData[i], true));
|
|
436
452
|
}
|
|
437
453
|
|
|
438
|
-
rangeText.style("opacity",
|
|
454
|
+
rangeText.style("opacity",
|
|
455
|
+
d => (!fixed && (d > totalSum || totalSum === 0) ? "0" : null));
|
|
439
456
|
}
|
|
440
457
|
},
|
|
441
458
|
|
|
@@ -456,13 +473,15 @@ export default {
|
|
|
456
473
|
if (forRange || $$.hasMultiArcGauge()) {
|
|
457
474
|
const y1 = Math.sin(updated.endAngle - Math.PI / 2);
|
|
458
475
|
const rangeTextPosition = config.arc_rangeText_position;
|
|
459
|
-
let x = Math.cos(updated.endAngle - Math.PI / 2) *
|
|
476
|
+
let x = Math.cos(updated.endAngle - Math.PI / 2) *
|
|
477
|
+
(radiusExpanded + (forRange ? 5 : 25));
|
|
460
478
|
let y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
|
|
461
479
|
|
|
462
480
|
if (forRange && rangeTextPosition) {
|
|
463
481
|
const rangeValues = config.arc_rangeText_values;
|
|
464
482
|
const pos = isFunction(rangeTextPosition) ?
|
|
465
|
-
rangeTextPosition(rangeValues[d.index]) :
|
|
483
|
+
rangeTextPosition(rangeValues[d.index]) :
|
|
484
|
+
rangeTextPosition;
|
|
466
485
|
|
|
467
486
|
x += pos?.x ?? 0;
|
|
468
487
|
y += pos?.y ?? 0;
|
|
@@ -488,7 +507,10 @@ export default {
|
|
|
488
507
|
ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
|
|
489
508
|
} else {
|
|
490
509
|
ratio = outerRadius && (
|
|
491
|
-
h ?
|
|
510
|
+
h ?
|
|
511
|
+
(36 / outerRadius > 0.375 ? 1.175 - 36 / outerRadius : 0.8) *
|
|
512
|
+
outerRadius / h :
|
|
513
|
+
0
|
|
492
514
|
);
|
|
493
515
|
}
|
|
494
516
|
|
|
@@ -504,7 +526,7 @@ export default {
|
|
|
504
526
|
id: "data" in d ? d.data.id : d.id,
|
|
505
527
|
value: d.value,
|
|
506
528
|
ratio: this.getRatio("arc", d),
|
|
507
|
-
index: d.index
|
|
529
|
+
index: d.index
|
|
508
530
|
});
|
|
509
531
|
},
|
|
510
532
|
|
|
@@ -515,14 +537,14 @@ export default {
|
|
|
515
537
|
if ($$.shouldShowArcLabel()) {
|
|
516
538
|
selection
|
|
517
539
|
.style("fill", $$.updateTextColor.bind($$))
|
|
518
|
-
.attr("filter",
|
|
540
|
+
.attr("filter", d =>
|
|
541
|
+
$$.updateTextBGColor.bind($$)(d, $$.config.data_labels_backgroundColors))
|
|
519
542
|
.each(function(d) {
|
|
520
543
|
const node = d3Select(this);
|
|
521
544
|
const updated = $$.updateAngle(d);
|
|
522
545
|
const ratio = $$.getRatio("arc", updated);
|
|
523
546
|
const isUnderThreshold = $$.meetsLabelThreshold(ratio,
|
|
524
|
-
["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))?.[0]
|
|
525
|
-
);
|
|
547
|
+
["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))?.[0]);
|
|
526
548
|
|
|
527
549
|
if (isUnderThreshold) {
|
|
528
550
|
const {value} = updated || d;
|
|
@@ -565,7 +587,9 @@ export default {
|
|
|
565
587
|
}
|
|
566
588
|
|
|
567
589
|
const expandDuration = $$.getExpandConfig(d.data.id, "duration");
|
|
568
|
-
const svgArcExpandedSub = $$.getSvgArcExpanded(
|
|
590
|
+
const svgArcExpandedSub = $$.getSvgArcExpanded(
|
|
591
|
+
$$.getExpandConfig(d.data.id, "rate")
|
|
592
|
+
);
|
|
569
593
|
|
|
570
594
|
d3Select(this).selectAll("path")
|
|
571
595
|
.transition()
|
|
@@ -671,7 +695,12 @@ export default {
|
|
|
671
695
|
|
|
672
696
|
const mainPieEnter = mainPieUpdate.enter().append("g")
|
|
673
697
|
.attr("class", classChartArc)
|
|
674
|
-
.call(
|
|
698
|
+
.call(
|
|
699
|
+
this.setCssRule(false, `.${$ARC.chartArcs} text`, [
|
|
700
|
+
"pointer-events:none",
|
|
701
|
+
"text-anchor:middle"
|
|
702
|
+
])
|
|
703
|
+
);
|
|
675
704
|
|
|
676
705
|
mainPieEnter.append("g")
|
|
677
706
|
.attr("class", classArcs)
|
|
@@ -1007,7 +1036,8 @@ export default {
|
|
|
1007
1036
|
|
|
1008
1037
|
backgroundArc.enter()
|
|
1009
1038
|
.append("path")
|
|
1010
|
-
.attr("class", (d, i) =>
|
|
1039
|
+
.attr("class", (d, i) =>
|
|
1040
|
+
`${$ARC.chartArcsBackground} ${$ARC.chartArcsBackground}-${i}`)
|
|
1011
1041
|
.merge(backgroundArc)
|
|
1012
1042
|
.style("fill", (config.gauge_background) || null)
|
|
1013
1043
|
.attr("d", ({id}) => {
|
|
@@ -1139,8 +1169,7 @@ export default {
|
|
|
1139
1169
|
|
|
1140
1170
|
$$.callOverOutForTouch(arcData);
|
|
1141
1171
|
|
|
1142
|
-
isUndefined(id) ?
|
|
1143
|
-
unselectArc() : selectArc(this, arcData, id);
|
|
1172
|
+
isUndefined(id) ? unselectArc() : selectArc(this, arcData, id);
|
|
1144
1173
|
});
|
|
1145
1174
|
}
|
|
1146
1175
|
},
|
|
@@ -1162,11 +1191,13 @@ export default {
|
|
|
1162
1191
|
.attr("transform", d => $$.transformForArcLabel.bind($$)(d))
|
|
1163
1192
|
.style("font-size", d => (
|
|
1164
1193
|
$$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ?
|
|
1165
|
-
`${Math.round(state.radius / 5)}px` :
|
|
1194
|
+
`${Math.round(state.radius / 5)}px` :
|
|
1195
|
+
null
|
|
1166
1196
|
))
|
|
1167
1197
|
.transition()
|
|
1168
1198
|
.duration(duration)
|
|
1169
|
-
.style("opacity",
|
|
1199
|
+
.style("opacity",
|
|
1200
|
+
d => ($$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0"));
|
|
1170
1201
|
|
|
1171
1202
|
hasMultiArcGauge && text.attr("dy", "-.1em");
|
|
1172
1203
|
}
|
|
@@ -1177,7 +1208,8 @@ export default {
|
|
|
1177
1208
|
if (hasGauge) {
|
|
1178
1209
|
const isFullCircle = config.gauge_fullCircle;
|
|
1179
1210
|
|
|
1180
|
-
isFullCircle &&
|
|
1211
|
+
isFullCircle &&
|
|
1212
|
+
text?.attr("dy", `${hasMultiArcGauge ? 0 : Math.round(state.radius / 14)}`);
|
|
1181
1213
|
|
|
1182
1214
|
if (config.gauge_label_show) {
|
|
1183
1215
|
arcs.select(`.${$GAUGE.chartArcsGaugeUnit}`)
|
|
@@ -1185,7 +1217,11 @@ export default {
|
|
|
1185
1217
|
.text(config.gauge_units);
|
|
1186
1218
|
|
|
1187
1219
|
arcs.select(`.${$GAUGE.chartArcsGaugeMin}`)
|
|
1188
|
-
.attr("dx", `${
|
|
1220
|
+
.attr("dx", `${
|
|
1221
|
+
-1 *
|
|
1222
|
+
(state.innerRadius +
|
|
1223
|
+
((state.radius - state.innerRadius) / (isFullCircle ? 1 : 2)))
|
|
1224
|
+
}px`)
|
|
1189
1225
|
.attr("dy", "1.2em")
|
|
1190
1226
|
.text($$.textForGaugeMinMax(config.gauge_min, false));
|
|
1191
1227
|
|
|
@@ -1207,9 +1243,7 @@ export default {
|
|
|
1207
1243
|
getArcElementByIdOrIndex(value: string | number): d3Selection {
|
|
1208
1244
|
const $$ = this;
|
|
1209
1245
|
const {$el: {arcs}} = $$;
|
|
1210
|
-
const filterFn = isNumber(value) ?
|
|
1211
|
-
d => d.index === value :
|
|
1212
|
-
d => d.data.id === value;
|
|
1246
|
+
const filterFn = isNumber(value) ? d => d.index === value : d => d.data.id === value;
|
|
1213
1247
|
|
|
1214
1248
|
return arcs?.selectAll(`.${$COMMON.target} path`)
|
|
1215
1249
|
.filter(filterFn);
|