billboard.js 3.11.2 → 3.12.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -6
- package/dist/billboard.css +5 -1
- package/dist/billboard.js +19431 -24292
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +26 -3
- package/dist/billboard.pkgd.js +22301 -29057
- package/dist/billboard.pkgd.min.js +33 -3
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
- package/dist/plugin/billboardjs-plugin-sparkline.js +423 -1134
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +660 -1524
- package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
- package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
- package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
- package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +339 -1324
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1701 -3424
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2385 -4462
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1783 -3467
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2031 -3979
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
- package/dist/theme/dark.css +5 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +5 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +5 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +5 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +5 -1
- package/dist/theme/modern.min.css +3 -4
- package/dist-esm/billboard.js +9051 -8666
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +19 -25
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +149 -148
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +295 -286
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +235 -234
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +40 -41
- package/package.json +26 -46
- package/src/Chart/api/axis.ts +6 -13
- package/src/Chart/api/chart.ts +12 -11
- package/src/Chart/api/data.ts +8 -7
- package/src/Chart/api/export.ts +28 -21
- package/src/Chart/api/flow.ts +4 -2
- package/src/Chart/api/grid.ts +1 -5
- package/src/Chart/api/load.ts +2 -2
- package/src/Chart/api/regions.ts +29 -5
- package/src/Chart/api/selection.ts +2 -2
- package/src/Chart/api/show.ts +2 -3
- package/src/Chart/api/subchart.ts +2 -2
- package/src/Chart/api/tooltip.ts +5 -7
- package/src/Chart/api/x.ts +2 -2
- package/src/Chart/api/zoom.ts +2 -2
- package/src/ChartInternal/Axis/Axis.ts +119 -44
- package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
- package/src/ChartInternal/ChartInternal.ts +79 -51
- package/src/ChartInternal/data/IData.ts +22 -29
- package/src/ChartInternal/data/convert.helper.ts +66 -68
- package/src/ChartInternal/data/convert.ts +11 -11
- package/src/ChartInternal/data/data.ts +40 -23
- package/src/ChartInternal/data/load.ts +7 -6
- package/src/ChartInternal/interactions/drag.ts +2 -1
- package/src/ChartInternal/interactions/eventrect.ts +54 -25
- package/src/ChartInternal/interactions/flow.ts +14 -4
- package/src/ChartInternal/interactions/interaction.ts +34 -12
- package/src/ChartInternal/interactions/subchart.ts +27 -25
- package/src/ChartInternal/interactions/zoom.ts +29 -18
- package/src/ChartInternal/internals/category.ts +1 -1
- package/src/ChartInternal/internals/class.ts +5 -5
- package/src/ChartInternal/internals/clip.ts +9 -10
- package/src/ChartInternal/internals/color.ts +70 -42
- package/src/ChartInternal/internals/domain.ts +59 -28
- package/src/ChartInternal/internals/format.ts +5 -5
- package/src/ChartInternal/internals/grid.ts +130 -47
- package/src/ChartInternal/internals/legend.ts +99 -66
- package/src/ChartInternal/internals/redraw.ts +3 -2
- package/src/ChartInternal/internals/region.ts +5 -3
- package/src/ChartInternal/internals/scale.ts +28 -15
- package/src/ChartInternal/internals/selection.ts +14 -13
- package/src/ChartInternal/internals/size.axis.ts +18 -10
- package/src/ChartInternal/internals/size.ts +97 -66
- package/src/ChartInternal/internals/style.ts +21 -19
- package/src/ChartInternal/internals/text.ts +64 -39
- package/src/ChartInternal/internals/title.ts +2 -2
- package/src/ChartInternal/internals/tooltip.ts +83 -34
- package/src/ChartInternal/internals/transform.ts +2 -2
- package/src/ChartInternal/internals/type.ts +12 -12
- package/src/ChartInternal/shape/arc.ts +78 -44
- package/src/ChartInternal/shape/area.ts +19 -22
- package/src/ChartInternal/shape/bar.ts +41 -31
- package/src/ChartInternal/shape/bubble.ts +5 -5
- package/src/ChartInternal/shape/candlestick.ts +15 -13
- package/src/ChartInternal/shape/gauge.ts +16 -9
- package/src/ChartInternal/shape/line.ts +62 -46
- package/src/ChartInternal/shape/point.common.ts +1 -4
- package/src/ChartInternal/shape/point.ts +52 -32
- package/src/ChartInternal/shape/polar.ts +4 -2
- package/src/ChartInternal/shape/radar.ts +40 -22
- package/src/ChartInternal/shape/shape.ts +84 -58
- package/src/ChartInternal/shape/treemap.ts +29 -20
- package/src/Plugin/bubblecompare/index.ts +1 -3
- package/src/Plugin/sparkline/index.ts +3 -4
- package/src/Plugin/stanford/ColorScale.ts +3 -2
- package/src/Plugin/stanford/Elements.ts +15 -6
- package/src/Plugin/stanford/Options.ts +5 -5
- package/src/Plugin/stanford/index.ts +13 -9
- package/src/Plugin/tableview/Options.ts +1 -1
- package/src/Plugin/tableview/const.ts +1 -4
- package/src/Plugin/tableview/index.ts +11 -9
- package/src/Plugin/textoverlap/index.ts +4 -6
- package/src/config/Options/Options.ts +3 -3
- package/src/config/Options/axis/axis.ts +36 -0
- package/src/config/Options/axis/x.ts +12 -13
- package/src/config/Options/axis/y.ts +13 -13
- package/src/config/Options/axis/y2.ts +23 -10
- package/src/config/Options/common/color.ts +4 -4
- package/src/config/Options/common/grid.ts +4 -4
- package/src/config/Options/common/legend.ts +13 -14
- package/src/config/Options/common/main.ts +23 -23
- package/src/config/Options/common/point.ts +17 -18
- package/src/config/Options/common/title.ts +2 -2
- package/src/config/Options/common/tooltip.ts +13 -11
- package/src/config/Options/data/axis.ts +2 -2
- package/src/config/Options/data/data.ts +45 -45
- package/src/config/Options/interaction/interaction.ts +1 -1
- package/src/config/Options/interaction/subchart.ts +2 -2
- package/src/config/Options/interaction/zoom.ts +9 -9
- package/src/config/Options/shape/arc.ts +10 -13
- package/src/config/Options/shape/area.ts +5 -7
- package/src/config/Options/shape/bar.ts +8 -10
- package/src/config/Options/shape/bubble.ts +1 -1
- package/src/config/Options/shape/candlestick.ts +2 -2
- package/src/config/Options/shape/donut.ts +4 -4
- package/src/config/Options/shape/gauge.ts +6 -6
- package/src/config/Options/shape/line.ts +3 -3
- package/src/config/Options/shape/pie.ts +5 -5
- package/src/config/Options/shape/polar.ts +3 -3
- package/src/config/Options/shape/radar.ts +2 -2
- package/src/config/Options/shape/scatter.ts +1 -1
- package/src/config/Options/shape/treemap.ts +1 -1
- package/src/config/Store/Element.ts +8 -5
- package/src/config/Store/State.ts +19 -13
- package/src/config/classes.ts +6 -4
- package/src/config/config.ts +1 -1
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/interaction.ts +3 -7
- package/src/config/resolver/shape.ts +11 -12
- package/src/core.ts +2 -3
- package/src/index.esm.ts +2 -6
- package/src/index.ts +2 -2
- package/src/module/Cache.ts +2 -3
- package/src/module/browser.ts +15 -10
- package/src/module/error.ts +9 -8
- package/src/module/generator.ts +3 -5
- package/src/module/util.ts +60 -37
- package/src/module/worker.ts +14 -11
- package/src/scss/billboard.scss +6 -0
- package/src/scss/theme/dark.scss +6 -0
- package/src/scss/theme/datalab.scss +6 -0
- package/src/scss/theme/graph.scss +6 -0
- package/src/scss/theme/insight.scss +6 -0
- package/src/scss/theme/modern.scss +6 -0
- package/types/axis.d.ts +7 -0
- package/types/options.d.ts +7 -0
- package/types/options.shape.d.ts +7 -0
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {line as d3Line} from "d3-shape";
|
|
6
|
-
import {getScale} from "../internals/scale";
|
|
7
6
|
import {$COMMON, $LINE} from "../../config/classes";
|
|
8
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
getPointer,
|
|
9
|
+
getRandom,
|
|
10
|
+
isArray,
|
|
11
|
+
isDefined,
|
|
12
|
+
isUndefined,
|
|
13
|
+
isValue,
|
|
14
|
+
parseDate
|
|
15
|
+
} from "../../module/util";
|
|
16
|
+
import {getScale} from "../internals/scale";
|
|
9
17
|
|
|
10
18
|
export default {
|
|
11
19
|
initLine(): void {
|
|
@@ -94,7 +102,7 @@ export default {
|
|
|
94
102
|
redrawLine(drawFn, withTransition?: boolean, isSub = false) {
|
|
95
103
|
const $$ = this;
|
|
96
104
|
const {$el, $T} = $$;
|
|
97
|
-
const {line} =
|
|
105
|
+
const {line} = isSub ? $el.subchart : $el;
|
|
98
106
|
|
|
99
107
|
return [
|
|
100
108
|
$T(line, withTransition, getRandom())
|
|
@@ -116,31 +124,33 @@ export default {
|
|
|
116
124
|
|
|
117
125
|
// when is step & rotated, should be computed in different way
|
|
118
126
|
// https://github.com/naver/billboard.js/issues/471
|
|
119
|
-
return isRotatedStepType ?
|
|
120
|
-
|
|
127
|
+
return isRotatedStepType ?
|
|
128
|
+
context => {
|
|
129
|
+
const step = $$.getInterpolate(d)(context);
|
|
121
130
|
|
|
122
|
-
|
|
123
|
-
|
|
131
|
+
// keep the original method
|
|
132
|
+
step.orgPoint = step.point;
|
|
124
133
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
// to get rotated path data
|
|
135
|
+
step.pointRotated = function(x, y) {
|
|
136
|
+
this._point === 1 && (this._point = 2);
|
|
128
137
|
|
|
129
|
-
|
|
138
|
+
const y1 = this._y * (1 - this._t) + y * this._t;
|
|
130
139
|
|
|
131
|
-
|
|
132
|
-
|
|
140
|
+
this._context.lineTo(this._x, y1);
|
|
141
|
+
this._context.lineTo(x, y1);
|
|
133
142
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
143
|
+
this._x = x;
|
|
144
|
+
this._y = y;
|
|
145
|
+
};
|
|
137
146
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
step.point = function(x, y) {
|
|
148
|
+
this._point === 0 ? this.orgPoint(x, y) : this.pointRotated(x, y);
|
|
149
|
+
};
|
|
141
150
|
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
return step;
|
|
152
|
+
} :
|
|
153
|
+
$$.getInterpolate(d);
|
|
144
154
|
},
|
|
145
155
|
|
|
146
156
|
generateDrawLine(lineIndices, isSub?: boolean): (d) => string {
|
|
@@ -154,15 +164,12 @@ export default {
|
|
|
154
164
|
|
|
155
165
|
const xValue = d => (isSub ? $$.subxx : $$.xx).call($$, d);
|
|
156
166
|
const yValue = (d, i) => (
|
|
157
|
-
$$.isGrouped(d.id) ?
|
|
158
|
-
getPoints(d, i)[0][1] :
|
|
159
|
-
yScale(d.id, isSub)($$.getBaseValue(d))
|
|
167
|
+
$$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d))
|
|
160
168
|
);
|
|
161
169
|
|
|
162
170
|
let line = d3Line();
|
|
163
171
|
|
|
164
|
-
line = isRotated ?
|
|
165
|
-
line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
|
|
172
|
+
line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
|
|
166
173
|
|
|
167
174
|
if (!lineConnectNull) {
|
|
168
175
|
line = line.defined(d => $$.getBaseValue(d) !== null);
|
|
@@ -236,25 +243,34 @@ export default {
|
|
|
236
243
|
const yValue = isRotated ? dt => x(dt.x) : dt => y(dt.value);
|
|
237
244
|
|
|
238
245
|
// Define svg generator function for region
|
|
239
|
-
const generateM = points =>
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
246
|
+
const generateM = points =>
|
|
247
|
+
`M${points[0][0]},${points[0][1]}L${points[1][0]},${points[1][1]}`;
|
|
248
|
+
const sWithRegion = isTimeSeries ?
|
|
249
|
+
(d0, d1, k, timeseriesDiff) => {
|
|
250
|
+
const x0 = d0.x.getTime();
|
|
251
|
+
const xDiff = d1.x - d0.x;
|
|
252
|
+
const xv0 = new Date(x0 + xDiff * k);
|
|
253
|
+
const xv1 = new Date(x0 + xDiff * (k + timeseriesDiff));
|
|
254
|
+
|
|
255
|
+
const points = isRotated ?
|
|
256
|
+
[[y(yp(k)), x(xv0)], [y(yp(k + diff)), x(xv1)]] :
|
|
257
|
+
[[x(xv0), y(yp(k))], [x(xv1), y(yp(k + diff))]];
|
|
258
|
+
|
|
259
|
+
return generateM(points);
|
|
260
|
+
} :
|
|
261
|
+
(d0, d1, k, otherDiff) => {
|
|
262
|
+
const points = isRotated ?
|
|
263
|
+
[[y(yp(k), true), x(xp(k))], [
|
|
264
|
+
y(yp(k + otherDiff), true),
|
|
265
|
+
x(xp(k + otherDiff))
|
|
266
|
+
]] :
|
|
267
|
+
[[x(xp(k), true), y(yp(k))], [
|
|
268
|
+
x(xp(k + otherDiff), true),
|
|
269
|
+
y(yp(k + otherDiff))
|
|
270
|
+
]];
|
|
271
|
+
|
|
272
|
+
return generateM(points);
|
|
273
|
+
};
|
|
258
274
|
|
|
259
275
|
// Generate
|
|
260
276
|
const axisType = {x: $$.axis.getAxisType("x"), y: $$.axis.getAxisType("y")};
|
|
@@ -324,5 +340,5 @@ export default {
|
|
|
324
340
|
|
|
325
341
|
return linePoint === true ||
|
|
326
342
|
(isArray(linePoint) && linePoint.indexOf(d.id) !== -1);
|
|
327
|
-
}
|
|
343
|
+
}
|
|
328
344
|
};
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
namespaces as d3Namespaces,
|
|
7
|
-
select as d3Select
|
|
8
|
-
} from "d3-selection";
|
|
5
|
+
import {namespaces as d3Namespaces, select as d3Select} from "d3-selection";
|
|
9
6
|
import {document} from "../../module/browser";
|
|
10
7
|
import {isFunction, isObjectType, notEmpty, toArray} from "../../module/util";
|
|
11
8
|
|
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
|
-
import {$CIRCLE, $COMMON, $SELECT} from "../../config/classes";
|
|
7
|
-
import {getBoundingRect, getPointer, getRandom, isFunction, isObject, isUndefined, isValue} from "../../module/util";
|
|
8
6
|
import type {d3Selection} from "../../../types/types";
|
|
7
|
+
import {$CIRCLE, $COMMON, $SELECT} from "../../config/classes";
|
|
8
|
+
import {
|
|
9
|
+
getBoundingRect,
|
|
10
|
+
getPointer,
|
|
11
|
+
getRandom,
|
|
12
|
+
isFunction,
|
|
13
|
+
isObject,
|
|
14
|
+
isUndefined,
|
|
15
|
+
isValue
|
|
16
|
+
} from "../../module/util";
|
|
9
17
|
import type {IDataPoint, IDataRow} from "../data/IData";
|
|
10
18
|
|
|
11
19
|
const getTransitionName = () => getRandom();
|
|
@@ -17,7 +25,9 @@ export default {
|
|
|
17
25
|
|
|
18
26
|
if (isUndefined(opacity)) {
|
|
19
27
|
opacity = this.getBaseValue(d) !== null &&
|
|
20
|
-
|
|
28
|
+
withoutFadeIn[d.id] ?
|
|
29
|
+
this.opacityForCircle(d) :
|
|
30
|
+
"0";
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
return opacity;
|
|
@@ -31,8 +41,8 @@ export default {
|
|
|
31
41
|
opacity = config.point_show && !this.isPointFocusOnly?.() ? null : "0";
|
|
32
42
|
|
|
33
43
|
opacity = isValue(this.getBaseValue(d)) ?
|
|
34
|
-
(this.isBubbleType(d) || this.isScatterType(d) ?
|
|
35
|
-
|
|
44
|
+
(this.isBubbleType(d) || this.isScatterType(d) ? "0.5" : opacity) :
|
|
45
|
+
"0";
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
return opacity;
|
|
@@ -44,7 +54,10 @@ export default {
|
|
|
44
54
|
|
|
45
55
|
$$.point = $$.generatePoint();
|
|
46
56
|
|
|
47
|
-
if (
|
|
57
|
+
if (
|
|
58
|
+
($$.hasType("bubble") || $$.hasType("scatter")) &&
|
|
59
|
+
main.select(`.${$CIRCLE.chartCircles}`).empty()
|
|
60
|
+
) {
|
|
48
61
|
main.select(`.${$COMMON.chart}`)
|
|
49
62
|
.append("g")
|
|
50
63
|
.attr("class", $CIRCLE.chartCircles);
|
|
@@ -69,7 +82,7 @@ export default {
|
|
|
69
82
|
|
|
70
83
|
// only for scatter & bubble type should generate seprate <g> node
|
|
71
84
|
if (!targets) {
|
|
72
|
-
targets =
|
|
85
|
+
targets = data.targets
|
|
73
86
|
.filter(d => this.isScatterType(d) || this.isBubbleType(d));
|
|
74
87
|
|
|
75
88
|
const mainCircle = $el.main.select(`.${$CIRCLE.chartCircles}`)
|
|
@@ -88,7 +101,9 @@ export default {
|
|
|
88
101
|
enterNode.append("g")
|
|
89
102
|
.attr("class", classCircles)
|
|
90
103
|
.call(selection => {
|
|
91
|
-
$$.setCssRule(true, `.${$CIRCLE.circles}`, ["cursor:pointer"], isSelectable)(
|
|
104
|
+
$$.setCssRule(true, `.${$CIRCLE.circles}`, ["cursor:pointer"], isSelectable)(
|
|
105
|
+
selection
|
|
106
|
+
);
|
|
92
107
|
$$.setCssRule(true, ` .${$CIRCLE.circle}`, ["fill", "stroke"], $$.color)(selection);
|
|
93
108
|
})
|
|
94
109
|
.style("opacity", function() {
|
|
@@ -122,14 +137,17 @@ export default {
|
|
|
122
137
|
.data(d => (
|
|
123
138
|
($$.isLineType(d) && $$.shouldDrawPointsForLine(d)) ||
|
|
124
139
|
$$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ?
|
|
125
|
-
(focusOnly ? [d.values[0]] : d.values) :
|
|
126
|
-
|
|
140
|
+
(focusOnly ? [d.values[0]] : d.values) :
|
|
141
|
+
[]
|
|
142
|
+
));
|
|
127
143
|
|
|
128
144
|
circles.exit().remove();
|
|
129
145
|
|
|
130
146
|
circles.enter()
|
|
131
147
|
.filter(Boolean)
|
|
132
|
-
.append(
|
|
148
|
+
.append(
|
|
149
|
+
$$.point("create", this, $$.pointR.bind($$), $$.updateCircleColor.bind($$))
|
|
150
|
+
);
|
|
133
151
|
|
|
134
152
|
$root.circle = $root.main.selectAll(`.${$CIRCLE.circles} .${$CIRCLE.circle}`)
|
|
135
153
|
.style("stroke", $$.getStylePropValue($$.color))
|
|
@@ -147,8 +165,7 @@ export default {
|
|
|
147
165
|
const $$ = this;
|
|
148
166
|
const fn = $$.getStylePropValue($$.color);
|
|
149
167
|
|
|
150
|
-
return $$.config.point_radialGradient ?
|
|
151
|
-
$$.getGradienColortUrl(d.id) : (fn ? fn(d) : null);
|
|
168
|
+
return $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : (fn ? fn(d) : null);
|
|
152
169
|
},
|
|
153
170
|
|
|
154
171
|
redrawCircle(cx: Function, cy: Function, withTransition: boolean, flow, isSub = false) {
|
|
@@ -161,7 +178,8 @@ export default {
|
|
|
161
178
|
return [];
|
|
162
179
|
}
|
|
163
180
|
|
|
164
|
-
const fn = $$.point("update", $$, cx, cy, $$.updateCircleColor.bind($$), withTransition,
|
|
181
|
+
const fn = $$.point("update", $$, cx, cy, $$.updateCircleColor.bind($$), withTransition,
|
|
182
|
+
flow, selectedCircles);
|
|
165
183
|
const posAttr = $$.isCirclePoint() ? "c" : "";
|
|
166
184
|
|
|
167
185
|
const t = getRandom();
|
|
@@ -199,15 +217,15 @@ export default {
|
|
|
199
217
|
const cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$);
|
|
200
218
|
const cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$);
|
|
201
219
|
const withTransition = toggling || isUndefined(d);
|
|
202
|
-
const fn = $$.point("update", $$, cx, cy, $$.getStylePropValue($$.color),
|
|
220
|
+
const fn = $$.point("update", $$, cx, cy, $$.getStylePropValue($$.color),
|
|
221
|
+
resizing ? false : withTransition);
|
|
203
222
|
|
|
204
223
|
if (d) {
|
|
205
224
|
circle = circle
|
|
206
225
|
.filter(function(t) {
|
|
207
226
|
const data = d.filter?.(v => v.id === t.id);
|
|
208
227
|
|
|
209
|
-
return data.length ?
|
|
210
|
-
d3Select(this).datum(data[0]) : false;
|
|
228
|
+
return data.length ? d3Select(this).datum(data[0]) : false;
|
|
211
229
|
});
|
|
212
230
|
}
|
|
213
231
|
|
|
@@ -332,15 +350,15 @@ export default {
|
|
|
332
350
|
const scale = $$.isBubbleType(d) ? 1.15 : 1.75;
|
|
333
351
|
|
|
334
352
|
return config.point_focus_expand_enabled ?
|
|
335
|
-
(config.point_focus_expand_r || $$.pointR(d) * scale) :
|
|
353
|
+
(config.point_focus_expand_r || $$.pointR(d) * scale) :
|
|
354
|
+
$$.pointR(d);
|
|
336
355
|
},
|
|
337
356
|
|
|
338
357
|
pointSelectR(d): number {
|
|
339
358
|
const $$ = this;
|
|
340
359
|
const selectR = $$.config.point_select_r;
|
|
341
360
|
|
|
342
|
-
return isFunction(selectR) ?
|
|
343
|
-
selectR(d) : (selectR || $$.pointR(d) * 4);
|
|
361
|
+
return isFunction(selectR) ? selectR(d) : (selectR || $$.pointR(d) * 4);
|
|
344
362
|
},
|
|
345
363
|
|
|
346
364
|
/**
|
|
@@ -360,7 +378,9 @@ export default {
|
|
|
360
378
|
const mouse = getPointer(state.event, node);
|
|
361
379
|
const element = d3Select(node);
|
|
362
380
|
const prefix = this.isCirclePoint(node) ? "c" : "";
|
|
363
|
-
const sensitivity = config.point_sensitivity === "radius" ?
|
|
381
|
+
const sensitivity = config.point_sensitivity === "radius" ?
|
|
382
|
+
node.getAttribute("r") :
|
|
383
|
+
config.point_sensitivity;
|
|
364
384
|
let cx = +element.attr(`${prefix}x`);
|
|
365
385
|
let cy = +element.attr(`${prefix}y`);
|
|
366
386
|
|
|
@@ -410,13 +430,14 @@ export default {
|
|
|
410
430
|
}
|
|
411
431
|
|
|
412
432
|
this.setAttribute("class", className);
|
|
413
|
-
}) :
|
|
433
|
+
}) :
|
|
434
|
+
$$.getClass("circle", true)(d);
|
|
414
435
|
}
|
|
415
436
|
|
|
416
437
|
return pointClass;
|
|
417
438
|
},
|
|
418
439
|
|
|
419
|
-
generateGetLinePoints(lineIndices, isSub?: boolean):Function { // partial duplication of generateGetBarPoints
|
|
440
|
+
generateGetLinePoints(lineIndices, isSub?: boolean): Function { // partial duplication of generateGetBarPoints
|
|
420
441
|
const $$ = this;
|
|
421
442
|
const {config} = $$;
|
|
422
443
|
const x = $$.getShapeX(0, lineIndices, isSub);
|
|
@@ -431,9 +452,11 @@ export default {
|
|
|
431
452
|
let posY = y(d);
|
|
432
453
|
|
|
433
454
|
// fix posY not to overflow opposite quadrant
|
|
434
|
-
if (
|
|
435
|
-
|
|
436
|
-
|
|
455
|
+
if (
|
|
456
|
+
config.axis_rotated && (
|
|
457
|
+
(d.value > 0 && posY < y0) || (d.value < 0 && y0 < posY)
|
|
458
|
+
)
|
|
459
|
+
) {
|
|
437
460
|
posY = y0;
|
|
438
461
|
}
|
|
439
462
|
|
|
@@ -458,8 +481,7 @@ export default {
|
|
|
458
481
|
.node();
|
|
459
482
|
},
|
|
460
483
|
|
|
461
|
-
update(element, xPosFn, yPosFn, fillStyleFn,
|
|
462
|
-
withTransition, flow, selectedCircles) {
|
|
484
|
+
update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
|
463
485
|
const $$ = this;
|
|
464
486
|
const {width, height} = element.node().getBBox();
|
|
465
487
|
|
|
@@ -491,8 +513,7 @@ export default {
|
|
|
491
513
|
.node();
|
|
492
514
|
},
|
|
493
515
|
|
|
494
|
-
update(element, xPosFn, yPosFn, fillStyleFn,
|
|
495
|
-
withTransition, flow, selectedCircles) {
|
|
516
|
+
update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
|
496
517
|
const $$ = this;
|
|
497
518
|
let mainCircles = element;
|
|
498
519
|
|
|
@@ -531,8 +552,7 @@ export default {
|
|
|
531
552
|
.node();
|
|
532
553
|
},
|
|
533
554
|
|
|
534
|
-
update(element, xPosFn, yPosFn, fillStyleFn,
|
|
535
|
-
withTransition, flow, selectedCircles) {
|
|
555
|
+
update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
|
536
556
|
const $$ = this;
|
|
537
557
|
const r = $$.config.point_r;
|
|
538
558
|
const rectXPosFn = d => xPosFn(d) - r;
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
|
|
42
42
|
// set level text background color
|
|
43
43
|
if (levelTextShow && levelTextBgColor) {
|
|
44
|
-
$$.
|
|
44
|
+
$$.generateTextBGColorFilter(levelTextBgColor);
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
|
|
@@ -116,7 +116,9 @@ export default {
|
|
|
116
116
|
|
|
117
117
|
if (config.polar_level_text_show) {
|
|
118
118
|
const levelTextBackgroundColor = config.polar_level_text_backgroundColor;
|
|
119
|
-
const defsId = `#${state.datetimeId}-labels-bg${
|
|
119
|
+
const defsId = `#${state.datetimeId}-labels-bg${
|
|
120
|
+
$$.getTargetSelectorSuffix(levelTextBackgroundColor)
|
|
121
|
+
}`;
|
|
120
122
|
|
|
121
123
|
levelEnter.append("text")
|
|
122
124
|
.style("text-anchor", "middle");
|
|
@@ -3,9 +3,19 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
|
-
import {KEY} from "../../module/Cache";
|
|
7
6
|
import {$AXIS, $COMMON, $LEVEL, $RADAR, $SHAPE, $TEXT} from "../../config/classes";
|
|
8
|
-
import {
|
|
7
|
+
import {KEY} from "../../module/Cache";
|
|
8
|
+
import {
|
|
9
|
+
getMinMax,
|
|
10
|
+
getPathBox,
|
|
11
|
+
getRange,
|
|
12
|
+
isDefined,
|
|
13
|
+
isEmpty,
|
|
14
|
+
isNumber,
|
|
15
|
+
isUndefined,
|
|
16
|
+
setTextValue,
|
|
17
|
+
toArray
|
|
18
|
+
} from "../../module/util";
|
|
9
19
|
|
|
10
20
|
/**
|
|
11
21
|
* Get the position value
|
|
@@ -18,7 +28,8 @@ import {getMinMax, getPathBox, getRange, isDefined, isEmpty, isNumber, isUndefin
|
|
|
18
28
|
* @returns {number}
|
|
19
29
|
* @private
|
|
20
30
|
*/
|
|
21
|
-
function getPosition(isClockwise: boolean, type: "x" | "y", edge: number, pos: number,
|
|
31
|
+
function getPosition(isClockwise: boolean, type: "x" | "y", edge: number, pos: number,
|
|
32
|
+
range: number, ratio: number): number {
|
|
22
33
|
const index = isClockwise && pos > 0 ? edge - pos : pos;
|
|
23
34
|
const r = 2 * Math.PI;
|
|
24
35
|
const func = type === "x" ? Math.sin : Math.cos;
|
|
@@ -67,7 +78,7 @@ export default {
|
|
|
67
78
|
const $$ = this;
|
|
68
79
|
const {config, state: {arcWidth, arcHeight}} = $$;
|
|
69
80
|
const padding = config.axis_x_categories.length < 4 ? -20 : 10;
|
|
70
|
-
const size = (
|
|
81
|
+
const size = (Math.min(arcWidth, arcHeight) - padding) / 2;
|
|
71
82
|
|
|
72
83
|
return [size, size];
|
|
73
84
|
},
|
|
@@ -77,7 +88,9 @@ export default {
|
|
|
77
88
|
const {config} = $$;
|
|
78
89
|
|
|
79
90
|
if (isEmpty(config.axis_x_categories)) {
|
|
80
|
-
config.axis_x_categories = getRange(0, getMinMax("max", targets.map(v =>
|
|
91
|
+
config.axis_x_categories = getRange(0, getMinMax("max", targets.map(v =>
|
|
92
|
+
v.values.length
|
|
93
|
+
)));
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
$$.generateRadarPoints();
|
|
@@ -90,14 +103,16 @@ export default {
|
|
|
90
103
|
const edge = config.axis_x_categories.length;
|
|
91
104
|
const isClockwise = config.radar_direction_clockwise;
|
|
92
105
|
|
|
93
|
-
const pos = toArray(type).map(v =>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
106
|
+
const pos = toArray(type).map(v =>
|
|
107
|
+
getPosition(
|
|
108
|
+
isClockwise,
|
|
109
|
+
v,
|
|
110
|
+
edge,
|
|
111
|
+
index,
|
|
112
|
+
isDefined(range) ? range : (type === "x" ? width : height),
|
|
113
|
+
isNumber(ratio) ? ratio : config.radar_size_ratio
|
|
114
|
+
)
|
|
115
|
+
);
|
|
101
116
|
|
|
102
117
|
return pos.length === 1 ? pos[0] : pos;
|
|
103
118
|
},
|
|
@@ -177,8 +192,10 @@ export default {
|
|
|
177
192
|
// Generate points
|
|
178
193
|
const points = levelData.map(v => {
|
|
179
194
|
const range = levelRatio[v];
|
|
180
|
-
const pos = getRange(0, edge).map(i =>
|
|
181
|
-
|
|
195
|
+
const pos = getRange(0, edge).map(i =>
|
|
196
|
+
(
|
|
197
|
+
$$.getRadarPosition(["x", "y"], i, range, 1)
|
|
198
|
+
).join(",")
|
|
182
199
|
);
|
|
183
200
|
|
|
184
201
|
return pos.join(" ");
|
|
@@ -209,14 +226,17 @@ export default {
|
|
|
209
226
|
levelEnter.append("text")
|
|
210
227
|
.attr("dx", "-.5em")
|
|
211
228
|
.style("text-anchor", "end")
|
|
212
|
-
.text(d =>
|
|
213
|
-
|
|
214
|
-
|
|
229
|
+
.text(d =>
|
|
230
|
+
levelTextFormat(
|
|
231
|
+
state.current.dataMax / levelData.length * (d + 1)
|
|
232
|
+
)
|
|
233
|
+
);
|
|
215
234
|
}
|
|
216
235
|
|
|
217
236
|
levelEnter
|
|
218
237
|
.merge(level)
|
|
219
|
-
.attr("transform",
|
|
238
|
+
.attr("transform",
|
|
239
|
+
d => `translate(${width - levelRatio[d]}, ${height - levelRatio[d]})`)
|
|
220
240
|
.selectAll("polygon")
|
|
221
241
|
.attr("points", d => points[d]);
|
|
222
242
|
|
|
@@ -327,9 +347,7 @@ export default {
|
|
|
327
347
|
if (isMouse || noIndex) {
|
|
328
348
|
$$.hideTooltip();
|
|
329
349
|
|
|
330
|
-
focusOnly ?
|
|
331
|
-
$$.hideCircleFocus() :
|
|
332
|
-
$$.unexpandCircles();
|
|
350
|
+
focusOnly ? $$.hideCircleFocus() : $$.unexpandCircles();
|
|
333
351
|
|
|
334
352
|
if (isMouse) {
|
|
335
353
|
$$.setOverOut(false, index);
|