billboard.js 3.16.0 → 3.17.0
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 +4 -4
- package/dist/billboard.js +645 -82
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +12 -12
- package/dist/billboard.pkgd.js +1987 -786
- package/dist/billboard.pkgd.min.js +18 -17
- 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 +18 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-stanford.js +18 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-tableview.js +16 -2
- package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +16 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1344 -706
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +6 -5
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1454 -800
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +8 -7
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +1455 -801
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +13 -12
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1454 -802
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +10 -9
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +1455 -803
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -6
- package/dist/theme/dark.css +4 -4
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +4 -4
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +4 -4
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +4 -4
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +4 -4
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/billboard.js +697 -79
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +4 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +21 -21
- package/src/ChartInternal/Axis/AxisRenderer.ts +20 -13
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +9 -4
- package/src/ChartInternal/data/convert.ts +3 -3
- package/src/ChartInternal/data/data.ts +2 -2
- package/src/ChartInternal/internals/color.ts +20 -14
- package/src/ChartInternal/internals/text.ts +40 -125
- package/src/ChartInternal/internals/text.util.ts +320 -0
- package/src/ChartInternal/shape/arc.ts +41 -19
- package/src/ChartInternal/shape/treemap.ts +5 -6
- package/src/config/Options/axis/x.ts +18 -0
- package/src/config/Options/axis/y.ts +17 -0
- package/src/config/Options/axis/y2.ts +18 -0
- package/src/config/Options/common/boost.ts +1 -0
- package/src/config/Options/data/data.ts +125 -4
- package/src/config/Options/shape/donut.ts +77 -1
- package/src/config/Options/shape/gauge.ts +69 -2
- package/src/config/Options/shape/pie.ts +68 -1
- package/src/config/Options/shape/polar.ts +68 -1
- package/src/config/classes.ts +2 -0
- package/src/module/util.ts +26 -0
- package/types/axis.d.ts +10 -0
- package/types/options.d.ts +138 -1
- package/types/options.shape.d.ts +302 -2
|
@@ -17,6 +17,7 @@ import type {d3Selection} from "../../../types/types";
|
|
|
17
17
|
import {$COMMON, $TREEMAP} from "../../config/classes";
|
|
18
18
|
import {getRandom, isFunction} from "../../module/util";
|
|
19
19
|
import type {IData, IDataRow, ITreemapData} from "../data/IData";
|
|
20
|
+
import {meetsLabelThreshold} from "../internals/text.util";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Get treemap elements' position
|
|
@@ -300,12 +301,10 @@ export default {
|
|
|
300
301
|
const format = config.treemap_label_format;
|
|
301
302
|
const ratio = $$.getRatio("treemap", d);
|
|
302
303
|
const percentValue = (ratio * 100).toFixed(2);
|
|
303
|
-
const meetLabelThreshold =
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
null :
|
|
308
|
-
"0";
|
|
304
|
+
const meetLabelThreshold =
|
|
305
|
+
config.treemap_label_show && meetsLabelThreshold.call($$, ratio, "treemap") ?
|
|
306
|
+
null :
|
|
307
|
+
"0";
|
|
309
308
|
|
|
310
309
|
return function(node) {
|
|
311
310
|
node.style("opacity", meetLabelThreshold);
|
|
@@ -263,6 +263,24 @@ export default {
|
|
|
263
263
|
*/
|
|
264
264
|
axis_x_tick_count: <number | undefined>undefined,
|
|
265
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
268
|
+
* @name axis․x․tick․inner
|
|
269
|
+
* @memberof Options
|
|
270
|
+
* @type {boolean}
|
|
271
|
+
* @default false
|
|
272
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
273
|
+
* @example
|
|
274
|
+
* axis: {
|
|
275
|
+
* x: {
|
|
276
|
+
* tick: {
|
|
277
|
+
* inner: true
|
|
278
|
+
* }
|
|
279
|
+
* }
|
|
280
|
+
* }
|
|
281
|
+
*/
|
|
282
|
+
axis_x_tick_inner: false,
|
|
283
|
+
|
|
266
284
|
/**
|
|
267
285
|
* Show or hide x axis tick line.
|
|
268
286
|
* @name axis․x․tick․show
|
|
@@ -266,6 +266,23 @@ export default {
|
|
|
266
266
|
*/
|
|
267
267
|
axis_y_tick_culling_reverse: false,
|
|
268
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
271
|
+
* @name axis․y․tick․inner
|
|
272
|
+
* @memberof Options
|
|
273
|
+
* @type {boolean}
|
|
274
|
+
* @default false
|
|
275
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
276
|
+
* axis: {
|
|
277
|
+
* y: {
|
|
278
|
+
* tick: {
|
|
279
|
+
* inner: true
|
|
280
|
+
* }
|
|
281
|
+
* }
|
|
282
|
+
* }
|
|
283
|
+
*/
|
|
284
|
+
axis_y_tick_inner: false,
|
|
285
|
+
|
|
269
286
|
/**
|
|
270
287
|
* Show y axis outer tick.
|
|
271
288
|
* @name axis․y․tick․outer
|
|
@@ -252,6 +252,24 @@ export default {
|
|
|
252
252
|
*/
|
|
253
253
|
axis_y2_tick_culling_reverse: false,
|
|
254
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
257
|
+
* @name axis․y2․tick․inner
|
|
258
|
+
* @memberof Options
|
|
259
|
+
* @type {boolean}
|
|
260
|
+
* @default false
|
|
261
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
262
|
+
* @example
|
|
263
|
+
* axis: {
|
|
264
|
+
* y2: {
|
|
265
|
+
* tick: {
|
|
266
|
+
* inner: true
|
|
267
|
+
* }
|
|
268
|
+
* }
|
|
269
|
+
* }
|
|
270
|
+
*/
|
|
271
|
+
axis_y2_tick_inner: false,
|
|
272
|
+
|
|
255
273
|
/**
|
|
256
274
|
* Show or hide y2 axis outer tick.
|
|
257
275
|
* @name axis․y2․tick․outer
|
|
@@ -20,6 +20,7 @@ export default {
|
|
|
20
20
|
* - **NOTE:**
|
|
21
21
|
* - For now, only applies for data conversion at the initial time.
|
|
22
22
|
* - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
|
|
23
|
+
* - When given data is empty, useWorker will be ignored.
|
|
23
24
|
* @example
|
|
24
25
|
* boost: {
|
|
25
26
|
* useCssRule: true,
|
|
@@ -334,7 +334,10 @@ export default {
|
|
|
334
334
|
* - `i` is the index of the data series point where the label is shown.
|
|
335
335
|
* - `texts` is the array of whole corresponding data series' text labels.<br><br>
|
|
336
336
|
* Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
|
|
337
|
-
* @property {string|object} [data.labels.backgroundColors] Set label text background colors
|
|
337
|
+
* @property {string|object|Function} [data.labels.backgroundColors] Set label text background colors.<br><br>
|
|
338
|
+
* - **NOTE**: When function is set, background colors can be specified one color per dataset.
|
|
339
|
+
* - Within the function, the last returned color for dataset will be used.
|
|
340
|
+
* - Only can control set or unset background color for each values.
|
|
338
341
|
* @property {string|object|Function} [data.labels.colors] Set label text colors.
|
|
339
342
|
* @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
|
|
340
343
|
* When function is specified, will receives 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
|
|
@@ -348,12 +351,32 @@ export default {
|
|
|
348
351
|
* @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
|
|
349
352
|
* @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
|
|
350
353
|
* - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
|
|
354
|
+
* @property {boolean|object} [data.labels.border=false] Add border to data label text. NOTE: When set as `true`, styling aren't applied. Hence, need to set using `.bb-text-border` class.
|
|
355
|
+
* @property {number|string|object} [data.labels.border.padding="3 5"] Border padding. Can be a single number, string or object with top, bottom, left, right properties.
|
|
356
|
+
* @property {number} [data.labels.border.radius=10] Border radius value.
|
|
357
|
+
* @property {number} [data.labels.border.strokeWidth=1] Border stroke width.
|
|
358
|
+
* @property {string} [data.labels.border.stroke="#000"] Border stroke color.
|
|
359
|
+
* @property {string} [data.labels.border.fill="none"] Border fill color.
|
|
360
|
+
* @property {object|Function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
|
|
361
|
+
* When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
|
|
362
|
+
* The arguments are:<br>
|
|
363
|
+
* - `v` is the value of the data point where the label is shown.
|
|
364
|
+
* - `id` is the id of the data where the label is shown.
|
|
365
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
366
|
+
* @property {string} data.labels.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
367
|
+
* @property {number} data.labels.image.width Image width in pixels.
|
|
368
|
+
* @property {number} data.labels.image.height Image height in pixels.
|
|
369
|
+
* @property {object} [data.labels.image.pos] Image position relative to the label text.
|
|
370
|
+
* @property {number} [data.labels.image.pos.x=0] x coordinate position, relative the original.
|
|
371
|
+
* @property {number} [data.labels.image.pos.y=0] y coordinate position, relative the original.
|
|
351
372
|
* @memberof Options
|
|
352
373
|
* @type {object}
|
|
353
374
|
* @default {}
|
|
354
375
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataLabel)
|
|
376
|
+
* @see [Demo: label border](https://naver.github.io/billboard.js/demo/#Data.DataLabelBorder)
|
|
355
377
|
* @see [Demo: label colors](https://naver.github.io/billboard.js/demo/#Data.DataLabelColors)
|
|
356
378
|
* @see [Demo: label format](https://naver.github.io/billboard.js/demo/#Data.DataLabelFormat)
|
|
379
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#Data.DataLabelImage)
|
|
357
380
|
* @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
|
|
358
381
|
* @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
|
|
359
382
|
* @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
|
|
@@ -386,7 +409,15 @@ export default {
|
|
|
386
409
|
* backgroundColors: {
|
|
387
410
|
* data1: "green",
|
|
388
411
|
* data2: "yellow"
|
|
389
|
-
* }
|
|
412
|
+
* },
|
|
413
|
+
*
|
|
414
|
+
* // call back for label text background color
|
|
415
|
+
* backgroundColors: function(color, d) {
|
|
416
|
+
* // color: the default data label color string
|
|
417
|
+
* // data: ex) {x: 0, value: 200, id: "data3", index: 0}
|
|
418
|
+
* ....
|
|
419
|
+
* return d.value > 200 ? "cyan" : "red";
|
|
420
|
+
* },
|
|
390
421
|
*
|
|
391
422
|
* // apply for all label texts
|
|
392
423
|
* colors: "red",
|
|
@@ -426,7 +457,76 @@ export default {
|
|
|
426
457
|
* },
|
|
427
458
|
*
|
|
428
459
|
* // rotate degree for label text
|
|
429
|
-
* rotate: 90
|
|
460
|
+
* rotate: 90,
|
|
461
|
+
*
|
|
462
|
+
* // add border to data label text
|
|
463
|
+
* // NOTE: When set as `true`, styling aren't applied. Hence, need to set using '.bb-text-border' class.
|
|
464
|
+
* // ex. ".bb-text-border { fill: red; stroke: #000; stroke-width: 2px; rx: 10px; ry: 10px; }"
|
|
465
|
+
* border: true,
|
|
466
|
+
*
|
|
467
|
+
* // or set detailed border options
|
|
468
|
+
* border: {
|
|
469
|
+
* padding: 10, // set all padding to 10
|
|
470
|
+
* padding: "5 10", // set top and bottom padding to 5, left and right padding to 10
|
|
471
|
+
* padding: { // specify each padding
|
|
472
|
+
* top: 3,
|
|
473
|
+
* bottom: 5,
|
|
474
|
+
* left: 10,
|
|
475
|
+
* right: 13
|
|
476
|
+
* },
|
|
477
|
+
* radius: 10,
|
|
478
|
+
* strokeWidth: 2,
|
|
479
|
+
* stroke: "#000",
|
|
480
|
+
* fill: "red"
|
|
481
|
+
* },
|
|
482
|
+
*
|
|
483
|
+
* // set image to be displayed next to the label text
|
|
484
|
+
* image: {
|
|
485
|
+
* url: "./sample.svg",
|
|
486
|
+
*
|
|
487
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
488
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
489
|
+
* width: 35,
|
|
490
|
+
* height: 35,
|
|
491
|
+
* pos: {
|
|
492
|
+
* x: 0,
|
|
493
|
+
* y: 0
|
|
494
|
+
* }
|
|
495
|
+
* },
|
|
496
|
+
*
|
|
497
|
+
* // or use function to return image configuration dynamically
|
|
498
|
+
* image: function(v, id, i) {
|
|
499
|
+
* // v is the value of the data point where the label is shown.
|
|
500
|
+
* // id is the id of the data where the label is shown.
|
|
501
|
+
* // i is the index of the data series point where the label is shown.
|
|
502
|
+
*
|
|
503
|
+
* // Return different images based on value
|
|
504
|
+
* if (v > 500) {
|
|
505
|
+
* return {
|
|
506
|
+
* url: "./high-value.svg",
|
|
507
|
+
* width: 40,
|
|
508
|
+
* height: 40,
|
|
509
|
+
* pos: { x: 0, y: 0 }
|
|
510
|
+
* };
|
|
511
|
+
* } else if (v > 100) {
|
|
512
|
+
* return {
|
|
513
|
+
* url: "./medium-value.svg",
|
|
514
|
+
* width: 30,
|
|
515
|
+
* height: 30,
|
|
516
|
+
* pos: { x: 0, y: 0 }
|
|
517
|
+
* };
|
|
518
|
+
* } else if(v < 5) {
|
|
519
|
+
* // Return falsy value in case of don't want to show image
|
|
520
|
+
* return null;
|
|
521
|
+
* } else {
|
|
522
|
+
* return {
|
|
523
|
+
* url: "./low-value.svg",
|
|
524
|
+
* width: 20,
|
|
525
|
+
* height: 20,
|
|
526
|
+
* pos: { x: 0, y: 0 }
|
|
527
|
+
* };
|
|
528
|
+
* }
|
|
529
|
+
* }
|
|
430
530
|
* }
|
|
431
531
|
* }
|
|
432
532
|
*/
|
|
@@ -438,11 +538,32 @@ export default {
|
|
|
438
538
|
| number
|
|
439
539
|
| {[key: string]: number}
|
|
440
540
|
| {[key: string]: {x?: number, y?: number}},
|
|
441
|
-
rotate?: number
|
|
541
|
+
rotate?: number,
|
|
542
|
+
border?: boolean | {
|
|
543
|
+
padding?: number | string | {
|
|
544
|
+
top?: number,
|
|
545
|
+
bottom?: number,
|
|
546
|
+
left?: number,
|
|
547
|
+
right?: number
|
|
548
|
+
},
|
|
549
|
+
radius?: number,
|
|
550
|
+
strokeWidth?: number,
|
|
551
|
+
stroke?: string,
|
|
552
|
+
fill?: string
|
|
553
|
+
},
|
|
554
|
+
image?:
|
|
555
|
+
| {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
|
|
556
|
+
| ((v: number, id: string, i: number) => {
|
|
557
|
+
url: string,
|
|
558
|
+
width: number,
|
|
559
|
+
height: number,
|
|
560
|
+
pos?: {x?: number, y?: number}
|
|
561
|
+
} | null)
|
|
442
562
|
}>{},
|
|
443
563
|
data_labels_backgroundColors: <string | {[key: string]: string} | undefined>undefined,
|
|
444
564
|
data_labels_colors: <string | object | Function | undefined>undefined,
|
|
445
565
|
data_labels_position: {},
|
|
566
|
+
data_labels_imgUrl: <string | Function | undefined>undefined,
|
|
446
567
|
|
|
447
568
|
/**
|
|
448
569
|
* Hide each data when the chart appears.<br><br>
|
|
@@ -16,6 +16,18 @@ export default {
|
|
|
16
16
|
* @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
|
|
17
17
|
* @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
18
18
|
* @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
|
|
19
|
+
* @property {object|Function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
|
|
20
|
+
* When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
|
|
21
|
+
* The arguments are:<br>
|
|
22
|
+
* - `v` is the value of the data point where the label is shown.
|
|
23
|
+
* - `id` is the id of the data where the label is shown.
|
|
24
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
25
|
+
* @property {string} donut.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
26
|
+
* @property {number} donut.label.image.width Image width in pixels.
|
|
27
|
+
* @property {number} donut.label.image.height Image height in pixels.
|
|
28
|
+
* @property {object} [donut.label.image.pos] Image position relative to the label text.
|
|
29
|
+
* @property {number} [donut.label.image.pos.x=0] x coordinate position, relative the original.
|
|
30
|
+
* @property {number} [donut.label.image.pos.y=0] y coordinate position, relative the original.
|
|
19
31
|
* @property {boolean} [donut.expand=true] Enable or disable expanding donut pieces.
|
|
20
32
|
* @property {number} [donut.expand.rate=0.98] Set expand rate.
|
|
21
33
|
* @property {number} [donut.expand.duration=50] Set expand transition time in ms.
|
|
@@ -25,6 +37,16 @@ export default {
|
|
|
25
37
|
* - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
|
|
26
38
|
* @property {number} [donut.padAngle=0] Set padding between data.
|
|
27
39
|
* @property {number} [donut.startingAngle=0] Set starting angle where data draws.
|
|
40
|
+
* @see [Demo: Corner Radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
|
|
41
|
+
* @see [Demo: Needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
|
|
42
|
+
* @see [Demo: Range Text](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
|
|
43
|
+
* @see [Demo: Label Image](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelImage)
|
|
44
|
+
* @see [Demo: Label Ratio](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelRatio)
|
|
45
|
+
* @see [Demo: Multiline Label](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineLabel)
|
|
46
|
+
* @see [Demo: Multiline Title](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineTitle)
|
|
47
|
+
* @see [Demo: Pad Angle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.padAngle)
|
|
48
|
+
* @see [Demo: Starting Angle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.StartingAngle)
|
|
49
|
+
*
|
|
28
50
|
* @example
|
|
29
51
|
* donut: {
|
|
30
52
|
* label: {
|
|
@@ -46,7 +68,51 @@ export default {
|
|
|
46
68
|
* return ratio;
|
|
47
69
|
* },
|
|
48
70
|
* // or set ratio number
|
|
49
|
-
* ratio: 0.5
|
|
71
|
+
* ratio: 0.5,
|
|
72
|
+
*
|
|
73
|
+
* // set image to be displayed next to the label text
|
|
74
|
+
* image: {
|
|
75
|
+
* url: "./sample.svg",
|
|
76
|
+
*
|
|
77
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
78
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
79
|
+
* width: 35,
|
|
80
|
+
* height: 35,
|
|
81
|
+
* pos: {
|
|
82
|
+
* x: 0,
|
|
83
|
+
* y: 0
|
|
84
|
+
* }
|
|
85
|
+
* },
|
|
86
|
+
*
|
|
87
|
+
* // or use function to return image configuration dynamically
|
|
88
|
+
* image: function(v, id, i) {
|
|
89
|
+
* // Return different images based on value
|
|
90
|
+
* if (v > 500) {
|
|
91
|
+
* return {
|
|
92
|
+
* url: "./high-value.svg",
|
|
93
|
+
* width: 40,
|
|
94
|
+
* height: 40,
|
|
95
|
+
* pos: { x: 0, y: 0 }
|
|
96
|
+
* };
|
|
97
|
+
* } else if (v > 100) {
|
|
98
|
+
* return {
|
|
99
|
+
* url: "./medium-value.svg",
|
|
100
|
+
* width: 30,
|
|
101
|
+
* height: 30,
|
|
102
|
+
* pos: { x: 0, y: 0 }
|
|
103
|
+
* };
|
|
104
|
+
* } else if(v < 5) {
|
|
105
|
+
* // Return falsy value in case of don't want to show image
|
|
106
|
+
* return null;
|
|
107
|
+
* } else {
|
|
108
|
+
* return {
|
|
109
|
+
* url: "./low-value.svg",
|
|
110
|
+
* width: 20,
|
|
111
|
+
* height: 20,
|
|
112
|
+
* pos: { x: 0, y: 0 }
|
|
113
|
+
* };
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
50
116
|
* },
|
|
51
117
|
*
|
|
52
118
|
* // disable expand transition for interaction
|
|
@@ -75,6 +141,16 @@ export default {
|
|
|
75
141
|
donut_label_show: true,
|
|
76
142
|
donut_label_format: <(() => number | string) | undefined>undefined,
|
|
77
143
|
donut_label_threshold: 0.05,
|
|
144
|
+
donut_label_image: <
|
|
145
|
+
| {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
|
|
146
|
+
| ((v: number, id: string, i: number) => {
|
|
147
|
+
url: string,
|
|
148
|
+
width: number,
|
|
149
|
+
height: number,
|
|
150
|
+
pos?: {x?: number, y?: number}
|
|
151
|
+
} | null)
|
|
152
|
+
| undefined
|
|
153
|
+
>undefined,
|
|
78
154
|
donut_label_ratio: <number | (() => number) | undefined>undefined,
|
|
79
155
|
donut_width: <number | undefined>undefined,
|
|
80
156
|
donut_title: "",
|
|
@@ -23,6 +23,18 @@ export default {
|
|
|
23
23
|
* - id {string}: data's id value
|
|
24
24
|
* @property {number|Function} [gauge.label.ratio=undefined] Set ratio of labels position.
|
|
25
25
|
* @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
|
|
26
|
+
* @property {object|Function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
|
|
27
|
+
* When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
|
|
28
|
+
* The arguments are:<br>
|
|
29
|
+
* - `v` is the value of the data point where the label is shown.
|
|
30
|
+
* - `id` is the id of the data where the label is shown.
|
|
31
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
32
|
+
* @property {string} gauge.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
33
|
+
* @property {number} gauge.label.image.width Image width in pixels.
|
|
34
|
+
* @property {number} gauge.label.image.height Image height in pixels.
|
|
35
|
+
* @property {object} [gauge.label.image.pos] Image position relative to the label text.
|
|
36
|
+
* @property {number} [gauge.label.image.pos.x=0] x coordinate position, relative the original.
|
|
37
|
+
* @property {number} [gauge.label.image.pos.y=0] y coordinate position, relative the original.
|
|
26
38
|
* @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
|
|
27
39
|
* @property {number} [gauge.expand.rate=0.98] Set expand rate.
|
|
28
40
|
* @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
|
|
@@ -63,7 +75,8 @@ export default {
|
|
|
63
75
|
* @see [Demo: enforceMinMax, min/max](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeMinMax)
|
|
64
76
|
* @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
|
|
65
77
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
|
|
66
|
-
* @see [Demo:
|
|
78
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelImage)
|
|
79
|
+
* @see [Demo: label ratio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
|
|
67
80
|
* @example
|
|
68
81
|
* gauge: {
|
|
69
82
|
* background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
|
|
@@ -91,7 +104,51 @@ export default {
|
|
|
91
104
|
* return ratio;
|
|
92
105
|
* },
|
|
93
106
|
* // or set ratio number
|
|
94
|
-
* ratio: 0.5
|
|
107
|
+
* ratio: 0.5,
|
|
108
|
+
*
|
|
109
|
+
* // set image to be displayed next to the label text
|
|
110
|
+
* image: {
|
|
111
|
+
* url: "./sample.svg",
|
|
112
|
+
*
|
|
113
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
114
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
115
|
+
* width: 35,
|
|
116
|
+
* height: 35,
|
|
117
|
+
* pos: {
|
|
118
|
+
* x: 0,
|
|
119
|
+
* y: 0
|
|
120
|
+
* }
|
|
121
|
+
* },
|
|
122
|
+
*
|
|
123
|
+
* // or use function to return image configuration dynamically
|
|
124
|
+
* image: function(v, id, i) {
|
|
125
|
+
* // Return different images based on value
|
|
126
|
+
* if (v > 500) {
|
|
127
|
+
* return {
|
|
128
|
+
* url: "./high-value.svg",
|
|
129
|
+
* width: 40,
|
|
130
|
+
* height: 40,
|
|
131
|
+
* pos: { x: 0, y: 0 }
|
|
132
|
+
* };
|
|
133
|
+
* } else if (v > 100) {
|
|
134
|
+
* return {
|
|
135
|
+
* url: "./medium-value.svg",
|
|
136
|
+
* width: 30,
|
|
137
|
+
* height: 30,
|
|
138
|
+
* pos: { x: 0, y: 0 }
|
|
139
|
+
* };
|
|
140
|
+
* } else if(v < 5) {
|
|
141
|
+
* // Return falsy value in case of don't want to show image
|
|
142
|
+
* return null;
|
|
143
|
+
* } else {
|
|
144
|
+
* return {
|
|
145
|
+
* url: "./low-value.svg",
|
|
146
|
+
* width: 20,
|
|
147
|
+
* height: 20,
|
|
148
|
+
* pos: { x: 0, y: 0 }
|
|
149
|
+
* };
|
|
150
|
+
* }
|
|
151
|
+
* }
|
|
95
152
|
* },
|
|
96
153
|
*
|
|
97
154
|
* // disable expand transition for interaction
|
|
@@ -134,6 +191,16 @@ export default {
|
|
|
134
191
|
gauge_label_format: <(() => string) | undefined>undefined,
|
|
135
192
|
gauge_label_ratio: <(() => number) | undefined>undefined,
|
|
136
193
|
gauge_label_threshold: 0,
|
|
194
|
+
gauge_label_image: <
|
|
195
|
+
| {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
|
|
196
|
+
| ((v: number, id: string, i: number) => {
|
|
197
|
+
url: string,
|
|
198
|
+
width: number,
|
|
199
|
+
height: number,
|
|
200
|
+
pos?: {x?: number, y?: number}
|
|
201
|
+
} | null)
|
|
202
|
+
| undefined
|
|
203
|
+
>undefined,
|
|
137
204
|
gauge_enforceMinMax: false,
|
|
138
205
|
gauge_min: 0,
|
|
139
206
|
gauge_max: 100,
|
|
@@ -16,6 +16,18 @@ export default {
|
|
|
16
16
|
* @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
|
|
17
17
|
* @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
|
|
18
18
|
* @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
19
|
+
* @property {object|Function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
|
|
20
|
+
* When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
|
|
21
|
+
* The arguments are:<br>
|
|
22
|
+
* - `v` is the value of the data point where the label is shown.
|
|
23
|
+
* - `id` is the id of the data where the label is shown.
|
|
24
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
25
|
+
* @property {string} pie.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
26
|
+
* @property {number} pie.label.image.width Image width in pixels.
|
|
27
|
+
* @property {number} pie.label.image.height Image height in pixels.
|
|
28
|
+
* @property {object} [pie.label.image.pos] Image position relative to the label text.
|
|
29
|
+
* @property {number} [pie.label.image.pos.x=0] x coordinate position, relative the original.
|
|
30
|
+
* @property {number} [pie.label.image.pos.y=0] y coordinate position, relative the original.
|
|
19
31
|
* @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
|
|
20
32
|
* @property {number} [pie.expand.rate=0.98] Set expand rate.
|
|
21
33
|
* @property {number} [pie.expand.duration=50] Set expand transition time in ms.
|
|
@@ -28,6 +40,7 @@ export default {
|
|
|
28
40
|
* @see [Demo: innerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.InnerRadius)
|
|
29
41
|
* @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
|
|
30
42
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
|
|
43
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelImage)
|
|
31
44
|
* @example
|
|
32
45
|
* pie: {
|
|
33
46
|
* label: {
|
|
@@ -49,7 +62,51 @@ export default {
|
|
|
49
62
|
* return ratio;
|
|
50
63
|
* },
|
|
51
64
|
* // or set ratio number
|
|
52
|
-
* ratio: 0.5
|
|
65
|
+
* ratio: 0.5,
|
|
66
|
+
*
|
|
67
|
+
* // set image to be displayed next to the label text
|
|
68
|
+
* image: {
|
|
69
|
+
* url: "./sample.svg",
|
|
70
|
+
*
|
|
71
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
72
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
73
|
+
* width: 35,
|
|
74
|
+
* height: 35,
|
|
75
|
+
* pos: {
|
|
76
|
+
* x: 0,
|
|
77
|
+
* y: 0
|
|
78
|
+
* }
|
|
79
|
+
* },
|
|
80
|
+
*
|
|
81
|
+
* // or use function to return image configuration dynamically
|
|
82
|
+
* image: function(v, id, i) {
|
|
83
|
+
* // Return different images based on value
|
|
84
|
+
* if (v > 500) {
|
|
85
|
+
* return {
|
|
86
|
+
* url: "./high-value.svg",
|
|
87
|
+
* width: 40,
|
|
88
|
+
* height: 40,
|
|
89
|
+
* pos: { x: 0, y: 0 }
|
|
90
|
+
* };
|
|
91
|
+
* } else if (v > 100) {
|
|
92
|
+
* return {
|
|
93
|
+
* url: "./medium-value.svg",
|
|
94
|
+
* width: 30,
|
|
95
|
+
* height: 30,
|
|
96
|
+
* pos: { x: 0, y: 0 }
|
|
97
|
+
* };
|
|
98
|
+
* } else if(v < 5) {
|
|
99
|
+
* // Return falsy value in case of don't want to show image
|
|
100
|
+
* return null;
|
|
101
|
+
* } else {
|
|
102
|
+
* return {
|
|
103
|
+
* url: "./low-value.svg",
|
|
104
|
+
* width: 20,
|
|
105
|
+
* height: 20,
|
|
106
|
+
* pos: { x: 0, y: 0 }
|
|
107
|
+
* };
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
53
110
|
* },
|
|
54
111
|
*
|
|
55
112
|
* // disable expand transition for interaction
|
|
@@ -88,6 +145,16 @@ export default {
|
|
|
88
145
|
pie_label_format: <(() => number | string) | undefined>undefined,
|
|
89
146
|
pie_label_ratio: <(() => number) | undefined>undefined,
|
|
90
147
|
pie_label_threshold: 0.05,
|
|
148
|
+
pie_label_image: <
|
|
149
|
+
| {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
|
|
150
|
+
| ((v: number, id: string, i: number) => {
|
|
151
|
+
url: string,
|
|
152
|
+
width: number,
|
|
153
|
+
height: number,
|
|
154
|
+
pos?: {x?: number, y?: number}
|
|
155
|
+
} | null)
|
|
156
|
+
| undefined
|
|
157
|
+
>undefined,
|
|
91
158
|
pie_expand: <boolean | {rate?: number, duration?: number}>{},
|
|
92
159
|
pie_expand_rate: 0.98,
|
|
93
160
|
pie_expand_duration: 50,
|
|
@@ -16,6 +16,18 @@ export default {
|
|
|
16
16
|
* @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
|
|
17
17
|
* @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
18
18
|
* @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
|
|
19
|
+
* @property {object|Function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
|
|
20
|
+
* When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
|
|
21
|
+
* The arguments are:<br>
|
|
22
|
+
* - `v` is the value of the data point where the label is shown.
|
|
23
|
+
* - `id` is the id of the data where the label is shown.
|
|
24
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
25
|
+
* @property {string} polar.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
26
|
+
* @property {number} polar.label.image.width Image width in pixels.
|
|
27
|
+
* @property {number} polar.label.image.height Image height in pixels.
|
|
28
|
+
* @property {object} [polar.label.image.pos] Image position relative to the label text.
|
|
29
|
+
* @property {number} [polar.label.image.pos.x=0] x coordinate position, relative the original.
|
|
30
|
+
* @property {number} [polar.label.image.pos.y=0] y coordinate position, relative the original.
|
|
19
31
|
* @property {number} [polar.level.depth=3] Set the level depth.
|
|
20
32
|
* @property {boolean} [polar.level.show=true] Show or hide level.
|
|
21
33
|
* @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
|
|
@@ -25,6 +37,7 @@ export default {
|
|
|
25
37
|
* @property {number} [polar.padding=0] Sets the gap between pie arcs.
|
|
26
38
|
* @property {number} [polar.startingAngle=0] Set starting angle where data draws.
|
|
27
39
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
|
|
40
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelImage)
|
|
28
41
|
* @example
|
|
29
42
|
* polar: {
|
|
30
43
|
* label: {
|
|
@@ -46,7 +59,51 @@ export default {
|
|
|
46
59
|
* return ratio;
|
|
47
60
|
* },
|
|
48
61
|
* // or set ratio number
|
|
49
|
-
* ratio: 0.5
|
|
62
|
+
* ratio: 0.5,
|
|
63
|
+
*
|
|
64
|
+
* // set image to be displayed next to the label text
|
|
65
|
+
* image: {
|
|
66
|
+
* url: "./sample.svg",
|
|
67
|
+
*
|
|
68
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
69
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
70
|
+
* width: 35,
|
|
71
|
+
* height: 35,
|
|
72
|
+
* pos: {
|
|
73
|
+
* x: 0,
|
|
74
|
+
* y: 0
|
|
75
|
+
* }
|
|
76
|
+
* },
|
|
77
|
+
*
|
|
78
|
+
* // or use function to return image configuration dynamically
|
|
79
|
+
* image: function(v, id, i) {
|
|
80
|
+
* // Return different images based on value
|
|
81
|
+
* if (v > 500) {
|
|
82
|
+
* return {
|
|
83
|
+
* url: "./high-value.svg",
|
|
84
|
+
* width: 40,
|
|
85
|
+
* height: 40,
|
|
86
|
+
* pos: { x: 0, y: 0 }
|
|
87
|
+
* };
|
|
88
|
+
* } else if (v > 100) {
|
|
89
|
+
* return {
|
|
90
|
+
* url: "./medium-value.svg",
|
|
91
|
+
* width: 30,
|
|
92
|
+
* height: 30,
|
|
93
|
+
* pos: { x: 0, y: 0 }
|
|
94
|
+
* };
|
|
95
|
+
* } else if(v < 5) {
|
|
96
|
+
* // Return falsy value in case of don't want to show image
|
|
97
|
+
* return null;
|
|
98
|
+
* } else {
|
|
99
|
+
* return {
|
|
100
|
+
* url: "./low-value.svg",
|
|
101
|
+
* width: 20,
|
|
102
|
+
* height: 20,
|
|
103
|
+
* pos: { x: 0, y: 0 }
|
|
104
|
+
* };
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
50
107
|
* },
|
|
51
108
|
* level: {
|
|
52
109
|
* depth: 3,
|
|
@@ -68,6 +125,16 @@ export default {
|
|
|
68
125
|
polar_label_show: true,
|
|
69
126
|
polar_label_format: <(() => number | string) | undefined>undefined,
|
|
70
127
|
polar_label_threshold: 0.05,
|
|
128
|
+
polar_label_image: <
|
|
129
|
+
| {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
|
|
130
|
+
| ((v: number, id: string, i: number) => {
|
|
131
|
+
url: string,
|
|
132
|
+
width: number,
|
|
133
|
+
height: number,
|
|
134
|
+
pos?: {x?: number, y?: number}
|
|
135
|
+
} | null)
|
|
136
|
+
| undefined
|
|
137
|
+
>undefined,
|
|
71
138
|
polar_label_ratio: <(() => number) | undefined>undefined,
|
|
72
139
|
polar_level_depth: 3,
|
|
73
140
|
polar_level_max: <number | undefined>undefined,
|