billboard.js 3.2.2 → 3.3.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 (100) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +818 -468
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +4765 -3104
  6. package/dist/billboard.pkgd.min.js +4 -4
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.d.ts +7 -0
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.d.ts +7 -0
  11. package/dist/plugin/billboardjs-plugin-sparkline.js +145 -99
  12. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-stanford.d.ts +7 -0
  14. package/dist/plugin/billboardjs-plugin-stanford.js +144 -98
  15. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-tableview.d.ts +7 -0
  17. package/dist/plugin/billboardjs-plugin-tableview.js +13 -128
  18. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  19. package/dist/plugin/billboardjs-plugin-textoverlap.d.ts +7 -0
  20. package/dist/plugin/billboardjs-plugin-textoverlap.js +11 -126
  21. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  22. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +3980 -2669
  23. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +4119 -2762
  24. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +4117 -2760
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +3970 -2774
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +3969 -2773
  27. package/dist/theme/datalab.css +1 -1
  28. package/dist/theme/datalab.min.css +2 -2
  29. package/dist/theme/graph.css +1 -1
  30. package/dist/theme/graph.min.css +2 -2
  31. package/dist/theme/insight.css +1 -1
  32. package/dist/theme/insight.min.css +2 -2
  33. package/dist-esm/billboard.js +787 -464
  34. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.d.ts +7 -0
  35. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -4
  36. package/dist-esm/plugin/billboardjs-plugin-sparkline.d.ts +7 -0
  37. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +131 -79
  38. package/dist-esm/plugin/billboardjs-plugin-stanford.d.ts +7 -0
  39. package/dist-esm/plugin/billboardjs-plugin-stanford.js +135 -80
  40. package/dist-esm/plugin/billboardjs-plugin-tableview.d.ts +7 -0
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +4 -8
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.d.ts +7 -0
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +4 -7
  44. package/package.json +45 -44
  45. package/src/Chart/api/chart.ts +7 -1
  46. package/src/Chart/api/data.ts +3 -4
  47. package/src/Chart/api/focus.ts +8 -8
  48. package/src/Chart/api/regions.ts +3 -3
  49. package/src/Chart/api/selection.ts +15 -15
  50. package/src/Chart/api/subchart.ts +3 -3
  51. package/src/ChartInternal/Axis/Axis.ts +26 -19
  52. package/src/ChartInternal/ChartInternal.ts +18 -8
  53. package/src/ChartInternal/data/IData.ts +9 -0
  54. package/src/ChartInternal/data/convert.ts +1 -1
  55. package/src/ChartInternal/data/data.ts +29 -12
  56. package/src/ChartInternal/data/load.ts +2 -2
  57. package/src/ChartInternal/interactions/drag.ts +15 -15
  58. package/src/ChartInternal/interactions/eventrect.ts +18 -18
  59. package/src/ChartInternal/interactions/interaction.ts +46 -14
  60. package/src/ChartInternal/interactions/zoom.ts +4 -4
  61. package/src/ChartInternal/internals/color.ts +4 -4
  62. package/src/ChartInternal/internals/domain.ts +5 -3
  63. package/src/ChartInternal/internals/grid.ts +32 -32
  64. package/src/ChartInternal/internals/legend.ts +27 -27
  65. package/src/ChartInternal/internals/redraw.ts +3 -3
  66. package/src/ChartInternal/internals/region.ts +3 -3
  67. package/src/ChartInternal/internals/scale.ts +3 -2
  68. package/src/ChartInternal/internals/selection.ts +16 -15
  69. package/src/ChartInternal/internals/size.ts +35 -4
  70. package/src/ChartInternal/internals/text.ts +10 -10
  71. package/src/ChartInternal/internals/title.ts +4 -4
  72. package/src/ChartInternal/internals/tooltip.ts +9 -6
  73. package/src/ChartInternal/internals/transform.ts +5 -5
  74. package/src/ChartInternal/shape/arc.ts +24 -22
  75. package/src/ChartInternal/shape/area.ts +4 -4
  76. package/src/ChartInternal/shape/bar.ts +87 -40
  77. package/src/ChartInternal/shape/candlestick.ts +8 -8
  78. package/src/ChartInternal/shape/gauge.ts +8 -8
  79. package/src/ChartInternal/shape/line.ts +7 -7
  80. package/src/ChartInternal/shape/point.ts +18 -18
  81. package/src/ChartInternal/shape/radar.ts +12 -10
  82. package/src/ChartInternal/shape/shape.ts +76 -13
  83. package/src/Plugin/sparkline/index.ts +4 -4
  84. package/src/Plugin/stanford/index.ts +3 -3
  85. package/src/Plugin/stanford/util.ts +0 -1
  86. package/src/Plugin/tableview/index.ts +1 -1
  87. package/src/config/Options/axis/x.ts +27 -7
  88. package/src/config/Options/axis/y.ts +24 -3
  89. package/src/config/Options/axis/y2.ts +24 -3
  90. package/src/config/Options/common/main.ts +11 -1
  91. package/src/config/Options/data/data.ts +22 -0
  92. package/src/config/Options/shape/bar.ts +9 -2
  93. package/src/config/classes.ts +154 -66
  94. package/src/module/util.ts +17 -17
  95. package/types/axis.d.ts +22 -8
  96. package/types/chart.d.ts +1 -1
  97. package/types/options.d.ts +40 -33
  98. package/types/plugin/tableview/index.d.ts +3 -3
  99. package/types/plugin/tableview/options.d.ts +1 -1
  100. package/types/types.d.ts +4 -4
@@ -9,7 +9,7 @@ import {
9
9
  } from "d3-shape";
10
10
  import {interpolate as d3Interpolate} from "d3-interpolate";
11
11
  import {document} from "../../module/browser";
12
- import CLASS from "../../config/classes";
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 {d3Selection} from "../../../types/types";
15
15
  import {IData} from "../data/IData";
@@ -364,7 +364,7 @@ export default {
364
364
  if (!transiting) {
365
365
  clearInterval(interval);
366
366
 
367
- $el.legend.selectAll(`.${CLASS.legendItemFocused}`).size() > 0 &&
367
+ $el.legend.selectAll(`.${$FOCUS.legendItemFocused}`).size() > 0 &&
368
368
  $$.expandArc(targetIds);
369
369
  }
370
370
  }, 10);
@@ -374,7 +374,7 @@ export default {
374
374
 
375
375
  const newTargetIds = $$.mapToTargetIds(targetIds);
376
376
 
377
- $el.svg.selectAll($$.selectorTargets(newTargetIds, `.${CLASS.chartArc}`))
377
+ $el.svg.selectAll($$.selectorTargets(newTargetIds, `.${$ARC.chartArc}`))
378
378
  .each(function(d) {
379
379
  if (!$$.shouldExpand(d.data.id)) {
380
380
  return;
@@ -403,13 +403,13 @@ export default {
403
403
 
404
404
  const newTargetIds = $$.mapToTargetIds(targetIds);
405
405
 
406
- svg.selectAll($$.selectorTargets(newTargetIds, `.${CLASS.chartArc}`))
406
+ svg.selectAll($$.selectorTargets(newTargetIds, `.${$ARC.chartArc}`))
407
407
  .selectAll("path")
408
408
  .transition()
409
409
  .duration(d => $$.getExpandConfig(d.data.id, "duration"))
410
410
  .attr("d", $$.svgArc);
411
411
 
412
- svg.selectAll(`${CLASS.arc}`)
412
+ svg.selectAll(`${$ARC.arc}`)
413
413
  .style("opacity", null);
414
414
  },
415
415
 
@@ -485,10 +485,10 @@ export default {
485
485
  const classChartArc = $$.getChartClass("Arc");
486
486
  const classArcs = $$.getClass("arcs", true);
487
487
  const classFocus = $$.classFocus.bind($$);
488
- const chartArcs = $el.main.select(`.${CLASS.chartArcs}`);
488
+ const chartArcs = $el.main.select(`.${$ARC.chartArcs}`);
489
489
 
490
490
  const mainPieUpdate = chartArcs
491
- .selectAll(`.${CLASS.chartArc}`)
491
+ .selectAll(`.${$ARC.chartArc}`)
492
492
  .data($$.pie(targets))
493
493
  .attr("class", d => classChartArc(d) + classFocus(d.data));
494
494
 
@@ -505,7 +505,7 @@ export default {
505
505
  .style("text-anchor", "middle")
506
506
  .style("pointer-events", "none");
507
507
 
508
- $el.text = chartArcs.selectAll(`.${CLASS.target} text`);
508
+ $el.text = chartArcs.selectAll(`.${$COMMON.target} text`);
509
509
  // MEMO: can not keep same color..., but not bad to update color in redraw
510
510
  // mainPieUpdate.exit().remove();
511
511
  },
@@ -514,9 +514,9 @@ export default {
514
514
  const $$ = this;
515
515
  const {$el} = $$;
516
516
 
517
- $el.arcs = $el.main.select(`.${CLASS.chart}`)
517
+ $el.arcs = $el.main.select(`.${$COMMON.chart}`)
518
518
  .append("g")
519
- .attr("class", CLASS.chartArcs)
519
+ .attr("class", $ARC.chartArcs)
520
520
  .attr("transform", $$.getTranslate("arc"));
521
521
 
522
522
  $$.setArcTitle();
@@ -533,7 +533,7 @@ export default {
533
533
 
534
534
  if (title) {
535
535
  const text = $$.$el.arcs.append("text")
536
- .attr("class", CLASS[hasGauge ? "chartArcsGaugeTitle" : "chartArcsTitle"])
536
+ .attr("class", hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle)
537
537
  .style("text-anchor", "middle");
538
538
 
539
539
  hasGauge && text.attr("dy", "-0.3em");
@@ -548,8 +548,8 @@ export default {
548
548
  const hasInteraction = config.interaction_enabled;
549
549
  const isSelectable = hasInteraction && config.data_selection_isselectable;
550
550
 
551
- let mainArc = main.selectAll(`.${CLASS.arcs}`)
552
- .selectAll(`.${CLASS.arc}`)
551
+ let mainArc = main.selectAll(`.${$ARC.arcs}`)
552
+ .selectAll(`.${$ARC.arc}`)
553
553
  .data($$.arcData.bind($$));
554
554
 
555
555
  mainArc.exit()
@@ -661,19 +661,19 @@ export default {
661
661
  const endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1;
662
662
 
663
663
  let backgroundArc = $$.$el.arcs.select(
664
- `${hasMultiArcGauge ? "g" : ""}.${CLASS.chartArcsBackground}`
664
+ `${hasMultiArcGauge ? "g" : ""}.${$ARC.chartArcsBackground}`
665
665
  );
666
666
 
667
667
  if (hasMultiArcGauge) {
668
668
  let index = 0;
669
669
 
670
670
  backgroundArc = backgroundArc
671
- .selectAll(`path.${CLASS.chartArcsBackground}`)
671
+ .selectAll(`path.${$ARC.chartArcsBackground}`)
672
672
  .data($$.data.targets);
673
673
 
674
674
  backgroundArc.enter()
675
675
  .append("path")
676
- .attr("class", (d, i) => `${CLASS.chartArcsBackground} ${CLASS.chartArcsBackground}-${i}`)
676
+ .attr("class", (d, i) => `${$ARC.chartArcsBackground} ${$ARC.chartArcsBackground}-${i}`)
677
677
  .merge(backgroundArc)
678
678
  .style("fill", (config.gauge_background) || null)
679
679
  .attr("d", ({id}) => {
@@ -795,6 +795,8 @@ export default {
795
795
  return;
796
796
  }
797
797
 
798
+ state.event = event;
799
+
798
800
  const eventArc = getEventArc(event);
799
801
  const datum: any = eventArc.datum();
800
802
  const updated = (datum?.data && datum.data.id) ? $$.updateAngle(datum) : null;
@@ -818,10 +820,10 @@ export default {
818
820
 
819
821
  // for gauge type, update text when has no title & multi data
820
822
  if (!(hasGauge && $$.data.targets.length === 1 && config.gauge_title)) {
821
- text = main.selectAll(`.${CLASS.chartArc}`)
823
+ text = main.selectAll(`.${$ARC.chartArc}`)
822
824
  .select("text")
823
825
  .style("opacity", "0")
824
- .attr("class", d => ($$.isGaugeType(d.data) ? CLASS.gaugeValue : null))
826
+ .attr("class", d => ($$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null))
825
827
  .call($$.textForArcLabel.bind($$))
826
828
  .attr("transform", $$.transformForArcLabel.bind($$))
827
829
  .style("font-size", d => (
@@ -835,7 +837,7 @@ export default {
835
837
  hasMultiArcGauge && text.attr("dy", "-.1em");
836
838
  }
837
839
 
838
- main.select(`.${CLASS.chartArcsTitle}`)
840
+ main.select(`.${$ARC.chartArcsTitle}`)
839
841
  .style("opacity", $$.hasType("donut") || hasGauge ? null : "0");
840
842
 
841
843
  if (hasGauge) {
@@ -844,17 +846,17 @@ export default {
844
846
  isFullCircle && text?.attr("dy", `${hasMultiArcGauge ? 0 : Math.round(state.radius / 14)}`);
845
847
 
846
848
  if (config.gauge_label_show) {
847
- arcs.select(`.${CLASS.chartArcsGaugeUnit}`)
849
+ arcs.select(`.${$GAUGE.chartArcsGaugeUnit}`)
848
850
  .attr("dy", `${isFullCircle ? 1.5 : 0.75}em`)
849
851
  .text(config.gauge_units);
850
852
 
851
- arcs.select(`.${CLASS.chartArcsGaugeMin}`)
853
+ arcs.select(`.${$GAUGE.chartArcsGaugeMin}`)
852
854
  .attr("dx", `${-1 * (state.innerRadius + ((state.radius - state.innerRadius) / (isFullCircle ? 1 : 2)))}px`)
853
855
  .attr("dy", "1.2em")
854
856
  .text($$.textForGaugeMinMax(config.gauge_min, false));
855
857
 
856
858
  // show max text when isn't fullCircle
857
- !isFullCircle && arcs.select(`.${CLASS.chartArcsGaugeMax}`)
859
+ !isFullCircle && arcs.select(`.${$GAUGE.chartArcsGaugeMax}`)
858
860
  .attr("dx", `${state.innerRadius + ((state.radius - state.innerRadius) / 2)}px`)
859
861
  .attr("dy", "1.2em")
860
862
  .text($$.textForGaugeMinMax(config.gauge_max, true));
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import {area as d3Area} from "d3-shape";
6
6
  import {select as d3Select} from "d3-selection";
7
- import CLASS from "../../config/classes";
7
+ import {$AREA, $CIRCLE, $LINE} from "../../config/classes";
8
8
  import {getRandom, isFunction} from "../../module/util";
9
9
 
10
10
  export default {
@@ -13,7 +13,7 @@ export default {
13
13
  const {config} = $$;
14
14
 
15
15
  mainLine
16
- .insert("g", `.${CLASS[config.area_front ? "circles" : "lines"]}`)
16
+ .insert("g", `.${config.area_front ? $CIRCLE.circles : $LINE.lines}`)
17
17
  .attr("class", $$.getClass("areas", true));
18
18
  },
19
19
 
@@ -72,8 +72,8 @@ export default {
72
72
 
73
73
  config.area_linearGradient && $$.updateAreaGradient();
74
74
 
75
- const area = $root.main.selectAll(`.${CLASS.areas}`)
76
- .selectAll(`.${CLASS.area}`)
75
+ const area = $root.main.selectAll(`.${$AREA.areas}`)
76
+ .selectAll(`.${$AREA.area}`)
77
77
  .data($$.lineData.bind($$));
78
78
 
79
79
  $T(area.exit(), withTransition)
@@ -2,17 +2,21 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import CLASS from "../../config/classes";
6
- import {getPointer, getRandom, getRectSegList, isNumber} from "../../module/util";
5
+ import {DataRow} from "../../../types/types";
6
+ import {$BAR, $COMMON} from "../../config/classes";
7
+ import {getRandom, isNumber} from "../../module/util";
8
+ import {IDataRow} from "../data/IData";
9
+
10
+ type BarTypeDataRow = DataRow<number | number[]>;
7
11
 
8
12
  export default {
9
13
  initBar(): void {
10
14
  const {$el, config, state: {clip}} = this;
11
15
 
12
- $el.bar = $el.main.select(`.${CLASS.chart}`)
16
+ $el.bar = $el.main.select(`.${$COMMON.chart}`)
13
17
  // should positioned at the beginning of the shape node to not overlap others
14
18
  .insert("g", ":first-child")
15
- .attr("class", CLASS.chartBars);
19
+ .attr("class", $BAR.chartBars);
16
20
 
17
21
  // set clip-path attribute when condition meet
18
22
  // https://github.com/naver/billboard.js/issues/2421
@@ -23,7 +27,7 @@ export default {
23
27
  }
24
28
  },
25
29
 
26
- updateTargetsForBar(targets): void {
30
+ updateTargetsForBar(targets: BarTypeDataRow[]): void {
27
31
  const $$ = this;
28
32
  const {config, $el} = $$;
29
33
  const classChartBar = $$.getChartClass("Bar");
@@ -35,12 +39,12 @@ export default {
35
39
  $$.initBar();
36
40
  }
37
41
 
38
- const mainBarUpdate = $$.$el.main.select(`.${CLASS.chartBars}`)
39
- .selectAll(`.${CLASS.chartBar}`)
42
+ const mainBarUpdate = $$.$el.main.select(`.${$BAR.chartBars}`)
43
+ .selectAll(`.${$BAR.chartBar}`)
40
44
  .data(
41
45
  // remove
42
46
  targets.filter(
43
- v => !v.values.every(d => !isNumber(d.value))
47
+ v => v.values.some(d => (isNumber(d.value) || $$.isBarRangeType(d)))
44
48
  )
45
49
  )
46
50
  .attr("class", d => classChartBar(d) + classFocus(d));
@@ -69,8 +73,8 @@ export default {
69
73
  const classBar = $$.getClass("bar", true);
70
74
  const initialOpacity = $$.initialOpacity.bind($$);
71
75
 
72
- const bar = $root.main.selectAll(`.${CLASS.bars}`)
73
- .selectAll(`.${CLASS.bar}`)
76
+ const bar = $root.main.selectAll(`.${$BAR.bars}`)
77
+ .selectAll(`.${$BAR.bar}`)
74
78
  .data($$.labelishData.bind($$));
75
79
 
76
80
  $T(bar.exit(), withTransition)
@@ -86,7 +90,7 @@ export default {
86
90
 
87
91
  /**
88
92
  * Redraw function
89
- * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
93
+ * @param {Function} drawFn Retuned function from .getDrawShape() => .generateDrawBar()
90
94
  * @param {boolean} withTransition With or without transition
91
95
  * @param {boolean} isSub Subchart draw
92
96
  * @returns {Array}
@@ -97,18 +101,37 @@ export default {
97
101
 
98
102
  return [
99
103
  $$.$T(bar, withTransition, getRandom())
100
- .attr("d", d => isNumber(d.value) && drawFn(d))
104
+ .attr("d", d => (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d))
101
105
  .style("fill", this.color)
102
106
  .style("opacity", null)
103
107
  ];
104
108
  },
105
109
 
106
- generateDrawBar(barIndices, isSub?: boolean): Function {
110
+ /**
111
+ * Generate draw function
112
+ * @param {object} barIndices data order within x axis.
113
+ * barIndices ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
114
+ *
115
+ * When gropus given as:
116
+ * groups: [
117
+ * ["data1", "data2"],
118
+ * ["data3", "data4"]
119
+ * ],
120
+ *
121
+ * Will be rendered as:
122
+ * data1 data3 data1 data3
123
+ * data2 data4 data2 data4
124
+ * -------------------------
125
+ * 0 1
126
+ * @param {boolean} isSub If is for subchart
127
+ * @returns {Function}
128
+ * @private
129
+ */
130
+ generateDrawBar(barIndices, isSub?: boolean): (d: IDataRow, i: number) => string {
107
131
  const $$ = this;
108
132
  const {config} = $$;
109
133
  const getPoints = $$.generateGetBarPoints(barIndices, isSub);
110
134
  const isRotated = config.axis_rotated;
111
- const isGrouped = config.data_groups.length;
112
135
  const barRadius = config.bar_radius;
113
136
  const barRadiusRatio = config.bar_radius_ratio;
114
137
 
@@ -118,7 +141,7 @@ export default {
118
141
  isNumber(barRadiusRatio) ? w => w * barRadiusRatio : null
119
142
  );
120
143
 
121
- return (d, i) => {
144
+ return (d: IDataRow, i: number) => {
122
145
  // 4 points that make a bar
123
146
  const points = getPoints(d, i);
124
147
 
@@ -130,7 +153,11 @@ export default {
130
153
  const pathRadius = ["", ""];
131
154
  let radius = 0;
132
155
 
133
- if (d.value !== 0 && getRadius && !isGrouped) {
156
+ const isGrouped = $$.isGrouped(d.id);
157
+ const hasRadius = d.value !== 0 && getRadius;
158
+ const isRadiusData = hasRadius && isGrouped ? $$.isStackingRadiusData(d) : false;
159
+
160
+ if (hasRadius && (!isGrouped || isRadiusData)) {
134
161
  const index = isRotated ? indexY : indexX;
135
162
  const barW = points[2][index] - points[0][index];
136
163
 
@@ -154,7 +181,46 @@ export default {
154
181
  };
155
182
  },
156
183
 
157
- generateGetBarPoints(barIndices, isSub?: boolean): Function {
184
+ /**
185
+ * Determine if given stacking bar data is radius type
186
+ * @param {Object} d Data row
187
+ * @returns {boolean}
188
+ */
189
+ isStackingRadiusData(d: IDataRow): boolean {
190
+ const $$ = this;
191
+ const {config, data} = $$;
192
+ const {id, index, value} = d;
193
+
194
+ // Find same grouped ids
195
+ const keys = config.data_groups.find(v => v.indexOf(id) > -1);
196
+
197
+ // Get sorted list
198
+ const sortedList = $$.orderTargets(
199
+ $$.filterTargetsToShow(data.targets.filter($$.isBarType, $$))
200
+ ).filter(v => keys.indexOf(v.id) > -1);
201
+
202
+ // Get sorted Ids. Filter positive or negative values Ids from given value
203
+ const sortedIds = sortedList
204
+ .map(v => v.values.filter(
205
+ v2 => v2.index === index && (
206
+ value > 0 ? v2.value > 0 : v2.value < 0
207
+ ))[0]
208
+ )
209
+ .filter(Boolean)
210
+ .map(v => v.id);
211
+
212
+ // If the given id stays in the last position, then radius should be applied.
213
+ return value !== 0 && (sortedIds.indexOf(id) === sortedIds.length - 1);
214
+ },
215
+
216
+ /**
217
+ * Generate bar coordinate points data
218
+ * @param {object} barIndices Data order within x axis.
219
+ * @param {boolean} isSub If is for subchart
220
+ * @returns {Array} Array of coordinate points
221
+ * @private
222
+ */
223
+ generateGetBarPoints(barIndices, isSub?: boolean): (d: IDataRow, i: number) => [number, number][] {
158
224
  const $$ = this;
159
225
  const {config} = $$;
160
226
  const axis = isSub ? $$.axis.subX : $$.axis.x;
@@ -165,7 +231,7 @@ export default {
165
231
  const barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub);
166
232
  const yScale = $$.getYScaleById.bind($$);
167
233
 
168
- return (d, i) => {
234
+ return (d: IDataRow, i: number) => {
169
235
  const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
170
236
  const offset = barOffset(d, i) || y0; // offset is for stacked bar chart
171
237
  const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
@@ -179,7 +245,9 @@ export default {
179
245
  posY = y0;
180
246
  }
181
247
 
182
- posY -= (y0 - offset);
248
+ if (!$$.isBarRangeType(d)) {
249
+ posY -= (y0 - offset);
250
+ }
183
251
 
184
252
  const startPosX = posX + width;
185
253
 
@@ -191,26 +259,5 @@ export default {
191
259
  [startPosX, offset]
192
260
  ];
193
261
  };
194
- },
195
-
196
- isWithinBar(that): boolean {
197
- const mouse = getPointer(this.state.event, that);
198
- const list = getRectSegList(that);
199
- const [seg0, seg1] = list;
200
- const x = Math.min(seg0.x, seg1.x);
201
- const y = Math.min(seg0.y, seg1.y);
202
- const offset = this.config.bar_sensitivity;
203
- const {width, height} = that.getBBox();
204
- const sx = x - offset;
205
- const ex = x + width + offset;
206
- const sy = y + height + offset;
207
- const ey = y - offset;
208
-
209
- const isWithin = sx < mouse[0] &&
210
- mouse[0] < ex &&
211
- ey < mouse[1] &&
212
- mouse[1] < sy;
213
-
214
- return isWithin;
215
262
  }
216
263
  };
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {select as d3Select} from "d3-selection";
6
- import CLASS from "../../config/classes";
6
+ import {$CANDLESTICK, $COMMON} from "../../config/classes";
7
7
  import {getRandom, isArray, isNumber, isObject} from "../../module/util";
8
8
 
9
9
  type CandlestickData = {
@@ -18,10 +18,10 @@ export default {
18
18
  initCandlestick(): void {
19
19
  const {$el} = this;
20
20
 
21
- $el.candlestick = $el.main.select(`.${CLASS.chart}`)
21
+ $el.candlestick = $el.main.select(`.${$COMMON.chart}`)
22
22
  // should positioned at the beginning of the shape node to not overlap others
23
23
  .append("g")
24
- .attr("class", CLASS.chartCandlesticks);
24
+ .attr("class", $CANDLESTICK.chartCandlesticks);
25
25
  },
26
26
 
27
27
  /**
@@ -40,8 +40,8 @@ export default {
40
40
  $$.initCandlestick();
41
41
  }
42
42
 
43
- const mainUpdate = $$.$el.main.select(`.${CLASS.chartCandlesticks}`)
44
- .selectAll(`.${CLASS.chartCandlestick}`)
43
+ const mainUpdate = $$.$el.main.select(`.${$CANDLESTICK.chartCandlesticks}`)
44
+ .selectAll(`.${$CANDLESTICK.chartCandlestick}`)
45
45
  .data(targets)
46
46
  .attr("class", d => classChart(d) + classFocus(d));
47
47
 
@@ -63,8 +63,8 @@ export default {
63
63
  const classSetter = $$.getClass("candlestick", true);
64
64
  const initialOpacity = $$.initialOpacity.bind($$);
65
65
 
66
- const candlestick = $root.main.selectAll(`.${CLASS.chartCandlestick}`)
67
- .selectAll(`.${CLASS.candlestick}`)
66
+ const candlestick = $root.main.selectAll(`.${$CANDLESTICK.chartCandlestick}`)
67
+ .selectAll(`.${$CANDLESTICK.candlestick}`)
68
68
  .data($$.labelishData.bind($$));
69
69
 
70
70
  $T(candlestick.exit(), withTransition)
@@ -111,7 +111,7 @@ export default {
111
111
  const indexY = +!indexX;
112
112
 
113
113
  if (g.classed) {
114
- g.classed(CLASS[isUp ? "valueUp" : "valueDown"], true);
114
+ g.classed($CANDLESTICK[isUp ? "valueUp" : "valueDown"], true);
115
115
  }
116
116
 
117
117
  const path = isRotated ?
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {select as d3Select} from "d3-selection";
6
- import CLASS from "../../config/classes";
6
+ import {$ARC, $COMMON, $GAUGE} from "../../config/classes";
7
7
  import {isFunction} from "../../module/util";
8
8
 
9
9
  export default {
@@ -21,14 +21,14 @@ export default {
21
21
  const hasMulti = $$.hasMultiArcGauge();
22
22
 
23
23
  arcs.append(hasMulti ? "g" : "path")
24
- .attr("class", CLASS.chartArcsBackground)
24
+ .attr("class", $ARC.chartArcsBackground)
25
25
  .style("fill", (!hasMulti && config.gauge_background) || null);
26
26
 
27
- config.gauge_units && appendText(CLASS.chartArcsGaugeUnit);
27
+ config.gauge_units && appendText($GAUGE.chartArcsGaugeUnit);
28
28
 
29
29
  if (config.gauge_label_show) {
30
- appendText(CLASS.chartArcsGaugeMin);
31
- !config.gauge_fullCircle && appendText(CLASS.chartArcsGaugeMax);
30
+ appendText($GAUGE.chartArcsGaugeMin);
31
+ !config.gauge_fullCircle && appendText($GAUGE.chartArcsGaugeMax);
32
32
  }
33
33
  }
34
34
  },
@@ -53,13 +53,13 @@ export default {
53
53
  const {config, state, $el} = $$;
54
54
  const {hiddenTargetIds} = $$.state;
55
55
 
56
- const arcLabelLines = $el.main.selectAll(`.${CLASS.arcs}`)
57
- .selectAll(`.${CLASS.arcLabelLine}`)
56
+ const arcLabelLines = $el.main.selectAll(`.${$ARC.arcs}`)
57
+ .selectAll(`.${$ARC.arcLabelLine}`)
58
58
  .data($$.arcData.bind($$));
59
59
 
60
60
  const mainArcLabelLine = arcLabelLines.enter()
61
61
  .append("rect")
62
- .attr("class", d => `${CLASS.arcLabelLine} ${CLASS.target} ${CLASS.target}-${d.data.id}`)
62
+ .attr("class", d => `${$ARC.arcLabelLine} ${$COMMON.target} ${$COMMON.target}-${d.data.id}`)
63
63
  .merge(arcLabelLines);
64
64
 
65
65
  mainArcLabelLine
@@ -4,15 +4,15 @@
4
4
  */
5
5
  import {line as d3Line} from "d3-shape";
6
6
  import {getScale} from "../internals/scale";
7
- import CLASS from "../../config/classes";
7
+ import {$COMMON, $LINE} from "../../config/classes";
8
8
  import {getPointer, getRandom, isArray, isDefined, isUndefined, isValue, parseDate} from "../../module/util";
9
9
 
10
10
  export default {
11
11
  initLine(): void {
12
12
  const {$el} = this;
13
13
 
14
- $el.line = $el.main.select(`.${CLASS.chart}`).append("g")
15
- .attr("class", CLASS.chartLines);
14
+ $el.line = $el.main.select(`.${$COMMON.chart}`).append("g")
15
+ .attr("class", $LINE.chartLines);
16
16
  },
17
17
 
18
18
  updateTargetsForLine(t): void {
@@ -28,8 +28,8 @@ export default {
28
28
 
29
29
  const targets = t.filter(d => !($$.isScatterType(d) || $$.isBubbleType(d)));
30
30
 
31
- const mainLineUpdate = main.select(`.${CLASS.chartLines}`)
32
- .selectAll(`.${CLASS.chartLine}`)
31
+ const mainLineUpdate = main.select(`.${$LINE.chartLines}`)
32
+ .selectAll(`.${$LINE.chartLine}`)
33
33
  .data(targets)
34
34
  .attr("class", d => classChartLine(d) + classFocus(d));
35
35
 
@@ -62,8 +62,8 @@ export default {
62
62
  const $root = isSub ? $el.subchart : $el;
63
63
 
64
64
  const line = $root.main
65
- .selectAll(`.${CLASS.lines}`)
66
- .selectAll(`.${CLASS.line}`)
65
+ .selectAll(`.${$LINE.lines}`)
66
+ .selectAll(`.${$LINE.line}`)
67
67
  .data($$.lineData.bind($$));
68
68
 
69
69
  $T(line.exit(), withTransition)
@@ -7,7 +7,7 @@ import {
7
7
  select as d3Select
8
8
  } from "d3-selection";
9
9
  import {d3Selection} from "../../../types/types";
10
- import CLASS from "../../config/classes";
10
+ import {$CIRCLE, $COMMON, $SELECT} from "../../config/classes";
11
11
  import {document} from "../../module/browser";
12
12
  import {getBoundingRect, getPointer, getRandom, isFunction, isObject, isObjectType, isUndefined, isValue, toArray, notEmpty} from "../../module/util";
13
13
 
@@ -58,10 +58,10 @@ export default {
58
58
 
59
59
  $$.point = $$.generatePoint();
60
60
 
61
- if (($$.hasType("bubble") || $$.hasType("scatter")) && main.select(`.${CLASS.chartCircles}`).empty()) {
62
- main.select(`.${CLASS.chart}`)
61
+ if (($$.hasType("bubble") || $$.hasType("scatter")) && main.select(`.${$CIRCLE.chartCircles}`).empty()) {
62
+ main.select(`.${$COMMON.chart}`)
63
63
  .append("g")
64
- .attr("class", CLASS.chartCircles);
64
+ .attr("class", $CIRCLE.chartCircles);
65
65
  }
66
66
  },
67
67
 
@@ -86,9 +86,9 @@ export default {
86
86
  targets = (data.targets)
87
87
  .filter(d => this.isScatterType(d) || this.isBubbleType(d));
88
88
 
89
- const mainCircle = $el.main.select(`.${CLASS.chartCircles}`)
89
+ const mainCircle = $el.main.select(`.${$CIRCLE.chartCircles}`)
90
90
  .style("pointer-events", "none")
91
- .selectAll(`.${CLASS.circles}`)
91
+ .selectAll(`.${$CIRCLE.circles}`)
92
92
  .data(targets)
93
93
  .attr("class", classCircles);
94
94
 
@@ -98,7 +98,7 @@ export default {
98
98
 
99
99
  // Circles for each data point on lines
100
100
  selectionEnabled && enterNode.append("g")
101
- .attr("class", d => $$.generateClass(CLASS.selectedCircles, d.id));
101
+ .attr("class", d => $$.generateClass($SELECT.selectedCircles, d.id));
102
102
 
103
103
  enterNode.append("g")
104
104
  .attr("class", classCircles)
@@ -106,8 +106,8 @@ export default {
106
106
 
107
107
  // Update date for selected circles
108
108
  selectionEnabled && targets.forEach(t => {
109
- $el.main.selectAll(`.${CLASS.selectedCircles}${$$.getTargetSelectorSuffix(t.id)}`)
110
- .selectAll(`${CLASS.selectedCircle}`)
109
+ $el.main.selectAll(`.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(t.id)}`)
110
+ .selectAll(`${$SELECT.selectedCircle}`)
111
111
  .each(d => {
112
112
  d.value = t.values[d.index].value;
113
113
  });
@@ -121,8 +121,8 @@ export default {
121
121
  const $root = isSub ? $el.subchart : $el;
122
122
 
123
123
  if (config.point_show && !state.toggling) {
124
- const circles = $root.main.selectAll(`.${CLASS.circles}`)
125
- .selectAll(`.${CLASS.circle}`)
124
+ const circles = $root.main.selectAll(`.${$CIRCLE.circles}`)
125
+ .selectAll(`.${$CIRCLE.circle}`)
126
126
  .data(d => (
127
127
  ($$.isLineType(d) && $$.shouldDrawPointsForLine(d)) ||
128
128
  $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ?
@@ -135,7 +135,7 @@ export default {
135
135
  .filter(Boolean)
136
136
  .append($$.point("create", this, $$.pointR.bind($$), $$.color));
137
137
 
138
- $root.circle = $root.main.selectAll(`.${CLASS.circles} .${CLASS.circle}`)
138
+ $root.circle = $root.main.selectAll(`.${$CIRCLE.circles} .${$CIRCLE.circle}`)
139
139
  .style("stroke", $$.color)
140
140
  .style("opacity", $$.initialOpacityForCircle.bind($$));
141
141
  }
@@ -145,7 +145,7 @@ export default {
145
145
  const $$ = this;
146
146
  const {state: {rendered}, $el, $T} = $$;
147
147
  const $root = isSub ? $el.subchart : $el;
148
- const selectedCircles = $root.main.selectAll(`.${CLASS.selectedCircle}`);
148
+ const selectedCircles = $root.main.selectAll(`.${$SELECT.selectedCircle}`);
149
149
 
150
150
  if (!$$.config.point_show) {
151
151
  return [];
@@ -256,7 +256,7 @@ export default {
256
256
 
257
257
  reset && $$.unexpandCircles();
258
258
 
259
- const circles = $$.getShapeByIndex("circle", i, id).classed(CLASS.EXPANDED, true);
259
+ const circles = $$.getShapeByIndex("circle", i, id).classed($COMMON.EXPANDED, true);
260
260
  const scale = r(circles) / $$.config.point_r;
261
261
  const ratio = 1 - scale;
262
262
 
@@ -286,9 +286,9 @@ export default {
286
286
 
287
287
  const circles = $$.getShapeByIndex("circle", i)
288
288
  .filter(function() {
289
- return d3Select(this).classed(CLASS.EXPANDED);
289
+ return d3Select(this).classed($COMMON.EXPANDED);
290
290
  })
291
- .classed(CLASS.EXPANDED, false);
291
+ .classed($COMMON.EXPANDED, false);
292
292
 
293
293
  circles.attr("r", r);
294
294
 
@@ -398,8 +398,8 @@ export default {
398
398
  circle.each(function(d) {
399
399
  let className = $$.getClass("circle", true)(d);
400
400
 
401
- if (this.getAttribute("class").indexOf(CLASS.EXPANDED) > -1) {
402
- className += ` ${CLASS.EXPANDED}`;
401
+ if (this.getAttribute("class").indexOf($COMMON.EXPANDED) > -1) {
402
+ className += ` ${$COMMON.EXPANDED}`;
403
403
  }
404
404
 
405
405
  this.setAttribute("class", className);