billboard.js 3.6.3 → 3.7.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/dist/billboard.css +1 -1
- package/dist/billboard.js +524 -160
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +1660 -1227
- package/dist/billboard.pkgd.min.js +4 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +35 -3
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +35 -3
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +35 -3
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +35 -3
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +875 -880
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +908 -881
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +908 -881
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +908 -881
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +908 -881
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist-esm/billboard.js +369 -101
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +40 -35
- package/src/Chart/api/chart.ts +13 -4
- package/src/Chart/api/export.ts +159 -14
- package/src/ChartInternal/Axis/Axis.ts +1 -1
- package/src/ChartInternal/data/IData.ts +1 -0
- package/src/ChartInternal/data/data.ts +21 -2
- package/src/ChartInternal/internals/domain.ts +11 -4
- package/src/ChartInternal/internals/format.ts +1 -1
- package/src/ChartInternal/internals/grid.ts +1 -1
- package/src/ChartInternal/shape/arc.ts +145 -68
- package/src/ChartInternal/shape/area.ts +3 -0
- package/src/ChartInternal/shape/bar.ts +3 -0
- package/src/ChartInternal/shape/line.ts +12 -15
- package/src/config/Options/common/tooltip.ts +11 -8
- package/src/config/Options/shape/arc.ts +47 -0
- package/src/config/Options/shape/gauge.ts +2 -2
- package/src/config/resolver/shape.ts +13 -4
- package/src/module/util.ts +1 -1
- package/types/chart.d.ts +7 -0
- package/types/options.d.ts +39 -624
- package/types/options.shape.d.ts +633 -0
- package/types/types.d.ts +2 -2
|
@@ -12,7 +12,119 @@ import {document} from "../../module/browser";
|
|
|
12
12
|
import {$ARC, $COMMON, $FOCUS, $GAUGE} from "../../config/classes";
|
|
13
13
|
import {callFn, endall, isFunction, isNumber, isObject, isUndefined, setTextValue} from "../../module/util";
|
|
14
14
|
import type {d3Selection} from "../../../types/types";
|
|
15
|
-
import type {IArcData, IData} from "../data/IData";
|
|
15
|
+
import type {IArcData, IArcDataRow, IData} from "../data/IData";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get radius functions
|
|
19
|
+
* @param {number} expandRate Expand rate number.
|
|
20
|
+
* - If 0, means for "normal" radius.
|
|
21
|
+
* - If > 0, means for "expanded" radius.
|
|
22
|
+
* @returns {object} radius functions
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
function getRadiusFn(expandRate = 0) {
|
|
26
|
+
const $$ = this;
|
|
27
|
+
const {config, state} = $$;
|
|
28
|
+
const hasMultiArcGauge = $$.hasMultiArcGauge();
|
|
29
|
+
const singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
|
|
30
|
+
const expandWidth = expandRate ? (
|
|
31
|
+
Math.min(
|
|
32
|
+
state.radiusExpanded * expandRate - state.radius,
|
|
33
|
+
singleArcWidth * 0.8 - (1 - expandRate) * 100
|
|
34
|
+
)) : 0;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
/**
|
|
38
|
+
* Getter of arc innerRadius value
|
|
39
|
+
* @param {IArcData} d Data object
|
|
40
|
+
* @returns {number} innerRadius value
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
inner(d: IArcData) {
|
|
44
|
+
const {innerRadius} = $$.getRadius(d);
|
|
45
|
+
|
|
46
|
+
return hasMultiArcGauge ?
|
|
47
|
+
state.radius - singleArcWidth * (d.index + 1) :
|
|
48
|
+
isNumber(innerRadius) ? innerRadius : 0;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Getter of arc outerRadius value
|
|
53
|
+
* @param {IArcData} d Data object
|
|
54
|
+
* @returns {number} outerRadius value
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
outer(d: IArcData) {
|
|
58
|
+
const {outerRadius} = $$.getRadius(d);
|
|
59
|
+
let radius: number;
|
|
60
|
+
|
|
61
|
+
if (hasMultiArcGauge) {
|
|
62
|
+
radius = state.radius - singleArcWidth * d.index + expandWidth;
|
|
63
|
+
} else if ($$.hasType("polar") && !expandRate) {
|
|
64
|
+
radius = $$.getPolarOuterRadius(d, outerRadius);
|
|
65
|
+
} else {
|
|
66
|
+
radius = outerRadius;
|
|
67
|
+
|
|
68
|
+
if (expandRate) {
|
|
69
|
+
let {radiusExpanded} = state;
|
|
70
|
+
|
|
71
|
+
if (state.radius !== outerRadius) {
|
|
72
|
+
radiusExpanded -= Math.abs(state.radius - outerRadius);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
radius = radiusExpanded * expandRate;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return radius;
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Getter of arc cornerRadius value
|
|
84
|
+
* @param {IArcData} d Data object
|
|
85
|
+
* @param {number} outerRadius outer radius value
|
|
86
|
+
* @returns {number} cornerRadius value
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
corner(d: IArcData, outerRadius): number {
|
|
90
|
+
const {
|
|
91
|
+
arc_cornerRadius_ratio: ratio = 0,
|
|
92
|
+
arc_cornerRadius: cornerRadius = 0
|
|
93
|
+
} = config;
|
|
94
|
+
const {data: {id}, value} = d;
|
|
95
|
+
let corner = 0;
|
|
96
|
+
|
|
97
|
+
if (ratio) {
|
|
98
|
+
corner = ratio * outerRadius;
|
|
99
|
+
} else {
|
|
100
|
+
corner = isNumber(cornerRadius) ?
|
|
101
|
+
cornerRadius : cornerRadius.call($$.api, id, value, outerRadius);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return corner;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get attrTween function to get interpolated value on transition
|
|
111
|
+
* @param {Function} fn Arc function to execute
|
|
112
|
+
* @returns {Function} attrTween function
|
|
113
|
+
* @private
|
|
114
|
+
*/
|
|
115
|
+
function getAttrTweenFn(fn: (d: IArcData) => string) {
|
|
116
|
+
return function(d: IArcData): (t: number) => string {
|
|
117
|
+
const interpolate = d3Interpolate(this._current, d);
|
|
118
|
+
|
|
119
|
+
this._current = d;
|
|
120
|
+
|
|
121
|
+
return function(t: number): string {
|
|
122
|
+
const interpolated = interpolate(t);
|
|
123
|
+
|
|
124
|
+
return fn(interpolated);
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
}
|
|
16
128
|
|
|
17
129
|
export default {
|
|
18
130
|
initPie(): void {
|
|
@@ -192,42 +304,22 @@ export default {
|
|
|
192
304
|
|
|
193
305
|
getSvgArc(): Function {
|
|
194
306
|
const $$ = this;
|
|
195
|
-
const {
|
|
196
|
-
const singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
|
|
197
|
-
const hasMultiArcGauge = $$.hasMultiArcGauge();
|
|
198
|
-
const hasPolar = $$.hasType("polar");
|
|
307
|
+
const {inner, outer, corner} = getRadiusFn.call($$);
|
|
199
308
|
|
|
200
309
|
const arc = d3Arc()
|
|
201
|
-
.innerRadius(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return hasMultiArcGauge ?
|
|
205
|
-
state.radius - singleArcWidth * (d.index + 1) :
|
|
206
|
-
isNumber(innerRadius) ? innerRadius : 0;
|
|
207
|
-
})
|
|
208
|
-
.outerRadius((d: any) => {
|
|
209
|
-
const {outerRadius} = $$.getRadius(d);
|
|
210
|
-
let radius = outerRadius;
|
|
211
|
-
|
|
212
|
-
if (hasMultiArcGauge) {
|
|
213
|
-
radius = state.radius - singleArcWidth * d.index;
|
|
214
|
-
} else if (hasPolar) {
|
|
215
|
-
radius = $$.getPolarOuterRadius(d, outerRadius);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return radius;
|
|
219
|
-
});
|
|
310
|
+
.innerRadius(inner)
|
|
311
|
+
.outerRadius(outer);
|
|
220
312
|
|
|
221
313
|
const newArc = function(d, withoutUpdate) {
|
|
222
314
|
let path: string | null = "M 0 0";
|
|
223
315
|
|
|
224
316
|
if (d.value || d.data) {
|
|
225
|
-
const
|
|
317
|
+
const data = withoutUpdate ? d : $$.updateAngle(d) ?? null;
|
|
226
318
|
|
|
227
|
-
if (
|
|
228
|
-
path = arc(
|
|
229
|
-
|
|
230
|
-
|
|
319
|
+
if (data) {
|
|
320
|
+
path = arc.cornerRadius(
|
|
321
|
+
corner(data, outer(data))
|
|
322
|
+
)(data);
|
|
231
323
|
}
|
|
232
324
|
}
|
|
233
325
|
|
|
@@ -240,45 +332,30 @@ export default {
|
|
|
240
332
|
return newArc;
|
|
241
333
|
},
|
|
242
334
|
|
|
243
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Get expanded arc path function
|
|
337
|
+
* @param {number} rate Expand rate
|
|
338
|
+
* @returns {Function} Expanded arc path getter function
|
|
339
|
+
* @private
|
|
340
|
+
*/
|
|
341
|
+
getSvgArcExpanded(rate = 1): (d: IArcData) => string {
|
|
244
342
|
const $$ = this;
|
|
245
|
-
const {
|
|
246
|
-
const newRate = rate || 1;
|
|
247
|
-
const singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
|
|
248
|
-
const hasMultiArcGauge = $$.hasMultiArcGauge();
|
|
249
|
-
const expandWidth = Math.min(state.radiusExpanded * newRate - state.radius,
|
|
250
|
-
singleArcWidth * 0.8 - (1 - newRate) * 100
|
|
251
|
-
);
|
|
343
|
+
const {inner, outer, corner} = getRadiusFn.call($$, rate);
|
|
252
344
|
|
|
253
345
|
const arc = d3Arc()
|
|
254
|
-
.innerRadius(
|
|
255
|
-
|
|
256
|
-
state.radius - singleArcWidth * (d.index + 1) : $$.getRadius(d).innerRadius
|
|
257
|
-
))
|
|
258
|
-
.outerRadius((d: any) => {
|
|
259
|
-
let radius: number;
|
|
260
|
-
|
|
261
|
-
if (hasMultiArcGauge) {
|
|
262
|
-
radius = state.radius - singleArcWidth * d.index + expandWidth;
|
|
263
|
-
} else {
|
|
264
|
-
const {outerRadius} = $$.getRadius(d);
|
|
346
|
+
.innerRadius(inner)
|
|
347
|
+
.outerRadius(outer);
|
|
265
348
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (state.radius !== outerRadius) {
|
|
269
|
-
radiusExpanded -= Math.abs(state.radius - outerRadius);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
radius = radiusExpanded * newRate;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return radius;
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
return function(d) {
|
|
349
|
+
return (d: IArcData): string => {
|
|
279
350
|
const updated = $$.updateAngle(d);
|
|
351
|
+
const outerR = outer(updated);
|
|
352
|
+
let cornerR = 0;
|
|
353
|
+
|
|
354
|
+
if (updated) {
|
|
355
|
+
cornerR = corner(updated, outerR);
|
|
356
|
+
}
|
|
280
357
|
|
|
281
|
-
return updated ? arc(updated) : "M 0 0";
|
|
358
|
+
return updated ? <string>arc.cornerRadius(cornerR)(updated) : "M 0 0";
|
|
282
359
|
};
|
|
283
360
|
},
|
|
284
361
|
|
|
@@ -292,7 +369,7 @@ export default {
|
|
|
292
369
|
* @returns {string} Translate attribute string
|
|
293
370
|
* @private
|
|
294
371
|
*/
|
|
295
|
-
transformForArcLabel(d): string {
|
|
372
|
+
transformForArcLabel(d: IArcData): string {
|
|
296
373
|
const $$ = this;
|
|
297
374
|
const {config, state: {radiusExpanded}} = $$;
|
|
298
375
|
|
|
@@ -337,9 +414,9 @@ export default {
|
|
|
337
414
|
return translate;
|
|
338
415
|
},
|
|
339
416
|
|
|
340
|
-
convertToArcData(d): object {
|
|
417
|
+
convertToArcData(d: IArcData | IArcDataRow): object {
|
|
341
418
|
return this.addName({
|
|
342
|
-
id:
|
|
419
|
+
id: "data" in d ? d.data.id : d.id,
|
|
343
420
|
value: d.value,
|
|
344
421
|
ratio: this.getRatio("arc", d),
|
|
345
422
|
index: d.index,
|
|
@@ -408,10 +485,10 @@ export default {
|
|
|
408
485
|
d3Select(this).selectAll("path")
|
|
409
486
|
.transition()
|
|
410
487
|
.duration(expandDuration)
|
|
411
|
-
.
|
|
488
|
+
.attrTween("d", getAttrTweenFn($$.svgArcExpanded.bind($$)))
|
|
412
489
|
.transition()
|
|
413
490
|
.duration(expandDuration * 2)
|
|
414
|
-
.
|
|
491
|
+
.attrTween("d", getAttrTweenFn(svgArcExpandedSub.bind($$)));
|
|
415
492
|
});
|
|
416
493
|
},
|
|
417
494
|
|
|
@@ -429,7 +506,7 @@ export default {
|
|
|
429
506
|
.selectAll("path")
|
|
430
507
|
.transition()
|
|
431
508
|
.duration(d => $$.getExpandConfig(d.data.id, "duration"))
|
|
432
|
-
.
|
|
509
|
+
.attrTween("d", getAttrTweenFn($$.svgArc.bind($$)));
|
|
433
510
|
|
|
434
511
|
svg.selectAll(`${$ARC.arc}`)
|
|
435
512
|
.style("opacity", null);
|
|
@@ -209,7 +209,6 @@ export default {
|
|
|
209
209
|
const {config} = $$;
|
|
210
210
|
const isRotated = config.axis_rotated;
|
|
211
211
|
const isTimeSeries = $$.axis.isTimeSeries();
|
|
212
|
-
const xOffset = $$.axis.isCategorized() ? 0.5 : 0;
|
|
213
212
|
const regions: any[] = [];
|
|
214
213
|
const dasharray = "2 2"; // default value
|
|
215
214
|
|
|
@@ -218,17 +217,6 @@ export default {
|
|
|
218
217
|
let diff;
|
|
219
218
|
let diffx2;
|
|
220
219
|
|
|
221
|
-
// check weather data is within region
|
|
222
|
-
const isWithinRegions = (withinX, withinRegions) => {
|
|
223
|
-
for (let i = 0, reg; (reg = withinRegions[i]); i++) {
|
|
224
|
-
if (reg.start < withinX && withinX <= reg.end) {
|
|
225
|
-
return reg.style;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return false;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
220
|
// Check start/end of regions
|
|
233
221
|
if (isDefined(_regions)) {
|
|
234
222
|
const getValue = (v: Date | any, def: number): Date | any => (
|
|
@@ -250,7 +238,6 @@ export default {
|
|
|
250
238
|
|
|
251
239
|
// Define svg generator function for region
|
|
252
240
|
const generateM = points => `M${points[0][0]},${points[0][1]}L${points[1][0]},${points[1][1]}`;
|
|
253
|
-
|
|
254
241
|
const sWithRegion = isTimeSeries ? (d0, d1, k, timeseriesDiff) => {
|
|
255
242
|
const x0 = d0.x.getTime();
|
|
256
243
|
const xDiff = d1.x - d0.x;
|
|
@@ -277,7 +264,7 @@ export default {
|
|
|
277
264
|
for (let i = 0, data; (data = d[i]); i++) {
|
|
278
265
|
const prevData = d[i - 1];
|
|
279
266
|
const hasPrevData = prevData && isValue(prevData.value);
|
|
280
|
-
let style = isWithinRegions(data.x, regions);
|
|
267
|
+
let style = $$.isWithinRegions(data.x, regions);
|
|
281
268
|
|
|
282
269
|
// https://github.com/naver/billboard.js/issues/1172
|
|
283
270
|
if (!isValue(data.value)) {
|
|
@@ -295,7 +282,7 @@ export default {
|
|
|
295
282
|
}
|
|
296
283
|
|
|
297
284
|
// Draw with region // TODO: Fix for horizotal charts
|
|
298
|
-
xp = getScale(axisType.x, prevData.x
|
|
285
|
+
xp = getScale(axisType.x, prevData.x, data.x);
|
|
299
286
|
yp = getScale(axisType.y, prevData.value, data.value);
|
|
300
287
|
|
|
301
288
|
const dx = x(data.x) - x(prevData.x);
|
|
@@ -319,6 +306,16 @@ export default {
|
|
|
319
306
|
return path;
|
|
320
307
|
},
|
|
321
308
|
|
|
309
|
+
isWithinRegions(withinX, withinRegions): boolean {
|
|
310
|
+
for (let i = 0, reg; (reg = withinRegions[i]); i++) {
|
|
311
|
+
if (reg.start < withinX && withinX <= reg.end) {
|
|
312
|
+
return reg.style;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return false;
|
|
317
|
+
},
|
|
318
|
+
|
|
322
319
|
isWithinStep(that, y: number): boolean {
|
|
323
320
|
return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
|
|
324
321
|
},
|
|
@@ -22,17 +22,20 @@ export default {
|
|
|
22
22
|
* Specified function receives x of the data point to show.
|
|
23
23
|
* @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
|
|
24
24
|
* Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
|
|
25
|
-
* @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip. If undefined returned, the row of that value will be skipped to be called.
|
|
26
|
+
* - Will pass following arguments to the given function:
|
|
27
|
+
* - `value {string}`: Value of the data point
|
|
28
|
+
* - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
|
|
29
|
+
* - `id {string}`: id of the data point
|
|
30
|
+
* - `index {number}`: Index of the data point
|
|
28
31
|
* @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
|
|
29
32
|
* This option can be used to modify the tooltip position by returning object that has top and left.
|
|
30
33
|
* - Will pass following arguments to the given function:
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* - `data {Array}`: Current selected data array object.
|
|
35
|
+
* - `width {number}`: Width of tooltip.
|
|
36
|
+
* - `height {number}`: Height of tooltip.
|
|
37
|
+
* - `element {SVGElement}`: Tooltip event bound element
|
|
38
|
+
* - `pos {object}`: Current position of the tooltip.
|
|
36
39
|
* @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
|
|
37
40
|
* If tooltip.grouped is true, data includes multiple data points.<br><br>
|
|
38
41
|
* Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* area config options
|
|
7
|
+
*/
|
|
8
|
+
export default {
|
|
9
|
+
/**
|
|
10
|
+
* Set arc options
|
|
11
|
+
* @name arc
|
|
12
|
+
* @memberof Options
|
|
13
|
+
* @type {object}
|
|
14
|
+
* @property {object} arc Arc object
|
|
15
|
+
* @property {number|Function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
|
|
16
|
+
* - **NOTE:**
|
|
17
|
+
* - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
|
|
18
|
+
* @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
|
|
19
|
+
* @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
|
|
20
|
+
* @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
|
|
21
|
+
* @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
|
|
22
|
+
* @example
|
|
23
|
+
* arc: {
|
|
24
|
+
* cornerRadius: 12,
|
|
25
|
+
*
|
|
26
|
+
* // can customize corner radius for each data with function callback
|
|
27
|
+
* //
|
|
28
|
+
* // The function will receive:
|
|
29
|
+
* // - id {string}: Data id
|
|
30
|
+
* // - value {number}: Data value
|
|
31
|
+
* // - outerRadius {number}: Outer radius value
|
|
32
|
+
* cornerRadius: function(id, value, outerRadius) {
|
|
33
|
+
* return (id === "data1" && value > 10) ?
|
|
34
|
+
* 50 : outerRadius * 1.2;
|
|
35
|
+
* },
|
|
36
|
+
*
|
|
37
|
+
* // set ratio relative of outer radius
|
|
38
|
+
* cornerRadius: {
|
|
39
|
+
* ratio: 0.5
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
43
|
+
arc_cornerRadius: <
|
|
44
|
+
number|((id: string, value: number) => number)
|
|
45
|
+
> 0,
|
|
46
|
+
arc_cornerRadius_ratio: 0
|
|
47
|
+
};
|
|
@@ -39,7 +39,7 @@ export default {
|
|
|
39
39
|
* - `startingAngle < -1 * Math.PI` defaults to `Math.PI`
|
|
40
40
|
* - `startingAngle > Math.PI` defaults to `Math.PI`
|
|
41
41
|
* @property {number} [gauge.arcLength=100] Set the length of the arc to be drawn in percent from -100 to 100.<br>
|
|
42
|
-
* Negative value will draw the arc **counterclockwise**.
|
|
42
|
+
* Negative value will draw the arc **counterclockwise**. Need to be used in conjunction with `gauge.fullCircle=true`.
|
|
43
43
|
*
|
|
44
44
|
* **Limitations:**
|
|
45
45
|
* - -100 <= arcLength (in percent) <= 100
|
|
@@ -52,7 +52,7 @@ export default {
|
|
|
52
52
|
* **Available Values:**
|
|
53
53
|
* - single
|
|
54
54
|
* - multi
|
|
55
|
-
* @property {
|
|
55
|
+
* @property {number} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
|
|
56
56
|
* @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
|
|
57
57
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
|
|
58
58
|
* @example
|
|
@@ -38,6 +38,7 @@ import optScatter from "../Options/shape/scatter";
|
|
|
38
38
|
import optSpline from "../Options/shape/spline";
|
|
39
39
|
|
|
40
40
|
// Non-Axis based
|
|
41
|
+
import optArc from "../Options/shape/arc";
|
|
41
42
|
import optDonut from "../Options/shape/donut";
|
|
42
43
|
import optGauge from "../Options/shape/gauge";
|
|
43
44
|
import optPie from "../Options/shape/pie";
|
|
@@ -121,10 +122,18 @@ let spline = (): string => (extendLine(undefined, [optSpline]), (spline = () =>
|
|
|
121
122
|
let step = (): string => (extendLine(), (step = () => TYPE.STEP)());
|
|
122
123
|
|
|
123
124
|
// Arc types
|
|
124
|
-
let donut = (): string => (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
let
|
|
125
|
+
let donut = (): string => (
|
|
126
|
+
extendArc(undefined, [optArc, optDonut]), (donut = () => TYPE.DONUT)()
|
|
127
|
+
);
|
|
128
|
+
let gauge = (): string => (
|
|
129
|
+
extendArc([shapeGauge], [optArc, optGauge]), (gauge = () => TYPE.GAUGE)()
|
|
130
|
+
);
|
|
131
|
+
let pie = (): string => (
|
|
132
|
+
extendArc(undefined, [optArc, optPie]), (pie = () => TYPE.PIE)()
|
|
133
|
+
);
|
|
134
|
+
let polar = (): string => (
|
|
135
|
+
extendArc([shapePolar], [optArc, optPolar]), (polar = () => TYPE.POLAR)()
|
|
136
|
+
);
|
|
128
137
|
let radar = (): string => (
|
|
129
138
|
extendArc([shapePoint, shapeRadar], [optPoint, optRadar]), (radar = () => TYPE.RADAR)()
|
|
130
139
|
);
|
package/src/module/util.ts
CHANGED
|
@@ -497,7 +497,7 @@ function getCssRules(styleSheets: any[]) {
|
|
|
497
497
|
rules = rules.concat(toArray(sheet.cssRules));
|
|
498
498
|
}
|
|
499
499
|
} catch (e) {
|
|
500
|
-
console
|
|
500
|
+
window.console?.warn(`Error while reading rules from ${sheet.href}: ${e.toString()}`);
|
|
501
501
|
}
|
|
502
502
|
});
|
|
503
503
|
|
package/types/chart.d.ts
CHANGED
|
@@ -504,6 +504,12 @@ export interface Chart {
|
|
|
504
504
|
* @param [option.width={currentWidth}] width
|
|
505
505
|
* @param [option.height={currentHeigth}] height
|
|
506
506
|
* @param [option.preserveAspectRatio=true] Preserve aspect ratio on given size
|
|
507
|
+
* @param [option.preserveFontStyle=false] Preserve font style(font-family).
|
|
508
|
+
* **NOTE:**
|
|
509
|
+
* - This option is useful when outlink web font style's `font-family` are applied to chart's text element.
|
|
510
|
+
* - Text element's position(especially "transformed") can't be preserved correctly according the page's layout condition.
|
|
511
|
+
* - If need to preserve accurate text position, embed the web font data within to the page and set `preserveFontStyle=false`.
|
|
512
|
+
* - Checkout the embed example: https://stackblitz.com/edit/zfbya9-8nf9nn?file=index.html
|
|
507
513
|
* @param callback The callback to be invoked when export is ready.
|
|
508
514
|
*/
|
|
509
515
|
export(this: Chart, option?: {
|
|
@@ -511,6 +517,7 @@ export interface Chart {
|
|
|
511
517
|
height?: number;
|
|
512
518
|
mimeType?: string;
|
|
513
519
|
preserveAspectRatio?: boolean;
|
|
520
|
+
preserveFontStyle?: boolean;
|
|
514
521
|
}, callback?: (this: Chart, dataUrl: string) => void): string;
|
|
515
522
|
|
|
516
523
|
/**
|