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.
Files changed (55) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +524 -160
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +1660 -1227
  6. package/dist/billboard.pkgd.min.js +4 -2
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +35 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +35 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +35 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +35 -3
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +875 -880
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +908 -881
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +908 -881
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +908 -881
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +908 -881
  22. package/dist/theme/datalab.css +1 -1
  23. package/dist/theme/datalab.min.css +1 -1
  24. package/dist/theme/graph.css +1 -1
  25. package/dist/theme/graph.min.css +1 -1
  26. package/dist/theme/insight.css +1 -1
  27. package/dist/theme/insight.min.css +1 -1
  28. package/dist-esm/billboard.js +369 -101
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  34. package/package.json +40 -35
  35. package/src/Chart/api/chart.ts +13 -4
  36. package/src/Chart/api/export.ts +159 -14
  37. package/src/ChartInternal/Axis/Axis.ts +1 -1
  38. package/src/ChartInternal/data/IData.ts +1 -0
  39. package/src/ChartInternal/data/data.ts +21 -2
  40. package/src/ChartInternal/internals/domain.ts +11 -4
  41. package/src/ChartInternal/internals/format.ts +1 -1
  42. package/src/ChartInternal/internals/grid.ts +1 -1
  43. package/src/ChartInternal/shape/arc.ts +145 -68
  44. package/src/ChartInternal/shape/area.ts +3 -0
  45. package/src/ChartInternal/shape/bar.ts +3 -0
  46. package/src/ChartInternal/shape/line.ts +12 -15
  47. package/src/config/Options/common/tooltip.ts +11 -8
  48. package/src/config/Options/shape/arc.ts +47 -0
  49. package/src/config/Options/shape/gauge.ts +2 -2
  50. package/src/config/resolver/shape.ts +13 -4
  51. package/src/module/util.ts +1 -1
  52. package/types/chart.d.ts +7 -0
  53. package/types/options.d.ts +39 -624
  54. package/types/options.shape.d.ts +633 -0
  55. package/types/types.d.ts +2 -2
@@ -3,12 +3,27 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {Axis} from "./axis";
6
- import {ChartTypes, d3Selection, DataItem, GaugeTypes, PrimitiveArray} from "./types";
6
+ import {ChartTypes, d3Selection, DataItem, PrimitiveArray} from "./types";
7
7
  import Bubblecompare from "./plugin/bubblecompare/index";
8
8
  import Stanford from "./plugin/stanford/index";
9
9
  import TextOverlap from "./plugin/textoverlap/index";
10
10
  import {Chart} from "./chart";
11
11
  import {IArcData, IData, IDataRow} from "../src/ChartInternal/data/IData";
12
+ import {
13
+ ArcOptions,
14
+ AreaOptions,
15
+ BarOptions,
16
+ BubbleOptions,
17
+ CandlestickOptions,
18
+ DonutOptions,
19
+ GaugeOptions,
20
+ LineOptions,
21
+ PieOptions,
22
+ PolarOptions,
23
+ RadarOptions,
24
+ ScatterOptions,
25
+ SplineOptions
26
+ } from "./options.shape";
12
27
 
13
28
  export interface ChartOptions {
14
29
  /**
@@ -242,600 +257,19 @@ export interface ChartOptions {
242
257
 
243
258
  point?: PointOptions;
244
259
 
245
- line?: {
246
- /**
247
- * Set if null data point will be connected or not.
248
- * If true set, the region of null data will be connected without any data point.
249
- * If false set, the region of null data will not be connected and get empty.
250
- */
251
- connectNull?: boolean;
252
-
253
- /**
254
- * Change step type for step chart.
255
- * 'step', 'step-before' and 'step-after' can be used.
256
- */
257
- step?: {
258
- type?: "step" | "step-before" | "step-after";
259
- };
260
-
261
- /**
262
- * Set if min or max value will be 0 on line chart.
263
- */
264
- zerobased?: boolean;
265
-
266
- /**
267
- * If set, used to set a css class on each line.
268
- */
269
- classes?: string[];
270
-
271
- /**
272
- * Set to false to not draw points on linecharts. Or pass an array of line ids to draw points for.
273
- */
274
- point?: boolean | string[];
275
- };
276
-
277
- scatter?: {
278
- /**
279
- * Set if min or max value will be 0 on scatter chart.
280
- */
281
- zerobased?: boolean;
282
- };
283
-
284
- area?: {
285
- /**
286
- * Set background area above the data chart line.
287
- */
288
- above?: boolean;
289
-
290
- /**
291
- * Set background area `below` the data chart line.
292
- * - **NOTE**: Can't be used along with `above` option. When above & below options are set to true, `above` will be prioritized.
293
- */
294
- below?: boolean;
295
-
296
- /**
297
- * Set area node to be positioned over line node.
298
- */
299
- front?: boolean;
300
-
301
- /**
302
- * Set the linear gradient on area.<br><br>
303
- * Or customize by giving below object value:
304
- * - x {Array}: `x1`, `x2` value
305
- * - y {Array}: `y1`, `y2` value
306
- * - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
307
- */
308
- linearGradient?: boolean | LinearGradientOptions;
309
-
310
- /**
311
- * Set if min or max value will be 0 on area chart.
312
- */
313
- zerobased?: boolean;
314
- };
315
-
316
- bar?: {
317
- /**
318
- * Set threshold ratio to show/hide labels.
319
- */
320
- label?: {
321
- threshold?: number;
322
- }
323
-
324
- /**
325
- * Remove nullish data on bar indices positions.
326
- */
327
- indices?: {
328
- removeNull?: boolean;
329
- }
330
-
331
- /**
332
- * Set the linear gradient on bar.<br><br>
333
- * Or customize by giving below object value:
334
- * - x {Array}: `x1`, `x2` value
335
- * - y {Array}: `y1`, `y2` value
336
- * - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
337
- */
338
- linearGradient?: boolean | LinearGradientOptions;
339
-
340
- /**
341
- * Bars will be rendered at same position, which will be overlapped each other. (for non-grouped bars only)
342
- */
343
- orverlap?: boolean;
344
-
345
- /**
346
- * The padding pixel value between each bar.
347
- */
348
- padding?: number;
349
-
350
- /**
351
- * Set the radius of bar edge in pixel.
352
- * - NOTE: Only for non-stacking bars.
353
- */
354
- radius?: number | {
355
- /**
356
- * Set the radius ratio of bar edge in relative the bar's width.
357
- */
358
- ratio?: number;
359
- };
360
-
361
- /**
362
- * The senstivity offset value for interaction boundary.
363
- */
364
- sensitivity?: number;
365
-
366
- /**
367
- * Change the width of bar chart. If ratio is specified, change the width of bar chart by ratio.
368
- */
369
- width?: number | {
370
- /**
371
- * Set the width of each bar by ratio
372
- */
373
- ratio: number;
374
-
375
- /**
376
- * Set max width of each bar
377
- */
378
- max?: number;
379
- } | {
380
- /**
381
- * Set the width option for specific dataset
382
- */
383
- [key: string]: number | {
384
- ratio: number;
385
- max: number;
386
- }
387
- };
388
-
389
- /**
390
- * Set if min or max value will be 0 on bar chart.
391
- */
392
- zerobased?: boolean;
393
- };
394
-
395
- bubble?: {
396
- /**
397
- * Set the max bubble radius value
398
- */
399
- maxR?: ((this: Chart, d: {}) => number) | number;
400
-
401
- /**
402
- * Set if min or max value will be 0 on bubble chart.
403
- */
404
- zerobased?: boolean;
405
- };
406
-
407
- candlestick?: {
408
- /**
409
- * Change the width of bar chart. If ratio is specified, change the width of bar chart by ratio.
410
- */
411
- width?: number | {
412
- /**
413
- * Set the width of each bar by ratio
414
- */
415
- ratio: number;
416
-
417
- /**
418
- * Set max width of each bar
419
- */
420
- max?: number;
421
- } | {
422
- /**
423
- * Set the width option for specific dataset
424
- */
425
- [key: string]: number | {
426
- ratio: number;
427
- max: number;
428
- }
429
- };
430
-
431
- color?: {
432
- /**
433
- * Change down value color.
434
- */
435
- down: string | {
436
- /**
437
- * Change down value color for indicated dataset only.
438
- */
439
- [key: string]: string;
440
- }
441
- }
442
- };
443
-
444
- radar?: {
445
- axis?: {
446
- /**
447
- * The max value of axis. If not given, it'll take the max value from the given data.
448
- */
449
- max?: number;
450
-
451
- line?: {
452
- /**
453
- * Show or hide axis line.
454
- */
455
- show?: boolean;
456
- };
457
-
458
- text?: {
459
- position?: {
460
- /**
461
- * x coordinate position, relative the original
462
- */
463
- x?: number;
464
-
465
- /**
466
- * y coordinate position, relative the original
467
- */
468
- y?: number;
469
- };
470
-
471
- /**
472
- * Show or hide axis text.
473
- */
474
- show?: boolean;
475
- };
476
- };
477
-
478
- direction?: {
479
- /**
480
- * Set the direction to be drawn.
481
- */
482
- clockwise?: boolean;
483
- };
484
-
485
- level?: {
486
- /**
487
- * Set the level depth.
488
- */
489
- depth?: number;
490
-
491
- /**
492
- * Show or hide level.
493
- */
494
- show?: boolean;
495
-
496
- text?: {
497
- /**
498
- * Set format function for the level value.
499
- */
500
- format?: (this: Chart, x: string) => string;
501
-
502
- /**
503
- * Show or hide level text.
504
- */
505
- show?: boolean;
506
- };
507
- }
508
-
509
- size?: {
510
- /**
511
- * Set size ratio.
512
- */
513
- ratio?: number;
514
- }
515
- };
516
-
517
- polar?: {
518
- label?: {
519
- /**
520
- * Show or hide label on each polar piece.
521
- */
522
- show?: boolean;
523
-
524
- /**
525
- * Set threshold ratio to show/hide labels.
526
- */
527
- threshold?: number;
528
-
529
- /**
530
- * Set formatter for the label on each polar piece.
531
- */
532
- format?(this: Chart, value: number, ratio: number, id: string): string;
533
-
534
- /**
535
- * Set ratio of labels position.
536
- */
537
- ratio?: ((this: Chart, d: DataItem, radius: number, h: number) => void) | number
538
- };
539
- level?: {
540
- /**
541
- * Set the level depth.
542
- */
543
- depth?: number;
544
-
545
- /**
546
- * Set level max value.
547
- */
548
- max?: number;
549
-
550
- /**
551
- * Show or hide level.
552
- */
553
- show?: boolean;
554
-
555
- text?: {
556
- /**
557
- * Set label text's background color.
558
- */
559
- backgroundColor?: string;
560
-
561
- /**
562
- * Set format function for the level value.
563
- */
564
- format?: (this: Chart, x: string) => string;
565
-
566
- /**
567
- * Show or hide level text.
568
- */
569
- show?: boolean;
570
- }
571
- };
572
-
573
- /**
574
- * Set padding between data.
575
- */
576
- padAngle?: number;
577
-
578
- /**
579
- * Sets the gap between pie arcs.
580
- */
581
- padding?: number;
582
-
583
- /**
584
- * Set starting angle where data draws.
585
- */
586
- startAngle?: number;
587
- };
588
-
589
- pie?: {
590
- label?: {
591
- /**
592
- * Show or hide label on each pie piece.
593
- */
594
- show?: boolean;
595
-
596
- /**
597
- * Set threshold ratio to show/hide labels.
598
- */
599
- threshold?: number;
600
-
601
- /**
602
- * Set formatter for the label on each pie piece.
603
- */
604
- format?(this: Chart, value: number, ratio: number, id: string): string;
605
-
606
- /**
607
- * Set ratio of labels position.
608
- */
609
- ratio?: ((this: Chart, d: DataItem, radius: number, h: number) => void) | number
610
- };
611
-
612
- /**
613
- * Enable or disable expanding pie pieces.
614
- */
615
- expand?: boolean | {
616
- /**
617
- * Set expand transition time in ms.
618
- */
619
- duration?: number;
620
-
621
- /**
622
- * Set expand rate.
623
- */
624
- rate?: number;
625
- };
626
-
627
- /**
628
- * Sets the inner radius of pie arc.
629
- */
630
- innerRadius?: number | {
631
- [key: string]: number
632
- };
633
-
634
- /**
635
- * Sets the outer radius of pie arc.
636
- */
637
- outerRadius?: number | {
638
- [key: string]: number
639
- };
640
-
641
- /**
642
- * Set padding between data.
643
- */
644
- padAngle?: number;
645
-
646
- /**
647
- * Sets the gap between pie arcs.
648
- */
649
- padding?: number;
650
-
651
- /**
652
- * Set starting angle where data draws.
653
- */
654
- startingAngle?: number;
655
- };
656
-
657
- donut?: {
658
- label?: {
659
- /**
660
- * Show or hide label on each donut piece.
661
- */
662
- show?: boolean;
663
-
664
- /**
665
- * Set formatter for the label on each donut piece.
666
- */
667
- format?: (this: Chart, value: number, ratio: number, id: string) => string;
668
-
669
- /**
670
- * Set ratio of labels position.
671
- */
672
- ratio?: number | ((this: Chart, d: DataItem, radius: number, h: number) => number)
673
-
674
- /**
675
- * Set threshold ratio to show/hide labels.
676
- */
677
- threshold?: number;
678
- };
679
-
680
- /**
681
- * Enable or disable expanding donut pieces.
682
- */
683
- expand?: boolean | {
684
- /**
685
- * Set expand transition time in ms.
686
- */
687
- duration?: number;
688
-
689
- /**
690
- * Set expand rate.
691
- */
692
- rate?: number;
693
- };
694
-
695
- /**
696
- * Set padding between data.
697
- */
698
- padAngle?: number;
699
-
700
- /**
701
- * Set starting angle where data draws.
702
- */
703
- startingAngle?: number;
704
-
705
- /**
706
- * Set width of donut chart.
707
- */
708
- width?: number;
709
-
710
- /**
711
- * Set title of donut chart.
712
- */
713
- title?: string;
714
- };
715
-
716
- gauge?: {
717
- /**
718
- * Set background color. (The `.bb-chart-arcs-background` element)
719
- */
720
- background?: string;
721
-
722
- /**
723
- * Whether this should be displayed
724
- * as a full circle instead of a
725
- * half circle.
726
- */
727
- fullCircle?: boolean;
728
-
729
- label?: {
730
- /**
731
- * Show or hide label on gauge.
732
- */
733
- show?: boolean;
734
-
735
- /**
736
- * Set formatter for the label on gauge.
737
- */
738
- format?(this: Chart, value: any, ratio: number): string;
739
-
740
- /**
741
- * Set customized min/max label text.
742
- */
743
- extents?(this: Chart, value: number, isMax: boolean): string | number;
744
-
745
- /**
746
- * Set threshold ratio to show/hide labels.
747
- */
748
- threshold?: number;
749
- };
750
-
751
- /**
752
- * Enable or disable expanding gauge pieces.
753
- */
754
- expand?: boolean | {
755
- /**
756
- * Set expand transition time in ms.
757
- */
758
- duration?: number;
759
-
760
- /**
761
- * Set expand rate.
762
- */
763
- rate?: number;
764
- };
765
-
766
- /**
767
- * Set type of the gauge.
768
- */
769
- type?: GaugeTypes;
770
-
771
- /**
772
- * Set min value of the gauge.
773
- */
774
- min?: number;
775
-
776
- /**
777
- * Set max value of the gauge.
778
- */
779
- max?: number;
780
-
781
- /**
782
- * Set starting angle where data draws.
783
- */
784
- startingAngle?: number;
785
-
786
- /**
787
- * Set title of gauge chart. Use `\n` character to enter line break.
788
- */
789
- title?: string;
790
-
791
- /**
792
- * Set units of the gauge.
793
- */
794
- units?: string;
795
-
796
- /**
797
- * Set width of gauge chart.
798
- */
799
- width?: number;
800
-
801
- /**
802
- * Set minimal width of gauge arcs until the innerRadius disappears.
803
- */
804
- arcs?: {
805
- minWidth?: number;
806
- };
807
-
808
- /**
809
- * Set the length of the arc to be drawn in percent from -100 to 100.
810
- * Negative value will draw the arc **counterclockwise**.
811
- */
812
- arcLength?: number;
813
- };
814
-
815
- spline?: {
816
- interpolation?: {
817
- /**
818
- * Set custom spline interpolation
819
- */
820
- type?: "basis"
821
- | "basis-open"
822
- | "bundle"
823
- | "cardinal"
824
- | "cardinal-closed"
825
- | "cardinal-open"
826
- | "catmull-rom"
827
- | "catmull-rom-closed"
828
- | "catmull-rom-open"
829
- | "monotone-x"
830
- | "monotone-y"
831
- | "natural"
832
- | "linear-closed"
833
- | "linear"
834
- | "step"
835
- | "step-after"
836
- | "step-before"
837
- };
838
- };
260
+ arc?: ArcOptions;
261
+ area?: AreaOptions;
262
+ bar?: BarOptions;
263
+ bubble?: BubbleOptions;
264
+ candlestick?: CandlestickOptions;
265
+ donut?: DonutOptions;
266
+ gauge?: GaugeOptions;
267
+ line?: LineOptions;
268
+ polar?: PolarOptions;
269
+ pie?: PieOptions;
270
+ radar?: RadarOptions;
271
+ scatter?: ScatterOptions;
272
+ spline?: SplineOptions;
839
273
 
840
274
  /**
841
275
  * Set a callback to execute when the chart is initialized.
@@ -946,27 +380,6 @@ export interface ChartOptions {
946
380
  };
947
381
  }
948
382
 
949
- export interface LinearGradientOptions {
950
- /**
951
- * x1, x2 attributes
952
- */
953
- x?: [number, number];
954
-
955
- /**
956
- * y1, y2 attributes
957
- */
958
- y?: [number, number];
959
-
960
- /**
961
- * The ramp of colors to use on a gradient
962
- *
963
- * offset, stop-color, stop-opacity
964
- * - setting 'null' for stop-color, will set its original data color
965
- * - setting 'function' for stop-color, will pass data id as argument. It should return color string or null value
966
- */
967
- stops?: Array<[number, string | null | ((this: Chart, id: string) => string), number]>;
968
- }
969
-
970
383
  export interface RegionOptions {
971
384
  axis?: string;
972
385
  start?: string | number | Date;
@@ -1108,12 +521,14 @@ export interface TooltipOptions {
1108
521
  name?(this: Chart, name: string, ratio: number, id: string, index: number): string;
1109
522
 
1110
523
  /**
1111
- * Set format for the value of each data in tooltip.
1112
- * Specified function receives name, ratio, id and index of the data point to show.
1113
- * ratio will be undefined if the chart is not donut/pie/gauge.
1114
- * If undefined returned, the row of that value will be skipped.
524
+ * Set format for the value of each data in tooltip. If undefined returned, the row of that value will be skipped to be called.
525
+ * - Will pass following arguments to the given function:
526
+ * - `value {string}`: Value of the data point
527
+ * - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
528
+ * - `id {string}`: id of the data point
529
+ * - `index {number}`: Index of the data point
1115
530
  */
1116
- value?(this: Chart, value: any, ratio: number, id: string, index: number): string;
531
+ value?(this: Chart, value: number, ratio: number | undefined, id: string, index: number): string;
1117
532
  };
1118
533
  /**
1119
534
  * Set tooltip values order
@@ -1472,7 +887,7 @@ export interface Grid {
1472
887
  * If x axis is category axis, value can be category name.
1473
888
  * If x axis is timeseries axis, value can be date string, Date object and unixtime integer.
1474
889
  */
1475
- lines?: LineOptions[];
890
+ lines?: GridLineOptions[];
1476
891
  };
1477
892
 
1478
893
  y?: {
@@ -1485,7 +900,7 @@ export interface Grid {
1485
900
  * Show additional grid lines along y axis.
1486
901
  * This option accepts array including object that has value, text, position and class.
1487
902
  */
1488
- lines?: LineOptions[];
903
+ lines?: GridLineOptions[];
1489
904
 
1490
905
  /**
1491
906
  * Number of y grids to be shown.
@@ -1494,7 +909,7 @@ export interface Grid {
1494
909
  };
1495
910
  }
1496
911
 
1497
- export interface LineOptions {
912
+ export interface GridLineOptions {
1498
913
  value: string | number | Date;
1499
914
  text?: string;
1500
915
  axis?: string;