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
|
@@ -2,31 +2,42 @@
|
|
|
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";
|
|
5
6
|
import {
|
|
6
|
-
|
|
7
|
-
curveStepAfter as d3CurveStepAfter,
|
|
7
|
+
curveBasis as d3CurveBasis,
|
|
8
8
|
curveBasisClosed as d3CurveBasisClosed,
|
|
9
9
|
curveBasisOpen as d3CurveBasisOpen,
|
|
10
|
-
curveBasis as d3CurveBasis,
|
|
11
10
|
curveBundle as d3CurveBundle,
|
|
11
|
+
curveCardinal as d3CurveCardinal,
|
|
12
12
|
curveCardinalClosed as d3CurveCardinalClosed,
|
|
13
13
|
curveCardinalOpen as d3CurveCardinalOpen,
|
|
14
|
-
|
|
14
|
+
curveCatmullRom as d3CurveCatmullRom,
|
|
15
15
|
curveCatmullRomClosed as d3CurveCatmullRomClosed,
|
|
16
16
|
curveCatmullRomOpen as d3CurveCatmullRomOpen,
|
|
17
|
-
curveCatmullRom as d3CurveCatmullRom,
|
|
18
|
-
curveLinearClosed as d3CurveLinearClosed,
|
|
19
17
|
curveLinear as d3CurveLinear,
|
|
18
|
+
curveLinearClosed as d3CurveLinearClosed,
|
|
20
19
|
curveMonotoneX as d3CurveMonotoneX,
|
|
21
20
|
curveMonotoneY as d3CurveMonotoneY,
|
|
22
21
|
curveNatural as d3CurveNatural,
|
|
23
|
-
curveStep as d3CurveStep
|
|
22
|
+
curveStep as d3CurveStep,
|
|
23
|
+
curveStepAfter as d3CurveStepAfter,
|
|
24
|
+
curveStepBefore as d3CurveStepBefore
|
|
24
25
|
} from "d3-shape";
|
|
25
|
-
import {select as d3Select} from "d3-selection";
|
|
26
26
|
import type {d3Selection} from "../../../types/types";
|
|
27
27
|
import CLASS from "../../config/classes";
|
|
28
|
-
import {
|
|
29
|
-
|
|
28
|
+
import {
|
|
29
|
+
capitalize,
|
|
30
|
+
getPointer,
|
|
31
|
+
getRectSegList,
|
|
32
|
+
getUnique,
|
|
33
|
+
isNumber,
|
|
34
|
+
isObjectType,
|
|
35
|
+
isUndefined,
|
|
36
|
+
isValue,
|
|
37
|
+
notEmpty,
|
|
38
|
+
parseDate
|
|
39
|
+
} from "../../module/util";
|
|
40
|
+
import type {IDataIndice, IDataRow, TIndices} from "../data/IData";
|
|
30
41
|
|
|
31
42
|
/**
|
|
32
43
|
* Get grouped data point function for y coordinate
|
|
@@ -50,7 +61,7 @@ function getGroupedDataPointsFn(d) {
|
|
|
50
61
|
|
|
51
62
|
export interface IOffset {
|
|
52
63
|
_$width: number;
|
|
53
|
-
_$total: number[]
|
|
64
|
+
_$total: number[];
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
export default {
|
|
@@ -60,11 +71,7 @@ export default {
|
|
|
60
71
|
* @private
|
|
61
72
|
*/
|
|
62
73
|
getDrawShape() {
|
|
63
|
-
type TShape = {
|
|
64
|
-
area?: any;
|
|
65
|
-
bar?: any;
|
|
66
|
-
line?: any;
|
|
67
|
-
};
|
|
74
|
+
type TShape = {area?: any, bar?: any, line?: any};
|
|
68
75
|
|
|
69
76
|
const $$ = this;
|
|
70
77
|
const isRotated = $$.config.axis_rotated;
|
|
@@ -74,9 +81,12 @@ export default {
|
|
|
74
81
|
!hasTreemap && ["bar", "candlestick", "line", "area"].forEach(v => {
|
|
75
82
|
const name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
|
|
76
83
|
|
|
77
|
-
if (
|
|
78
|
-
v
|
|
79
|
-
|
|
84
|
+
if (
|
|
85
|
+
$$.hasType(v) || $$.hasTypeOf(name) || (
|
|
86
|
+
v === "line" &&
|
|
87
|
+
($$.hasType("bubble") || $$.hasType("scatter"))
|
|
88
|
+
)
|
|
89
|
+
) {
|
|
80
90
|
const indices = $$.getShapeIndices($$[`is${name}Type`]);
|
|
81
91
|
const drawFn = $$[`generateDraw${name}`];
|
|
82
92
|
|
|
@@ -112,10 +122,10 @@ export default {
|
|
|
112
122
|
* From the below example, indices will be:
|
|
113
123
|
* ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
|
|
114
124
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
125
|
+
* data1 data3 data1 data3
|
|
126
|
+
* data2 data4 data2 data4
|
|
127
|
+
* -------------------------
|
|
128
|
+
* 0 1
|
|
119
129
|
* @param {Function} typeFilter Chart type filter function
|
|
120
130
|
* @returns {object} Indices object with its position
|
|
121
131
|
*/
|
|
@@ -193,8 +203,7 @@ export default {
|
|
|
193
203
|
return ind;
|
|
194
204
|
}
|
|
195
205
|
|
|
196
|
-
return notEmpty(xs) ?
|
|
197
|
-
indices[xs[id]] : indices;
|
|
206
|
+
return notEmpty(xs) ? indices[xs[id]] : indices;
|
|
198
207
|
},
|
|
199
208
|
|
|
200
209
|
/**
|
|
@@ -208,7 +217,8 @@ export default {
|
|
|
208
217
|
// if is multiple xs, return total sum of xs' __max__ value
|
|
209
218
|
Object.keys(indices)
|
|
210
219
|
.map(v => indices[v].__max__ || 0)
|
|
211
|
-
.reduce((acc, curr) => acc + curr) :
|
|
220
|
+
.reduce((acc, curr) => acc + curr) :
|
|
221
|
+
(indices as IDataIndice).__max__;
|
|
212
222
|
},
|
|
213
223
|
|
|
214
224
|
getShapeX(offset: IOffset, indices, isSub?: boolean): (d) => number {
|
|
@@ -236,14 +246,14 @@ export default {
|
|
|
236
246
|
if (halfWidth) {
|
|
237
247
|
const offsetWidth = offset[d.id] || offset._$width;
|
|
238
248
|
|
|
239
|
-
x = barOverlap ?
|
|
240
|
-
|
|
241
|
-
|
|
249
|
+
x = barOverlap ? xPos - offsetWidth / 2 : xPos - offsetWidth +
|
|
250
|
+
offset._$total.slice(0, index + 1).reduce(sum) -
|
|
251
|
+
halfWidth;
|
|
242
252
|
} else {
|
|
243
253
|
x = xPos - (isNumber(offset) ? offset : offset._$width) *
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
254
|
+
(targetsNum / 2 - (
|
|
255
|
+
barOverlap ? 1 : index
|
|
256
|
+
));
|
|
247
257
|
}
|
|
248
258
|
}
|
|
249
259
|
|
|
@@ -312,7 +322,9 @@ export default {
|
|
|
312
322
|
*/
|
|
313
323
|
getShapeOffsetData(typeFilter) {
|
|
314
324
|
const $$ = this;
|
|
315
|
-
const targets = $$.orderTargets(
|
|
325
|
+
const targets = $$.orderTargets(
|
|
326
|
+
$$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
|
|
327
|
+
);
|
|
316
328
|
const isStackNormalized = $$.isStackNormalized();
|
|
317
329
|
|
|
318
330
|
const shapeOffsetTargets = targets.map(target => {
|
|
@@ -349,7 +361,9 @@ export default {
|
|
|
349
361
|
|
|
350
362
|
getShapeOffset(typeFilter, indices, isSub?: boolean): Function {
|
|
351
363
|
const $$ = this;
|
|
352
|
-
const {shapeOffsetTargets, indexMapByTargetId} = $$.getShapeOffsetData(
|
|
364
|
+
const {shapeOffsetTargets, indexMapByTargetId} = $$.getShapeOffsetData(
|
|
365
|
+
typeFilter
|
|
366
|
+
);
|
|
353
367
|
const groupsZeroAs = $$.config.data_groupsZeroAs;
|
|
354
368
|
|
|
355
369
|
return (d, idx) => {
|
|
@@ -369,7 +383,12 @@ export default {
|
|
|
369
383
|
shapeOffsetTargets
|
|
370
384
|
.filter(t => t.id !== id && ind[t.id] === ind[id])
|
|
371
385
|
.forEach(t => {
|
|
372
|
-
const {
|
|
386
|
+
const {
|
|
387
|
+
id: tid,
|
|
388
|
+
rowValueMapByXValue,
|
|
389
|
+
rowValues,
|
|
390
|
+
values: tvalues
|
|
391
|
+
} = t;
|
|
373
392
|
|
|
374
393
|
// for same stacked group (ind[tid] === ind[id])
|
|
375
394
|
if (indexMapByTargetId[tid] < indexMapByTargetId[id]) {
|
|
@@ -382,10 +401,13 @@ export default {
|
|
|
382
401
|
}
|
|
383
402
|
|
|
384
403
|
if (row?.value * value >= 0 && isNumber(rValue)) {
|
|
385
|
-
const addOffset = value === 0 ?
|
|
386
|
-
(
|
|
387
|
-
|
|
388
|
-
|
|
404
|
+
const addOffset = value === 0 ?
|
|
405
|
+
(
|
|
406
|
+
(groupsZeroAs === "positive" &&
|
|
407
|
+
rValue > 0) ||
|
|
408
|
+
(groupsZeroAs === "negative" && rValue < 0)
|
|
409
|
+
) :
|
|
410
|
+
true;
|
|
389
411
|
|
|
390
412
|
if (addOffset) {
|
|
391
413
|
offset += scale(rValue) - y0;
|
|
@@ -414,9 +436,7 @@ export default {
|
|
|
414
436
|
points = getGroupedDataPointsFn.bind($$)(d);
|
|
415
437
|
}
|
|
416
438
|
|
|
417
|
-
return points ?
|
|
418
|
-
points(d, i)[0][1] :
|
|
419
|
-
$$.getYScaleById(id)($$.getBaseValue(d));
|
|
439
|
+
return points ? points(d, i)[0][1] : $$.getYScaleById(id)($$.getBaseValue(d));
|
|
420
440
|
},
|
|
421
441
|
|
|
422
442
|
getBarW(type, axis, targetsNum: number): number | IOffset {
|
|
@@ -448,7 +468,8 @@ export default {
|
|
|
448
468
|
const ratio = id ? width.ratio : config[`${configName}_ratio`];
|
|
449
469
|
const max = id ? width.max : config[`${configName}_max`];
|
|
450
470
|
const w = isNumber(width) ?
|
|
451
|
-
width :
|
|
471
|
+
width :
|
|
472
|
+
(targetsNum ? (tickInterval * ratio) / targetsNum : 0);
|
|
452
473
|
|
|
453
474
|
return max && w > max ? max : w;
|
|
454
475
|
};
|
|
@@ -480,7 +501,7 @@ export default {
|
|
|
480
501
|
getShapeByIndex(shapeName: string, i: number, id?: string): d3Selection {
|
|
481
502
|
const $$ = this;
|
|
482
503
|
const {$el} = $$;
|
|
483
|
-
const suffix =
|
|
504
|
+
const suffix = isValue(i) ? `-${i}` : ``;
|
|
484
505
|
let shape = $el[shapeName];
|
|
485
506
|
|
|
486
507
|
// filter from shape reference if has
|
|
@@ -489,8 +510,12 @@ export default {
|
|
|
489
510
|
.filter(d => (id ? d.id === id : true))
|
|
490
511
|
.filter(d => (isValue(i) ? d.index === i : true));
|
|
491
512
|
} else {
|
|
492
|
-
shape = (id ?
|
|
493
|
-
|
|
513
|
+
shape = (id ?
|
|
514
|
+
$el.main
|
|
515
|
+
.selectAll(
|
|
516
|
+
`.${CLASS[`${shapeName}s`]}${$$.getTargetSelectorSuffix(id)}`
|
|
517
|
+
) :
|
|
518
|
+
$el.main)
|
|
494
519
|
.selectAll(`.${CLASS[shapeName]}${suffix}`);
|
|
495
520
|
}
|
|
496
521
|
|
|
@@ -507,7 +532,10 @@ export default {
|
|
|
507
532
|
} else if ($$.hasValidPointType?.(that.nodeName)) {
|
|
508
533
|
isWithin = $$.isStepType(d) ?
|
|
509
534
|
$$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) :
|
|
510
|
-
$$.isWithinCircle(
|
|
535
|
+
$$.isWithinCircle(
|
|
536
|
+
that,
|
|
537
|
+
$$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0
|
|
538
|
+
);
|
|
511
539
|
} else if (that.nodeName === "path") {
|
|
512
540
|
isWithin = shape.classed(CLASS.bar) ? $$.isWithinBar(that) : true;
|
|
513
541
|
}
|
|
@@ -520,11 +548,11 @@ export default {
|
|
|
520
548
|
const interpolation = $$.getInterpolateType(d);
|
|
521
549
|
|
|
522
550
|
return {
|
|
523
|
-
|
|
551
|
+
basis: d3CurveBasis,
|
|
524
552
|
"basis-closed": d3CurveBasisClosed,
|
|
525
553
|
"basis-open": d3CurveBasisOpen,
|
|
526
|
-
|
|
527
|
-
|
|
554
|
+
bundle: d3CurveBundle,
|
|
555
|
+
cardinal: d3CurveCardinal,
|
|
528
556
|
"cardinal-closed": d3CurveCardinalClosed,
|
|
529
557
|
"cardinal-open": d3CurveCardinalOpen,
|
|
530
558
|
"catmull-rom": d3CurveCatmullRom,
|
|
@@ -532,10 +560,10 @@ export default {
|
|
|
532
560
|
"catmull-rom-open": d3CurveCatmullRomOpen,
|
|
533
561
|
"monotone-x": d3CurveMonotoneX,
|
|
534
562
|
"monotone-y": d3CurveMonotoneY,
|
|
535
|
-
|
|
563
|
+
natural: d3CurveNatural,
|
|
536
564
|
"linear-closed": d3CurveLinearClosed,
|
|
537
|
-
|
|
538
|
-
|
|
565
|
+
linear: d3CurveLinear,
|
|
566
|
+
step: d3CurveStep,
|
|
539
567
|
"step-after": d3CurveStepAfter,
|
|
540
568
|
"step-before": d3CurveStepBefore
|
|
541
569
|
}[interpolation];
|
|
@@ -547,11 +575,9 @@ export default {
|
|
|
547
575
|
const type = config.spline_interpolation_type;
|
|
548
576
|
const interpolation = $$.isInterpolationType(type) ? type : "cardinal";
|
|
549
577
|
|
|
550
|
-
return $$.isSplineType(d) ?
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
config.line_step_type : "linear"
|
|
554
|
-
);
|
|
578
|
+
return $$.isSplineType(d) ? interpolation : (
|
|
579
|
+
$$.isStepType(d) ? config.line_step_type : "linear"
|
|
580
|
+
);
|
|
555
581
|
},
|
|
556
582
|
|
|
557
583
|
isWithinBar(that): boolean {
|
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
treemap as d3Treemap,
|
|
8
8
|
treemapBinary as d3TreemapBinary,
|
|
9
9
|
treemapDice as d3TreemapDice,
|
|
10
|
+
treemapResquarify as d3TreemapResquarify,
|
|
10
11
|
treemapSlice as d3TreemapSlice,
|
|
11
12
|
treemapSliceDice as d3TreemapSliceDice,
|
|
12
|
-
treemapSquarify as d3TreemapSquarify
|
|
13
|
-
treemapResquarify as d3TreemapResquarify
|
|
13
|
+
treemapSquarify as d3TreemapSquarify
|
|
14
14
|
} from "d3-hierarchy";
|
|
15
15
|
import {select as d3Select} from "d3-selection";
|
|
16
16
|
import type {d3Selection} from "../../../types/types";
|
|
17
17
|
import {$COMMON, $TREEMAP} from "../../config/classes";
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
18
|
+
import {getRandom, isFunction} from "../../module/util";
|
|
19
|
+
import type {IData, IDataRow, ITreemapData} from "../data/IData";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Get treemap elements' position
|
|
@@ -34,11 +34,11 @@ function position(group, root): void {
|
|
|
34
34
|
))
|
|
35
35
|
.select("rect")
|
|
36
36
|
.attr("width", d => (
|
|
37
|
-
d === root ? width : x(d.x1) - x(d.x0)
|
|
38
|
-
)
|
|
37
|
+
d === root ? width : x(d.x1) - x(d.x0)
|
|
38
|
+
))
|
|
39
39
|
.attr("height", d => (
|
|
40
|
-
d === root ? 0 : y(d.y1) - y(d.y0)
|
|
41
|
-
);
|
|
40
|
+
d === root ? 0 : y(d.y1) - y(d.y0)
|
|
41
|
+
));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -66,9 +66,14 @@ function convertDataToTreemapData(data: IData[]): ITreemapData[] {
|
|
|
66
66
|
export default {
|
|
67
67
|
initTreemap(): void {
|
|
68
68
|
const $$ = this;
|
|
69
|
-
const {
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const {
|
|
70
|
+
$el,
|
|
71
|
+
state: {
|
|
72
|
+
current: {width, height},
|
|
73
|
+
clip,
|
|
74
|
+
datetimeId
|
|
75
|
+
}
|
|
76
|
+
} = $$;
|
|
72
77
|
|
|
73
78
|
clip.id = `${datetimeId}-clip`;
|
|
74
79
|
|
|
@@ -148,12 +153,12 @@ export default {
|
|
|
148
153
|
const $$ = this;
|
|
149
154
|
const {config, state: {current: {width, height}}} = $$;
|
|
150
155
|
const tile = {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
binary: d3TreemapBinary,
|
|
157
|
+
dice: d3TreemapDice,
|
|
158
|
+
slice: d3TreemapSlice,
|
|
159
|
+
sliceDice: d3TreemapSliceDice,
|
|
160
|
+
squarify: d3TreemapSquarify,
|
|
161
|
+
resquarify: d3TreemapResquarify
|
|
157
162
|
}[config.treemap_tile ?? "binary"] ?? d3TreemapBinary;
|
|
158
163
|
|
|
159
164
|
return (node, x0, y0, x1, y1) => {
|
|
@@ -209,6 +214,7 @@ export default {
|
|
|
209
214
|
const {$el, $T} = $$;
|
|
210
215
|
const data = $el.treemap.datum();
|
|
211
216
|
const classChartTreemap = $$.getChartClass("Treemap");
|
|
217
|
+
const classTreemap = $$.getClass("treemap", true);
|
|
212
218
|
|
|
213
219
|
const treemap = $el.treemap
|
|
214
220
|
.selectAll("g")
|
|
@@ -225,6 +231,7 @@ export default {
|
|
|
225
231
|
$el.treemap.selectAll("g")
|
|
226
232
|
.attr("class", classChartTreemap)
|
|
227
233
|
.select("rect")
|
|
234
|
+
.attr("class", classTreemap)
|
|
228
235
|
.attr("fill", d => $$.color(d.data.name));
|
|
229
236
|
},
|
|
230
237
|
|
|
@@ -283,13 +290,17 @@ export default {
|
|
|
283
290
|
const ratio = $$.getRatio("treemap", d);
|
|
284
291
|
const percentValue = (ratio * 100).toFixed(2);
|
|
285
292
|
const meetLabelThreshold = config.treemap_label_show && $$.meetsLabelThreshold(
|
|
286
|
-
|
|
287
|
-
|
|
293
|
+
ratio,
|
|
294
|
+
"treemap"
|
|
295
|
+
) ?
|
|
296
|
+
null :
|
|
297
|
+
"0";
|
|
288
298
|
|
|
289
299
|
return function(node) {
|
|
290
300
|
node.style("opacity", meetLabelThreshold);
|
|
291
301
|
|
|
292
|
-
return isFunction(format) ?
|
|
302
|
+
return isFunction(format) ?
|
|
303
|
+
format.bind($$.api)(value, ratio, id) :
|
|
293
304
|
`${id}\n${percentValue}%`;
|
|
294
305
|
};
|
|
295
306
|
}
|
|
@@ -111,8 +111,6 @@ export default class BubbleCompare extends Plugin {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
getZData(d): number {
|
|
114
|
-
return this.$$.isBubbleZType(d) ?
|
|
115
|
-
this.$$.getBubbleZData(d.value, "z") :
|
|
116
|
-
d.value;
|
|
114
|
+
return this.$$.isBubbleZType(d) ? this.$$.getBubbleZData(d.value, "z") : d.value;
|
|
117
115
|
}
|
|
118
116
|
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) 2021 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
+
import type {IData} from "../../ChartInternal/data/IData";
|
|
5
6
|
import {$COMMON} from "../../config/classes";
|
|
7
|
+
import {loadConfig} from "../../config/config";
|
|
6
8
|
import Plugin from "../Plugin";
|
|
7
9
|
import Options from "./Options";
|
|
8
|
-
import type {IData} from "../../ChartInternal/data/IData";
|
|
9
|
-
import {loadConfig} from "../../config/config";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Sparkline plugin.<br>
|
|
@@ -235,8 +235,7 @@ export default class Sparkline extends Plugin {
|
|
|
235
235
|
|
|
236
236
|
$$.state.event = e;
|
|
237
237
|
|
|
238
|
-
$$.isPointFocusOnly() ?
|
|
239
|
-
$$.hideCircleFocus() : $$.unexpandCircles();
|
|
238
|
+
$$.isPointFocusOnly() ? $$.hideCircleFocus() : $$.unexpandCircles();
|
|
240
239
|
|
|
241
240
|
$$.hideTooltip();
|
|
242
241
|
}
|
|
@@ -6,7 +6,7 @@ import {axisRight as d3AxisRight} from "d3-axis";
|
|
|
6
6
|
import {format as d3Format} from "d3-format";
|
|
7
7
|
import {scaleSequential as d3ScaleSequential, scaleSymlog as d3ScaleSymlog} from "d3-scale";
|
|
8
8
|
import CLASS from "./classes";
|
|
9
|
-
import {
|
|
9
|
+
import {getRange, isFunction} from "./util";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Stanford diagram plugin color scale class
|
|
@@ -89,7 +89,8 @@ export default class ColorScale {
|
|
|
89
89
|
.text(d => Math.round(Math.log(d) / Math.LN10));
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
this.colorScale.attr("transform",
|
|
92
|
+
this.colorScale.attr("transform",
|
|
93
|
+
`translate(${$$.state.current.width - this.xForColorScale()}, 0)`);
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
xForColorScale(): number {
|
|
@@ -111,18 +111,27 @@ export default class Elements {
|
|
|
111
111
|
.select("polygon")
|
|
112
112
|
.transition()
|
|
113
113
|
.duration(duration)
|
|
114
|
-
.attr("points", d =>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
.attr("points", d =>
|
|
115
|
+
d.points.map(value =>
|
|
116
|
+
[
|
|
117
|
+
isRotated ? yvCustom(value, "y") : xvCustom(value, "x"),
|
|
118
|
+
isRotated ? xvCustom(value, "x") : yvCustom(value, "y")
|
|
119
|
+
].join(",")
|
|
120
|
+
).join(" "))
|
|
118
121
|
.transition()
|
|
119
122
|
.style("opacity", d => String(d.opacity ? d.opacity : 0.2));
|
|
120
123
|
|
|
121
124
|
stanfordRegion.select("text")
|
|
122
125
|
.transition()
|
|
123
126
|
.duration(duration)
|
|
124
|
-
.attr("x",
|
|
125
|
-
|
|
127
|
+
.attr("x",
|
|
128
|
+
d => (isRotated ?
|
|
129
|
+
yvCustom(getCentroid(d.points), "y") :
|
|
130
|
+
xvCustom(getCentroid(d.points), "x")))
|
|
131
|
+
.attr("y",
|
|
132
|
+
d => (isRotated ?
|
|
133
|
+
xvCustom(getCentroid(d.points), "x") :
|
|
134
|
+
yvCustom(getCentroid(d.points), "y")))
|
|
126
135
|
.text(d => {
|
|
127
136
|
if (d.text) {
|
|
128
137
|
const {value, percentage} = countPointsInRegion(d.points);
|
|
@@ -35,7 +35,7 @@ export default class Options {
|
|
|
35
35
|
* @example
|
|
36
36
|
* epochs: [ 1, 1, 2, 2, ... ]
|
|
37
37
|
*/
|
|
38
|
-
epochs: <number[]>
|
|
38
|
+
epochs: <number[]>[],
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Show additional lines anywhere on the chart.
|
|
@@ -84,10 +84,10 @@ export default class Options {
|
|
|
84
84
|
* }
|
|
85
85
|
* },
|
|
86
86
|
*/
|
|
87
|
-
scale_min: <number|undefined>
|
|
88
|
-
scale_max: <number|undefined>
|
|
89
|
-
scale_width: <number|undefined>
|
|
90
|
-
scale_format: <number|undefined>
|
|
87
|
+
scale_min: <number | undefined>undefined,
|
|
88
|
+
scale_max: <number | undefined>undefined,
|
|
89
|
+
scale_width: <number | undefined>20,
|
|
90
|
+
scale_format: <number | undefined>undefined,
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* The padding for color scale element
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
// @ts-nocheck
|
|
6
|
-
import {interpolateHslLong as d3InterpolateHslLong} from "d3-interpolate";
|
|
7
6
|
import {hsl as d3Hsl} from "d3-color";
|
|
7
|
+
import {interpolateHslLong as d3InterpolateHslLong} from "d3-interpolate";
|
|
8
8
|
import {scaleSequentialLog as d3ScaleSequentialLog} from "d3-scale";
|
|
9
9
|
import {$TOOLTIP} from "../../config/classes";
|
|
10
10
|
import {loadConfig} from "../../config/config";
|
|
11
11
|
import Plugin from "../Plugin";
|
|
12
|
-
import Options from "./Options";
|
|
13
|
-
import Elements from "./Elements";
|
|
14
12
|
import ColorScale from "./ColorScale";
|
|
13
|
+
import Elements from "./Elements";
|
|
14
|
+
import Options from "./Options";
|
|
15
15
|
import {compareEpochs, isEmpty, isFunction, pointInRegion} from "./util";
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -90,7 +90,7 @@ import {compareEpochs, isEmpty, isFunction, pointInRegion} from "./util";
|
|
|
90
90
|
* ]
|
|
91
91
|
* });
|
|
92
92
|
* @example
|
|
93
|
-
*
|
|
93
|
+
* import {bb} from "billboard.js";
|
|
94
94
|
* import Stanford from "billboard.js/dist/billboardjs-plugin-stanford";
|
|
95
95
|
*
|
|
96
96
|
* bb.generate({
|
|
@@ -156,7 +156,6 @@ export default class Stanford extends Plugin {
|
|
|
156
156
|
this.elements?.updateStanfordElements(duration);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
|
|
160
159
|
getOptions(): Options {
|
|
161
160
|
return new Options();
|
|
162
161
|
}
|
|
@@ -192,7 +191,8 @@ export default class Stanford extends Plugin {
|
|
|
192
191
|
target.maxEpochs = !isNaN(config.scale_max) ? config.scale_max : Math.max(...epochs);
|
|
193
192
|
|
|
194
193
|
target.colors = isFunction(config.colors) ?
|
|
195
|
-
config.colors :
|
|
194
|
+
config.colors :
|
|
195
|
+
d3InterpolateHslLong(d3Hsl(250, 1, 0.5), d3Hsl(0, 1, 0.5));
|
|
196
196
|
|
|
197
197
|
target.colorscale = d3ScaleSequentialLog(target.colors)
|
|
198
198
|
.domain([target.minEpochs, target.maxEpochs]);
|
|
@@ -224,7 +224,9 @@ export default class Stanford extends Plugin {
|
|
|
224
224
|
<th class="value">${defaultValueFormat(value)}</th>
|
|
225
225
|
</tr>
|
|
226
226
|
<tr class="${$TOOLTIP.tooltipName}-${id}">
|
|
227
|
-
<td class="name"><span style="background-color:${
|
|
227
|
+
<td class="name"><span style="background-color:${
|
|
228
|
+
color(v)
|
|
229
|
+
}"></span>Epochs</td>
|
|
228
230
|
<td class="value">${defaultValueFormat(epochs)}</td>
|
|
229
231
|
</tr>`;
|
|
230
232
|
});
|
|
@@ -238,8 +240,10 @@ export default class Stanford extends Plugin {
|
|
|
238
240
|
const $$ = this;
|
|
239
241
|
const target = $$.data.targets[0];
|
|
240
242
|
|
|
241
|
-
const total = target.values.reduce(
|
|
242
|
-
accumulator + Number(currentValue.epochs),
|
|
243
|
+
const total = target.values.reduce(
|
|
244
|
+
(accumulator, currentValue) => accumulator + Number(currentValue.epochs),
|
|
245
|
+
0
|
|
246
|
+
);
|
|
243
247
|
|
|
244
248
|
const value = target.values.reduce((accumulator, currentValue) => {
|
|
245
249
|
if (pointInRegion(currentValue, region)) {
|
|
@@ -46,7 +46,7 @@ export default class Options {
|
|
|
46
46
|
* @example
|
|
47
47
|
* categoryFormat: "#table-holder"
|
|
48
48
|
*/
|
|
49
|
-
categoryFormat: function(v: Date|number|string): string {
|
|
49
|
+
categoryFormat: function(v: Date | number | string): string {
|
|
50
50
|
let category = v;
|
|
51
51
|
|
|
52
52
|
if (this.$$.axis.isCategorized()) {
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) 2021 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import Plugin from "../Plugin";
|
|
6
|
-
import Options from "./Options";
|
|
7
|
-
import {defaultStyle, tpl} from "./const";
|
|
8
5
|
import {loadConfig} from "../../config/config";
|
|
9
6
|
import {isNumber, tplProcess} from "../../module/util";
|
|
7
|
+
import Plugin from "../Plugin";
|
|
8
|
+
import {defaultStyle, tpl} from "./const";
|
|
9
|
+
import Options from "./Options";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Table view plugin.<br>
|
|
@@ -115,7 +115,7 @@ export default class TableView extends Plugin {
|
|
|
115
115
|
title: dataToShow.length ? this.config.categoryTitle : ""
|
|
116
116
|
});
|
|
117
117
|
let tbody = "";
|
|
118
|
-
const rows: (number|string)[][] = [];
|
|
118
|
+
const rows: (number | string)[][] = [];
|
|
119
119
|
|
|
120
120
|
dataToShow.forEach(v => {
|
|
121
121
|
thead += tplProcess(tpl.thead, {title: v.id});
|
|
@@ -132,11 +132,13 @@ export default class TableView extends Plugin {
|
|
|
132
132
|
|
|
133
133
|
rows.forEach(v => {
|
|
134
134
|
tbody += `<tr>${
|
|
135
|
-
v.map((d, i) =>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
v.map((d, i) =>
|
|
136
|
+
tplProcess(i ? tpl.tbody : tpl.tbodyHeader, {
|
|
137
|
+
value: i === 0 ?
|
|
138
|
+
config.categoryFormat.bind(this)(d) :
|
|
139
|
+
(isNumber(d) ? d.toLocaleString() : config.nullString)
|
|
140
|
+
})
|
|
141
|
+
).join("")
|
|
140
142
|
}</tr>`;
|
|
141
143
|
});
|
|
142
144
|
|