billboard.js 3.8.2 → 3.9.0-next.2

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 (63) hide show
  1. package/dist/billboard.css +7 -7
  2. package/dist/billboard.js +386 -71
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +868 -361
  6. package/dist/billboard.pkgd.min.js +2 -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 +4 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +4 -4
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +484 -292
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +487 -294
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +488 -295
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +489 -297
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +501 -320
  22. package/dist/theme/dark.css +298 -0
  23. package/dist/theme/dark.min.css +9 -0
  24. package/dist/theme/datalab.css +9 -2
  25. package/dist/theme/datalab.min.css +2 -2
  26. package/dist/theme/graph.css +7 -5
  27. package/dist/theme/graph.min.css +2 -2
  28. package/dist/theme/insight.css +7 -5
  29. package/dist/theme/insight.min.css +2 -2
  30. package/dist-esm/billboard.js +367 -59
  31. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  32. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -3
  33. package/dist-esm/plugin/billboardjs-plugin-stanford.js +4 -3
  34. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  35. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  36. package/package.json +35 -34
  37. package/src/Chart/Chart.ts +30 -1
  38. package/src/ChartInternal/ChartInternal.ts +12 -4
  39. package/src/ChartInternal/data/IData.ts +5 -0
  40. package/src/ChartInternal/data/data.ts +23 -9
  41. package/src/ChartInternal/internals/size.ts +5 -1
  42. package/src/ChartInternal/internals/text.ts +20 -15
  43. package/src/ChartInternal/internals/tooltip.ts +4 -3
  44. package/src/ChartInternal/shape/arc.ts +161 -18
  45. package/src/ChartInternal/shape/bar.ts +7 -3
  46. package/src/ChartInternal/shape/bubble.ts +0 -1
  47. package/src/ChartInternal/shape/point.ts +2 -0
  48. package/src/config/Options/common/legend.ts +1 -1
  49. package/src/config/Options/common/point.ts +30 -2
  50. package/src/config/Options/data/data.ts +22 -6
  51. package/src/config/Options/shape/arc.ts +73 -1
  52. package/src/config/Options/shape/bar.ts +7 -1
  53. package/src/config/Options/shape/donut.ts +5 -0
  54. package/src/config/Options/shape/gauge.ts +6 -0
  55. package/src/config/Store/State.ts +2 -1
  56. package/src/config/classes.ts +2 -1
  57. package/src/scss/billboard.scss +8 -5
  58. package/src/scss/theme/dark.scss +423 -0
  59. package/src/scss/theme/datalab.scss +11 -0
  60. package/src/scss/theme/graph.scss +9 -4
  61. package/src/scss/theme/insight.scss +9 -4
  62. package/types/options.d.ts +36 -14
  63. package/types/options.shape.d.ts +81 -4
@@ -10,7 +10,7 @@ import {
10
10
  import {interpolate as d3Interpolate} from "d3-interpolate";
11
11
  import {document} from "../../module/browser";
12
12
  import {$ARC, $COMMON, $FOCUS, $GAUGE} from "../../config/classes";
13
- import {callFn, endall, isFunction, isNumber, isObject, isUndefined, setTextValue} from "../../module/util";
13
+ import {callFn, endall, isDefined, isFunction, isNumber, isObject, isUndefined, setTextValue, tplProcess} from "../../module/util";
14
14
  import type {d3Selection} from "../../../types/types";
15
15
  import type {IArcData, IArcDataRow, IData} from "../data/IData";
16
16
 
@@ -226,7 +226,7 @@ export default {
226
226
  return len * Math.PI;
227
227
  },
228
228
 
229
- getStartAngle(): number {
229
+ getGaugeStartAngle(): number {
230
230
  const $$ = this;
231
231
  const {config} = $$;
232
232
  const isFullCircle = config.gauge_fullCircle;
@@ -248,7 +248,7 @@ export default {
248
248
  updateAngle(dValue) {
249
249
  const $$ = this;
250
250
  const {config, state} = $$;
251
- let pie = $$.pie;
251
+ let {pie} = $$;
252
252
  let d = dValue;
253
253
  let found = false;
254
254
 
@@ -256,7 +256,7 @@ export default {
256
256
  return null;
257
257
  }
258
258
 
259
- const gStart = $$.getStartAngle();
259
+ const gStart = $$.getGaugeStartAngle();
260
260
  const radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
261
261
 
262
262
  if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
@@ -274,7 +274,7 @@ export default {
274
274
 
275
275
  pie($$.filterTargetsToShow())
276
276
  .forEach((t, i) => {
277
- if (!found && t.data.id === d.data.id) {
277
+ if (!found && t.data.id === d.data?.id) {
278
278
  found = true;
279
279
  d = t;
280
280
  d.index = i;
@@ -570,13 +570,6 @@ export default {
570
570
  return isFunction(format) ? format.bind($$.api) : format;
571
571
  },
572
572
 
573
- getArcTitle(): string {
574
- const $$ = this;
575
- const type = ($$.hasType("donut") && "donut") || ($$.hasType("gauge") && "gauge");
576
-
577
- return type ? $$.config[`${type}_title`] : "";
578
- },
579
-
580
573
  updateTargetsForArc(targets: IData): void {
581
574
  const $$ = this;
582
575
  const {$el} = $$;
@@ -624,17 +617,23 @@ export default {
624
617
 
625
618
  /**
626
619
  * Set arc title text
620
+ * @param {string} str Title text
627
621
  * @private
628
622
  */
629
- setArcTitle() {
623
+ setArcTitle(str?: string) {
630
624
  const $$ = this;
631
- const title = $$.getArcTitle();
625
+ const title = str || $$.getArcTitle();
632
626
  const hasGauge = $$.hasType("gauge");
633
627
 
634
628
  if (title) {
635
- const text = $$.$el.arcs.append("text")
636
- .attr("class", hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle)
637
- .style("text-anchor", "middle");
629
+ const className = hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle;
630
+ let text = $$.$el.arcs.select(`.${className}`);
631
+
632
+ if (text.empty()) {
633
+ text = $$.$el.arcs.append("text")
634
+ .attr("class", className)
635
+ .style("text-anchor", "middle");
636
+ }
638
637
 
639
638
  hasGauge && text.attr("dy", "-0.3em");
640
639
 
@@ -642,6 +641,43 @@ export default {
642
641
  }
643
642
  },
644
643
 
644
+ /**
645
+ * Return arc title text
646
+ * @returns {string} Arc title text
647
+ * @private
648
+ */
649
+ getArcTitle(): string {
650
+ const $$ = this;
651
+ const type = ($$.hasType("donut") && "donut") || ($$.hasType("gauge") && "gauge");
652
+
653
+ return type ? $$.config[`${type}_title`] : "";
654
+ },
655
+
656
+ /**
657
+ * Get arc title text with needle value
658
+ * @returns {string|boolean} When title contains needle template string will return processed string, otherwise false
659
+ * @private
660
+ */
661
+ getArcTitleWithNeedleValue(): string | false {
662
+ const $$ = this;
663
+ const {config, state} = $$;
664
+ const title = $$.getArcTitle();
665
+
666
+ if (title && $$.config.arc_needle_show && /{=[A-Z_]+}/.test(title)) {
667
+ let value = state.current.needle;
668
+
669
+ if (!isNumber(value)) {
670
+ value = config.arc_needle_value;
671
+ }
672
+
673
+ return tplProcess(title, {
674
+ NEEDLE_VALUE: isNumber(value) ? value : 0
675
+ });
676
+ }
677
+
678
+ return false;
679
+ },
680
+
645
681
  redrawArc(duration: number, durationForExit: number, withTransform?: boolean): void {
646
682
  const $$ = this;
647
683
  const {config, state, $el: {main}} = $$;
@@ -750,9 +786,116 @@ export default {
750
786
  $$.hasType("polar") && $$.redrawPolar();
751
787
  $$.hasType("gauge") && $$.redrawBackgroundArcs();
752
788
 
789
+ config.arc_needle_show && $$.redrawNeedle();
753
790
  $$.redrawArcText(duration);
754
791
  },
755
792
 
793
+ /**
794
+ * Update needle element
795
+ * @private
796
+ */
797
+ redrawNeedle(): void {
798
+ const $$ = this;
799
+ const {$el, config, state: {hiddenTargetIds, radius}} = $$;
800
+ const length = (radius - 1) / 100 * config.arc_needle_length;
801
+ const hasDataToShow = hiddenTargetIds.length !== $$.data.targets.length;
802
+ let needle = $$.$el.arcs.select(`.${$ARC.needle}`);
803
+
804
+ // needle options
805
+ const pathFn = config.arc_needle_path;
806
+ const baseWidth = config.arc_needle_bottom_width / 2;
807
+ const topWidth = config.arc_needle_top_width / 2;
808
+ const topRx = config.arc_needle_top_rx;
809
+ const topRy = config.arc_needle_top_ry;
810
+ const bottomLen = config.arc_needle_bottom_len;
811
+ const bottomRx = config.arc_needle_bottom_rx;
812
+ const bottomRy = config.arc_needle_bottom_ry;
813
+ const needleAngle = $$.getNeedleAngle();
814
+
815
+ const updateNeedleValue = () => {
816
+ const title = $$.getArcTitleWithNeedleValue();
817
+
818
+ title && $$.setArcTitle(title);
819
+ };
820
+
821
+ updateNeedleValue();
822
+
823
+ if (needle.empty()) {
824
+ needle = $el.arcs
825
+ .append("path")
826
+ .classed($ARC.needle, true);
827
+
828
+ $el.needle = needle;
829
+
830
+ /**
831
+ * Function to be exposed as public to facilitate updating needle
832
+ * @param {number} v Value to be updated
833
+ * @param {boolean} updateConfig Weather update config's value
834
+ * @private
835
+ */
836
+ $el.needle.updateHelper = (v: number, updateConfig = false): void => {
837
+ if ($el.needle.style("display") !== "none") {
838
+ $$.$T($el.needle)
839
+ .style("transform", `rotate(${$$.getNeedleAngle(v)}deg)`)
840
+ .call(endall, () => {
841
+ updateConfig && (config.arc_needle_value = v);
842
+ updateNeedleValue();
843
+ });
844
+ }
845
+ };
846
+ }
847
+
848
+ if (hasDataToShow) {
849
+ const path = isFunction(pathFn) ?
850
+ pathFn.call($$, length) :
851
+ `M-${baseWidth} ${bottomLen} A${bottomRx} ${bottomRy} 0 0 0 ${baseWidth} ${bottomLen} L${topWidth} -${length} A${topRx} ${topRy} 0 0 0 -${topWidth} -${length} L-${baseWidth} ${bottomLen} Z`;
852
+
853
+ $$.$T(needle)
854
+ .attr("d", path)
855
+ .style("fill", config.arc_needle_color)
856
+ .style("display", null)
857
+ .style("transform", `rotate(${needleAngle}deg)`);
858
+ } else {
859
+ needle.style("display", "none");
860
+ }
861
+ },
862
+
863
+ /**
864
+ * Get needle angle value relative given value
865
+ * @param {number} v Value to be calculated angle
866
+ * @returns {number} angle value
867
+ * @private
868
+ */
869
+ getNeedleAngle(v?: number): number {
870
+ const $$ = this;
871
+ const {config, state} = $$;
872
+ const arcLength = $$.getArcLength();
873
+ const hasGauge = $$.hasType("gauge");
874
+ const total = $$.getTotalDataSum(true);
875
+ let value = isDefined(v) ? v : config.arc_needle_value;
876
+ let startingAngle = config[`${config.data_type}_startingAngle`] || 0;
877
+ let radian = 0;
878
+
879
+ if (!isNumber(value)) {
880
+ value = hasGauge && $$.data.targets.length === 1 ? total : 0;
881
+ }
882
+
883
+ state.current.needle = value;
884
+
885
+ if (hasGauge) {
886
+ startingAngle = $$.getGaugeStartAngle();
887
+
888
+ const radius = config.gauge_fullCircle ? arcLength : startingAngle * -2;
889
+ const {gauge_min: min, gauge_max: max} = config;
890
+
891
+ radian = radius * ((value - min) / (max - min));
892
+ } else {
893
+ radian = arcLength * (value / total);
894
+ }
895
+
896
+ return (startingAngle + radian) * (180 / Math.PI);
897
+ },
898
+
756
899
  redrawBackgroundArcs() {
757
900
  const $$ = this;
758
901
  const {config, state} = $$;
@@ -761,7 +904,7 @@ export default {
761
904
  const showEmptyTextLabel = $$.filterTargetsToShow($$.data.targets).length === 0 &&
762
905
  !!config.data_empty_label_text;
763
906
 
764
- const startAngle = $$.getStartAngle();
907
+ const startAngle = $$.getGaugeStartAngle();
765
908
  const endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1;
766
909
 
767
910
  let backgroundArc = $$.$el.arcs.select(
@@ -14,9 +14,13 @@ export default {
14
14
  initBar(): void {
15
15
  const {$el, config, state: {clip}} = this;
16
16
 
17
- $el.bar = $el.main.select(`.${$COMMON.chart}`)
18
- // should positioned at the beginning of the shape node to not overlap others
19
- .insert("g", ":first-child")
17
+ $el.bar = $el.main.select(`.${$COMMON.chart}`);
18
+
19
+ $el.bar = config.bar_front ?
20
+ $el.bar.append("g") :
21
+ $el.bar.insert("g", ":first-child");
22
+
23
+ $el.bar
20
24
  .attr("class", $BAR.chartBars)
21
25
  .call(this.setCssRule(false, `.${$BAR.chartBars}`, ["pointer-events:none"]));
22
26
 
@@ -17,7 +17,6 @@ export default {
17
17
  if ($$.hasType("bubble")) {
18
18
  config.point_show = true;
19
19
  config.point_type = "circle";
20
- config.point_sensitivity = 25;
21
20
  }
22
21
  },
23
22
 
@@ -320,6 +320,8 @@ export default {
320
320
  r = pointR.bind($$.api)(d);
321
321
  }
322
322
 
323
+ d.r = r;
324
+
323
325
  return r;
324
326
  },
325
327
 
@@ -39,7 +39,7 @@ export default {
39
39
  * - **step**:
40
40
  * - defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
41
41
  * @property {boolean} [legend.equally=false] Set to all items have same width size.
42
- * @property {boolean} [legend.padding=0] Set padding value
42
+ * @property {number} [legend.padding=0] Set padding value
43
43
  * @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
44
44
  * @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
45
45
  * @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
@@ -2,6 +2,8 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
+ import {IDataPoint} from "../../../ChartInternal/data/IData";
6
+
5
7
  /**
6
8
  * point config options
7
9
  */
@@ -23,7 +25,20 @@ export default {
23
25
  * - **NOTE:**
24
26
  * - `null` will make to not set inline 'opacity' css prop.
25
27
  * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
26
- * @property {number} [point.sensitivity=10] The senstivity value for interaction boundary.
28
+ * @property {number|string|Function} [point.sensitivity=10] The senstivity value for interaction boundary.
29
+ * - **Available Values:**
30
+ * - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
31
+ * - "radius": sensitivity based on point's radius
32
+ * - Function: callback for each point to determine the sensitivity<br>
33
+ * ```js
34
+ * sensitivity: function(d) {
35
+ * // ex. of argument d:
36
+ * // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
37
+ *
38
+ * // returning d.r, will make sensitivity same as point's radius value.
39
+ * return d.r;
40
+ * }
41
+ * ```
27
42
  * @property {number} [point.select.r=point.r*4] The radius size of each point on selected.
28
43
  * @property {string} [point.type="circle"] The type of point to be drawn
29
44
  * - **NOTE:**
@@ -44,6 +59,7 @@ export default {
44
59
  * (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
45
60
  * @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
46
61
  * @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
62
+ * @see [Demo: point sensitivity](https://naver.github.io/billboard.js/demo/#Point.PointSensitivity)
47
63
  * @example
48
64
  * point: {
49
65
  * show: false,
@@ -76,6 +92,18 @@ export default {
76
92
  * // having lower value, means how closer to be for interaction
77
93
  * sensitivity: 3,
78
94
  *
95
+ * // sensitivity based on point's radius
96
+ * sensitivity: "radius",
97
+ *
98
+ * // callback for each point to determine the sensitivity
99
+ * sensitivity: function(d) {
100
+ * // ex. of argument d:
101
+ * // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
102
+ *
103
+ * // returning d.r, will make sensitivity same as point's radius value.
104
+ * return d.r;
105
+ * }
106
+ *
79
107
  * // valid values are "circle" or "rectangle"
80
108
  * type: "rectangle",
81
109
  *
@@ -89,7 +117,7 @@ export default {
89
117
  */
90
118
  point_show: true,
91
119
  point_r: 2.5,
92
- point_sensitivity: 10,
120
+ point_sensitivity: <number|"radius"|((d: IDataPoint) => number)> 10,
93
121
  point_focus_expand_enabled: true,
94
122
  point_focus_expand_r: <number|undefined> undefined,
95
123
  point_focus_only: false,
@@ -2,7 +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 type {ChartTypes} from "../../../../types/types";
5
+ import type {ChartTypes, d3Selection} from "../../../../types/types";
6
6
 
7
7
  /**
8
8
  * data config options
@@ -321,7 +321,7 @@ export default {
321
321
  * @property {boolean} [data.labels=false] Show or hide labels on each data points
322
322
  * @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
323
323
  * @property {Function} [data.labels.format] Set formatter function for data labels.<br>
324
- * The formatter function receives 4 arguments such as v, id, i, j and it **must return a string**(`\n` character will be used as line break) that will be shown as the label.<br><br>
324
+ * The formatter function receives 4 arguments such as `v, id, i, texts` and it **must return a string** (`\n` character will be used as line break) that will be shown as the label.<br><br>
325
325
  * The arguments are:<br>
326
326
  * - `v` is the value of the data point where the label is shown.
327
327
  * - `id` is the id of the data where the label is shown.
@@ -330,7 +330,14 @@ export default {
330
330
  * Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
331
331
  * @property {string|object} [data.labels.backgroundColors] Set label text background colors.
332
332
  * @property {string|object|Function} [data.labels.colors] Set label text colors.
333
- * @property {object} [data.labels.position] Set each dataset position, relative the original.
333
+ * @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
334
+ * When function is specified, will receives 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
335
+ * The arguments are:<br>
336
+ * - `type` coordinate type string, which will be 'x' or 'y'.
337
+ * - `v` is the value of the data point where the label is shown.
338
+ * - `id` is the id of the data where the label is shown.
339
+ * - `i` is the index of the data series point where the label is shown.
340
+ * - `texts` is the array of whole corresponding data series' text labels.<br><br>
334
341
  * @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
335
342
  * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
336
343
  * @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
@@ -351,7 +358,7 @@ export default {
351
358
  *
352
359
  * // or set specific options
353
360
  * labels: {
354
- * format: function(v, id, i, j) {
361
+ * format: function(v, id, i, texts) {
355
362
  * ...
356
363
  * // to multiline, return with '\n' character
357
364
  * return "Line1\nLine2";
@@ -393,6 +400,13 @@ export default {
393
400
  * return d.value > 200 ? "cyan" : color;
394
401
  * },
395
402
  *
403
+ * // return x, y coordinate position
404
+ * // apt to handle each text position manually
405
+ * position: function(type, v, id, i, texts) {
406
+ * ...
407
+ * return type == "x" ? 10 : 20;
408
+ * },
409
+ *
396
410
  * // set x, y coordinate position
397
411
  * position: {
398
412
  * x: -10,
@@ -413,9 +427,11 @@ export default {
413
427
  data_labels:
414
428
  <boolean | {
415
429
  centered?: boolean;
416
- format?: Function;
430
+ format?: (v: number, id: string, i: number, texts: d3Selection) => number;
417
431
  colors?: string|{[key: string]: string};
418
- position?: {[key: string]: number}|{[key: string]: {x?: number; y?: number;}};
432
+ position?: (type: "x" | "y", v: number, id: string, i: number, texts: d3Selection) => number |
433
+ {[key: string]: number} |
434
+ {[key: string]: {x?: number; y?: number;}};
419
435
  rotate?: number;
420
436
  }> {},
421
437
  data_labels_backgroundColors: <string|{[key: string]: string}|undefined> undefined,
@@ -16,9 +16,31 @@ export default {
16
16
  * - **NOTE:**
17
17
  * - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
18
18
  * @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
19
+ * @property {object} [arc.needle] Set needle options.
20
+ * @property {boolean} [arc.needle.show=false] Show or hide needle.
21
+ * @property {string} [arc.needle.color] Set needle filled color.
22
+ * @property {Function} [arc.needle.path] Set custom needle path function.
23
+ * - **NOTE:**
24
+ * - The path should be starting from 0,0 (which is center) to top center coordinate.
25
+ * - The function will receive, `length`{number} parameter which indicating the needle length in pixel relative to radius.
26
+ * @property {number} [arc.needle.value] Set needle value.
27
+ * - **NOTE:**
28
+ * - For single gauge chart, needle will point the data value by default, otherwise will point 0(zero).
29
+ * @property {number} [arc.needle.length=100] Set needle length in percentages relative to radius.
30
+ * @property {object} [arc.needle.top] Set needle top options.
31
+ * @property {number} [arc.needle.top.rx=0] Set needle top [rx radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
32
+ * @property {number} [arc.needle.top.ry=0] Set needle top [ry radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
33
+ * @property {number} [arc.needle.top.width=0] Set needle top width in pixel.
34
+ * @property {object} [arc.needle.bottom] Set needle bottom options.
35
+ * @property {number} [arc.needle.bottom.rx=1] Set needle bottom [rx radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
36
+ * @property {number} [arc.needle.bottom.ry=1] Set needle bottom [ry radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
37
+ * @property {number} [arc.needle.bottom.width=15] Set needle bottom width in pixel.
38
+ * @property {number} [arc.needle.bottom.len=0] Set needle bottom length in pixel. Setting this value, will make bottom larger starting from center.
19
39
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
20
40
  * @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
21
41
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
42
+ * @see [Demo: Donut needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
43
+ * @see [Demo: Gauge needle](https://naver.github.io/billboard.js/demo/##GaugeChartOptions.GaugeNeedle)
22
44
  * @example
23
45
  * arc: {
24
46
  * cornerRadius: 12,
@@ -37,11 +59,61 @@ export default {
37
59
  * // set ratio relative of outer radius
38
60
  * cornerRadius: {
39
61
  * ratio: 0.5
62
+ * },
63
+ *
64
+ * needle: {
65
+ * show: true,
66
+ * color: "red", // any valid CSS color
67
+ * path: function(length) {
68
+ * const len = length - 20;
69
+ *
70
+ * // will return upper arrow shape path
71
+ * // Note: The path should begun from '0,0' coordinate to top center.
72
+ * const path = `M 0 -${len + 20}
73
+ * L -12 -${len}
74
+ * L -5 -${len}
75
+ * L -5 0
76
+ * A 1 1 0 0 0 5 0
77
+ * L 5 -${len}
78
+ * L 12 -${len} Z`;
79
+ *
80
+ * return path;
81
+ * },
82
+ * value: 40, // will make needle to point value 40.
83
+ * length: 80, // needle length in percentages relative to radius.
84
+ *
85
+ * top: {
86
+ * // rx and ry are the two radii of the ellipse;
87
+ * // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve
88
+ * rx: 1,
89
+ * ry: 1,
90
+ * width: 5
91
+ * },
92
+ * bottom: {
93
+ * // rx and ry are the two radii of the ellipse;
94
+ * // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve
95
+ * rx: 1,
96
+ * ry: 1,
97
+ * width: 10
98
+ * len: 10
99
+ * }
40
100
  * }
41
101
  * }
42
102
  */
43
103
  arc_cornerRadius: <
44
104
  number|((id: string, value: number) => number)
45
105
  > 0,
46
- arc_cornerRadius_ratio: 0
106
+ arc_cornerRadius_ratio: 0,
107
+ arc_needle_show: false,
108
+ arc_needle_color: <string|undefined> undefined,
109
+ arc_needle_value: <number|undefined> undefined,
110
+ arc_needle_path: undefined,
111
+ arc_needle_length: 100,
112
+ arc_needle_top_rx: 0,
113
+ arc_needle_top_ry: 0,
114
+ arc_needle_top_width: 0,
115
+ arc_needle_bottom_rx: 1,
116
+ arc_needle_bottom_ry: 1,
117
+ arc_needle_bottom_width: 15,
118
+ arc_needle_bottom_len: 0
47
119
  };
@@ -12,6 +12,7 @@ export default {
12
12
  * @memberof Options
13
13
  * @type {object}
14
14
  * @property {object} bar Bar object
15
+ * @property {boolean} [bar.front=false] Set 'bar' to be positioned over(on the top) other shapes elements.
15
16
  * @property {number} [bar.indices.removeNull=false] Remove nullish data on bar indices positions.
16
17
  * @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
17
18
  * @property {boolean|object} [bar.linearGradient=false] Set the linear gradient on bar.<br><br>
@@ -34,6 +35,7 @@ export default {
34
35
  * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
35
36
  * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
36
37
  * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
38
+ * @see [Demo: bar front](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarFront)
37
39
  * @see [Demo: bar indices](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarIndices)
38
40
  * @see [Demo: bar overlap](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarOverlap)
39
41
  * @see [Demo: bar padding](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarPadding)
@@ -42,6 +44,9 @@ export default {
42
44
  * @see [Demo: bar width variant](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidthVariant)
43
45
  * @example
44
46
  * bar: {
47
+ * // make bar shape to be positioned over the other shape elements
48
+ * front: true,
49
+ *
45
50
  * // remove nullish data on bar indices postions
46
51
  * indices: {
47
52
  * removeNull: true
@@ -112,11 +117,12 @@ export default {
112
117
  * zerobased: false
113
118
  * }
114
119
  */
120
+ bar_front: false,
121
+ bar_indices_removeNull: false,
115
122
  bar_label_threshold: 0,
116
123
  bar_linearGradient: <
117
124
  boolean|{x?: number[]; y?: number[]; stops?: [number, string|Function|null, number]}
118
125
  > false,
119
- bar_indices_removeNull: false,
120
126
  bar_overlap: false,
121
127
  bar_padding: 0,
122
128
  bar_radius: <number|{ratio: number}|undefined> undefined,
@@ -21,6 +21,8 @@ export default {
21
21
  * @property {number} [donut.expand.duration=50] Set expand transition time in ms.
22
22
  * @property {number} [donut.width] Set width of donut chart.
23
23
  * @property {string} [donut.title=""] Set title of donut chart. Use `\n` character for line break.
24
+ * - **NOTE:**
25
+ * - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
24
26
  * @property {number} [donut.padAngle=0] Set padding between data.
25
27
  * @property {number} [donut.startingAngle=0] Set starting angle where data draws.
26
28
  * @example
@@ -63,6 +65,9 @@ export default {
63
65
  * startingAngle: 1,
64
66
  * title: "Donut Title"
65
67
  *
68
+ * // when 'arc.needle.show=true' is set, can show current needle value.
69
+ * title: "Needle value:\n{=NEEDLE_VALUE}",
70
+ *
66
71
  * // title with line break
67
72
  * title: "Title1\nTitle2"
68
73
  * }
@@ -46,6 +46,8 @@ export default {
46
46
  * - 'arcLength < -100' defaults to -100
47
47
  * - 'arcLength > 100' defaults to 100
48
48
  * @property {string} [gauge.title=""] Set title of gauge chart. Use `\n` character for line break.
49
+ * - **NOTE:**
50
+ * - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
49
51
  * @property {string} [gauge.units] Set units of the gauge.
50
52
  * @property {number} [gauge.width] Set width of gauge chart.
51
53
  * @property {string} [gauge.type="single"] Set type of gauge to be displayed.<br><br>
@@ -92,6 +94,10 @@ export default {
92
94
  * max: 200,
93
95
  * type: "single" // or 'multi'
94
96
  * title: "Title Text",
97
+ *
98
+ * // when 'arc.needle.show=true' is set, can show current needle value.
99
+ * title: "Needle value:\n{=NEEDLE_VALUE}",
100
+ *
95
101
  * units: "%",
96
102
  * width: 10,
97
103
  * startingAngle: -1 * Math.PI / 2,
@@ -59,6 +59,7 @@ export default class State {
59
59
 
60
60
  // current used chart type list
61
61
  types: <string[]> [],
62
+ needle: undefined, // arc needle current value
62
63
  },
63
64
 
64
65
  // legend
@@ -111,7 +112,7 @@ export default class State {
111
112
  pathGrid: ""
112
113
  },
113
114
 
114
- // status
115
+ // state
115
116
  event: null, // event object
116
117
  dragStart: null,
117
118
  dragging: false,
@@ -22,7 +22,8 @@ export const $ARC = {
22
22
  chartArc: "bb-chart-arc",
23
23
  chartArcs: "bb-chart-arcs",
24
24
  chartArcsBackground: "bb-chart-arcs-background",
25
- chartArcsTitle: "bb-chart-arcs-title"
25
+ chartArcsTitle: "bb-chart-arcs-title",
26
+ needle: "bb-needle"
26
27
  };
27
28
 
28
29
  export const $AREA = {
@@ -20,12 +20,16 @@
20
20
  .bb-legend-item-tile,
21
21
  .bb-xgrid-focus,
22
22
  .bb-ygrid-focus,
23
- .bb-ygrid,
24
- .bb-event-rect,
25
- .bb-bars path {
23
+ .bb-ygrid {
26
24
  shape-rendering: crispEdges;
27
25
  }
28
26
 
27
+ .bb-chart-arcs {
28
+ .bb-needle {
29
+ fill: #000;
30
+ }
31
+ }
32
+
29
33
  .bb-chart-arc {
30
34
  .bb-gauge-value {
31
35
  fill: #000;
@@ -186,9 +190,8 @@
186
190
  background-color:#fff;
187
191
  empty-cells:show;
188
192
  opacity: 0.9;
189
- -webkit-box-shadow: 7px 7px 12px -9px rgb(119,119,119);
190
- -moz-box-shadow: 7px 7px 12px -9px rgb(119,119,119);
191
193
  box-shadow: 7px 7px 12px -9px rgb(119,119,119);
194
+ white-space: nowrap;
192
195
 
193
196
  tr {
194
197
  border:1px solid #CCC;