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
|
@@ -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);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {area as d3Area} from "d3-shape";
|
|
6
5
|
import {select as d3Select} from "d3-selection";
|
|
6
|
+
import {area as d3Area} from "d3-shape";
|
|
7
|
+
import {d3Selection} from "../../../types";
|
|
7
8
|
import {$AREA, $CIRCLE, $LINE} from "../../config/classes";
|
|
8
9
|
import {getRandom} from "../../module/util";
|
|
9
10
|
import type {IData, IDataRow} from "../data/IData";
|
|
10
|
-
import {d3Selection} from "../../../types";
|
|
11
11
|
|
|
12
12
|
type Indices = {[key: string | "__max__"]: number};
|
|
13
13
|
|
|
@@ -30,8 +30,7 @@ export default {
|
|
|
30
30
|
updateAreaColor(d: IDataRow): string {
|
|
31
31
|
const $$ = this;
|
|
32
32
|
|
|
33
|
-
return $$.config.area_linearGradient ?
|
|
34
|
-
$$.getGradienColortUrl(d.id) : $$.color(d);
|
|
33
|
+
return $$.config.area_linearGradient ? $$.getGradienColortUrl(d.id) : $$.color(d);
|
|
35
34
|
},
|
|
36
35
|
|
|
37
36
|
/**
|
|
@@ -79,14 +78,15 @@ export default {
|
|
|
79
78
|
*/
|
|
80
79
|
redrawArea(drawFn: Function, withTransition?: boolean, isSub = false): d3Selection[] {
|
|
81
80
|
const $$ = this;
|
|
82
|
-
const {area} =
|
|
81
|
+
const {area} = isSub ? this.$el.subchart : this.$el;
|
|
83
82
|
const {orgAreaOpacity} = $$.state;
|
|
84
83
|
|
|
85
84
|
return [
|
|
86
85
|
$$.$T(area, withTransition, getRandom())
|
|
87
86
|
.attr("d", drawFn)
|
|
88
87
|
.style("fill", $$.updateAreaColor.bind($$))
|
|
89
|
-
.style("opacity",
|
|
88
|
+
.style("opacity",
|
|
89
|
+
d => String($$.isAreaRangeType(d) ? orgAreaOpacity / 1.75 : orgAreaOpacity))
|
|
90
90
|
];
|
|
91
91
|
},
|
|
92
92
|
|
|
@@ -107,18 +107,12 @@ export default {
|
|
|
107
107
|
const yScale = $$.getYScaleById.bind($$);
|
|
108
108
|
|
|
109
109
|
const xValue = d => (isSub ? $$.subxx : $$.xx).call($$, d);
|
|
110
|
-
const value0 = (d, i) => ($$.isGrouped(d.id) ?
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const value1 = (d, i) => ($$.isGrouped(d.id) ?
|
|
117
|
-
getPoints(d, i)[1][1] :
|
|
118
|
-
yScale(d.id, isSub)(
|
|
119
|
-
$$.isAreaRangeType(d) ?
|
|
120
|
-
$$.getRangedData(d, "low") : d.value
|
|
121
|
-
));
|
|
110
|
+
const value0 = (d, i) => ($$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)(
|
|
111
|
+
$$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : $$.getShapeYMin(d.id)
|
|
112
|
+
));
|
|
113
|
+
const value1 = (d, i) => ($$.isGrouped(d.id) ? getPoints(d, i)[1][1] : yScale(d.id, isSub)(
|
|
114
|
+
$$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : d.value
|
|
115
|
+
));
|
|
122
116
|
|
|
123
117
|
return d => {
|
|
124
118
|
let values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values;
|
|
@@ -162,7 +156,8 @@ export default {
|
|
|
162
156
|
},
|
|
163
157
|
|
|
164
158
|
generateGetAreaPoints(
|
|
165
|
-
areaIndices: Indices,
|
|
159
|
+
areaIndices: Indices,
|
|
160
|
+
isSub?: boolean
|
|
166
161
|
): (d: IDataRow, i: number) => [number, number][] {
|
|
167
162
|
// partial duplication of generateGetBarPoints
|
|
168
163
|
const $$ = this;
|
|
@@ -180,9 +175,11 @@ export default {
|
|
|
180
175
|
let posY = y(d);
|
|
181
176
|
|
|
182
177
|
// fix posY not to overflow opposite quadrant
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
if (
|
|
179
|
+
config.axis_rotated && (
|
|
180
|
+
(value > 0 && posY < y0) || (value < 0 && y0 < posY)
|
|
181
|
+
)
|
|
182
|
+
) {
|
|
186
183
|
posY = y0;
|
|
187
184
|
}
|
|
188
185
|
|
|
@@ -16,9 +16,7 @@ export default {
|
|
|
16
16
|
|
|
17
17
|
$el.bar = $el.main.select(`.${$COMMON.chart}`);
|
|
18
18
|
|
|
19
|
-
$el.bar = config.bar_front ?
|
|
20
|
-
$el.bar.append("g") :
|
|
21
|
-
$el.bar.insert("g", ":first-child");
|
|
19
|
+
$el.bar = config.bar_front ? $el.bar.append("g") : $el.bar.insert("g", ":first-child");
|
|
22
20
|
|
|
23
21
|
$el.bar
|
|
24
22
|
.attr("class", $BAR.chartBars)
|
|
@@ -26,9 +24,11 @@ export default {
|
|
|
26
24
|
|
|
27
25
|
// set clip-path attribute when condition meet
|
|
28
26
|
// https://github.com/naver/billboard.js/issues/2421
|
|
29
|
-
if (
|
|
30
|
-
config.
|
|
31
|
-
|
|
27
|
+
if (
|
|
28
|
+
config.clipPath === false && (
|
|
29
|
+
config.bar_radius || config.bar_radius_ratio
|
|
30
|
+
)
|
|
31
|
+
) {
|
|
32
32
|
$el.bar.attr("clip-path", clip.pathXAxis.replace(/#[^)]*/, `#${clip.id}`));
|
|
33
33
|
}
|
|
34
34
|
},
|
|
@@ -110,8 +110,7 @@ export default {
|
|
|
110
110
|
const $$ = this;
|
|
111
111
|
const fn = $$.getStylePropValue($$.color);
|
|
112
112
|
|
|
113
|
-
return $$.config.bar_linearGradient ?
|
|
114
|
-
$$.getGradienColortUrl(d.id) : (fn ? fn(d) : null);
|
|
113
|
+
return $$.config.bar_linearGradient ? $$.getGradienColortUrl(d.id) : (fn ? fn(d) : null);
|
|
115
114
|
},
|
|
116
115
|
|
|
117
116
|
/**
|
|
@@ -124,7 +123,7 @@ export default {
|
|
|
124
123
|
*/
|
|
125
124
|
redrawBar(drawFn, withTransition?: boolean, isSub = false) {
|
|
126
125
|
const $$ = this;
|
|
127
|
-
const {bar} =
|
|
126
|
+
const {bar} = isSub ? $$.$el.subchart : $$.$el;
|
|
128
127
|
|
|
129
128
|
return [
|
|
130
129
|
$$.$T(bar, withTransition, getRandom())
|
|
@@ -141,15 +140,15 @@ export default {
|
|
|
141
140
|
*
|
|
142
141
|
* When gropus given as:
|
|
143
142
|
* groups: [
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
143
|
+
* ["data1", "data2"],
|
|
144
|
+
* ["data3", "data4"]
|
|
145
|
+
* ],
|
|
147
146
|
*
|
|
148
147
|
* Will be rendered as:
|
|
149
148
|
* data1 data3 data1 data3
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
149
|
+
* data2 data4 data2 data4
|
|
150
|
+
* -------------------------
|
|
151
|
+
* 0 1
|
|
153
152
|
* @param {boolean} isSub If is for subchart
|
|
154
153
|
* @returns {Function}
|
|
155
154
|
* @private
|
|
@@ -163,10 +162,9 @@ export default {
|
|
|
163
162
|
const barRadiusRatio = config.bar_radius_ratio;
|
|
164
163
|
|
|
165
164
|
// get the bar radius
|
|
166
|
-
const getRadius = isNumber(barRadius) && barRadius > 0 ?
|
|
167
|
-
() =>
|
|
168
|
-
|
|
169
|
-
);
|
|
165
|
+
const getRadius = isNumber(barRadius) && barRadius > 0 ? () => barRadius : (
|
|
166
|
+
isNumber(barRadiusRatio) ? w => w * barRadiusRatio : null
|
|
167
|
+
);
|
|
170
168
|
|
|
171
169
|
return (d: IDataRow, i: number) => {
|
|
172
170
|
// 4 points that make a bar
|
|
@@ -195,7 +193,9 @@ export default {
|
|
|
195
193
|
const arc = `a${radius},${radius} ${isNegative ? `1 0 0` : `0 0 1`} `;
|
|
196
194
|
|
|
197
195
|
pathRadius[+!isRotated] = `${arc}${radius},${radius}`;
|
|
198
|
-
pathRadius[+isRotated] = `${arc}${
|
|
196
|
+
pathRadius[+isRotated] = `${arc}${
|
|
197
|
+
[-radius, radius][isRotated ? "sort" : "reverse"]()
|
|
198
|
+
}`;
|
|
199
199
|
|
|
200
200
|
isNegative && pathRadius.reverse();
|
|
201
201
|
}
|
|
@@ -203,8 +203,12 @@ export default {
|
|
|
203
203
|
// path string data shouldn't be containing new line chars
|
|
204
204
|
// https://github.com/naver/billboard.js/issues/530
|
|
205
205
|
const path = isRotated ?
|
|
206
|
-
`H${points[1][indexX] + (isNegative ? radius : -radius)} ${pathRadius[0]}V${
|
|
207
|
-
|
|
206
|
+
`H${points[1][indexX] + (isNegative ? radius : -radius)} ${pathRadius[0]}V${
|
|
207
|
+
points[2][indexY] - radius
|
|
208
|
+
} ${pathRadius[1]}H${points[3][indexX]}` :
|
|
209
|
+
`V${points[1][indexY] + (isNegative ? -radius : radius)} ${pathRadius[0]}H${
|
|
210
|
+
points[2][indexX] - radius
|
|
211
|
+
} ${pathRadius[1]}V${points[3][indexY]}`;
|
|
208
212
|
|
|
209
213
|
return `M${points[0][indexX]},${points[0][indexY]}${path}z`;
|
|
210
214
|
};
|
|
@@ -237,10 +241,13 @@ export default {
|
|
|
237
241
|
|
|
238
242
|
// Get sorted Ids. Filter positive or negative values Ids from given value
|
|
239
243
|
const sortedIds = sortedList
|
|
240
|
-
.map(v =>
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
.map(v =>
|
|
245
|
+
v.values.filter(
|
|
246
|
+
v2 =>
|
|
247
|
+
v2.index === index && (
|
|
248
|
+
isNumber(value) && value > 0 ? v2.value > 0 : v2.value < 0
|
|
249
|
+
)
|
|
250
|
+
)[0]
|
|
244
251
|
)
|
|
245
252
|
.filter(Boolean)
|
|
246
253
|
.map(v => v.id);
|
|
@@ -256,7 +263,8 @@ export default {
|
|
|
256
263
|
* @returns {Array} Array of coordinate points
|
|
257
264
|
* @private
|
|
258
265
|
*/
|
|
259
|
-
generateGetBarPoints(barIndices,
|
|
266
|
+
generateGetBarPoints(barIndices,
|
|
267
|
+
isSub?: boolean): (d: IDataRow, i: number) => [number, number][] {
|
|
260
268
|
const $$ = this;
|
|
261
269
|
const {config} = $$;
|
|
262
270
|
const axis = isSub ? $$.axis.subX : $$.axis.x;
|
|
@@ -278,14 +286,16 @@ export default {
|
|
|
278
286
|
let posY = barY(d);
|
|
279
287
|
|
|
280
288
|
// fix posY not to overflow opposite quadrant
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
|
|
289
|
+
if (
|
|
290
|
+
config.axis_rotated && !isInverted && (
|
|
291
|
+
(value > 0 && posY < y0) || (value < 0 && y0 < posY)
|
|
292
|
+
)
|
|
293
|
+
) {
|
|
284
294
|
posY = y0;
|
|
285
295
|
}
|
|
286
296
|
|
|
287
297
|
if (!$$.isBarRangeType(d)) {
|
|
288
|
-
posY -=
|
|
298
|
+
posY -= y0 - offset;
|
|
289
299
|
}
|
|
290
300
|
|
|
291
301
|
const startPosX = posX + width;
|
|
@@ -55,13 +55,13 @@ export default {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const max = getMinMax("max", $$.getMinMaxData().max.map(d => (
|
|
58
|
-
$$.isBubbleZType(d) ?
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
58
|
+
$$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "y") : (
|
|
59
|
+
isObject(d.value) ? d.value.mid : d.value
|
|
60
|
+
)
|
|
62
61
|
)));
|
|
63
62
|
const maxArea = maxR * maxR * Math.PI;
|
|
64
|
-
const area = ($$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "z") : d.value) *
|
|
63
|
+
const area = ($$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "z") : d.value) *
|
|
64
|
+
(maxArea / max);
|
|
65
65
|
|
|
66
66
|
return Math.sqrt(area / Math.PI);
|
|
67
67
|
},
|
|
@@ -125,17 +125,19 @@ export default {
|
|
|
125
125
|
|
|
126
126
|
// set line position
|
|
127
127
|
const line = g.select("line");
|
|
128
|
-
const pos = isRotated ?
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
128
|
+
const pos = isRotated ?
|
|
129
|
+
{
|
|
130
|
+
x1: points[2][1],
|
|
131
|
+
x2: points[2][2],
|
|
132
|
+
y1: points[2][0],
|
|
133
|
+
y2: points[2][0]
|
|
134
|
+
} :
|
|
135
|
+
{
|
|
136
|
+
x1: points[2][0],
|
|
137
|
+
x2: points[2][0],
|
|
138
|
+
y1: points[2][1],
|
|
139
|
+
y2: points[2][2]
|
|
140
|
+
};
|
|
139
141
|
|
|
140
142
|
for (const x in pos) {
|
|
141
143
|
line.attr(x, pos[x]);
|
|
@@ -184,7 +186,7 @@ export default {
|
|
|
184
186
|
low: y(value.low)
|
|
185
187
|
};
|
|
186
188
|
|
|
187
|
-
posY.start -=
|
|
189
|
+
posY.start -= y0 - offset;
|
|
188
190
|
|
|
189
191
|
points = [
|
|
190
192
|
[posX.start, posY.start],
|
|
@@ -209,7 +211,7 @@ export default {
|
|
|
209
211
|
redrawCandlestick(drawFn, withTransition?: boolean, isSub = false) {
|
|
210
212
|
const $$ = this;
|
|
211
213
|
const {$el, $T} = $$;
|
|
212
|
-
const {candlestick} =
|
|
214
|
+
const {candlestick} = isSub ? $el.subchart : $el;
|
|
213
215
|
const rand = getRandom(true);
|
|
214
216
|
|
|
215
217
|
return [
|
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
initGauge(): void {
|
|
11
11
|
const $$ = this;
|
|
12
12
|
const {config, $el: {arcs}} = $$;
|
|
13
|
-
const appendText = (className = <null|string>null, value = "") => {
|
|
13
|
+
const appendText = (className = <null | string>null, value = "") => {
|
|
14
14
|
arcs.append("text")
|
|
15
15
|
.attr("class", className)
|
|
16
16
|
.style("text-anchor", "middle")
|
|
@@ -42,12 +42,15 @@ export default {
|
|
|
42
42
|
|
|
43
43
|
// to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
|
|
44
44
|
const max = hasMultiGauge ?
|
|
45
|
-
$$.getMinMaxData().max[0].value :
|
|
45
|
+
$$.getMinMaxData().max[0].value :
|
|
46
|
+
$$.getTotalDataSum(state.rendered);
|
|
46
47
|
|
|
47
48
|
// if gauge_max less than max, make max to max value
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
if (
|
|
50
|
+
!config.gauge_enforceMinMax && (
|
|
51
|
+
max + config.gauge_min * (config.gauge_min > 0 ? -1 : 1) > config.gauge_max
|
|
52
|
+
)
|
|
53
|
+
) {
|
|
51
54
|
config.gauge_max = max - config.gauge_min;
|
|
52
55
|
}
|
|
53
56
|
},
|
|
@@ -63,11 +66,13 @@ export default {
|
|
|
63
66
|
|
|
64
67
|
const mainArcLabelLine = arcLabelLines.enter()
|
|
65
68
|
.append("rect")
|
|
66
|
-
.attr("class",
|
|
69
|
+
.attr("class",
|
|
70
|
+
d => `${$ARC.arcLabelLine} ${$COMMON.target} ${$COMMON.target}-${d.data.id}`)
|
|
67
71
|
.merge(arcLabelLines);
|
|
68
72
|
|
|
69
73
|
mainArcLabelLine
|
|
70
|
-
.style("fill",
|
|
74
|
+
.style("fill",
|
|
75
|
+
d => ($$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data)))
|
|
71
76
|
.style("display", config.gauge_label_show ? null : "none")
|
|
72
77
|
.each(function(d) {
|
|
73
78
|
let lineLength = 0;
|
|
@@ -78,11 +83,13 @@ export default {
|
|
|
78
83
|
|
|
79
84
|
if (hiddenTargetIds.indexOf(d.data.id) < 0) {
|
|
80
85
|
const updated = $$.updateAngle(d);
|
|
81
|
-
const innerLineLength = state.gaugeArcWidth /
|
|
86
|
+
const innerLineLength = state.gaugeArcWidth /
|
|
87
|
+
$$.filterTargetsToShow($$.data.targets).length *
|
|
82
88
|
(updated.index + 1);
|
|
83
89
|
const lineAngle = updated.endAngle - Math.PI / 2;
|
|
84
90
|
const arcInnerRadius = state.radius - innerLineLength;
|
|
85
|
-
const linePositioningAngle = lineAngle -
|
|
91
|
+
const linePositioningAngle = lineAngle -
|
|
92
|
+
(arcInnerRadius === 0 ? 0 : (1 / arcInnerRadius));
|
|
86
93
|
|
|
87
94
|
lineLength = state.radiusExpanded - state.radius + innerLineLength;
|
|
88
95
|
x = Math.cos(linePositioningAngle) * arcInnerRadius;
|