billboard.js 3.4.0 → 3.5.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 (70) hide show
  1. package/README.md +11 -4
  2. package/dist/billboard.css +1 -1
  3. package/dist/billboard.js +3901 -1451
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +2 -2
  6. package/dist/billboard.pkgd.js +8350 -5297
  7. package/dist/billboard.pkgd.min.js +3 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +29 -13
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +377 -92
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +447 -109
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +341 -74
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +337 -75
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +4233 -3792
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +4635 -3889
  20. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +4823 -3937
  21. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +4594 -3866
  22. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +4606 -3874
  23. package/dist/theme/datalab.css +1 -1
  24. package/dist/theme/datalab.min.css +1 -1
  25. package/dist/theme/graph.css +1 -1
  26. package/dist/theme/graph.min.css +1 -1
  27. package/dist/theme/insight.css +1 -1
  28. package/dist/theme/insight.min.css +1 -1
  29. package/dist-esm/billboard.js +796 -387
  30. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +47 -75
  31. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +68 -86
  32. package/dist-esm/plugin/billboardjs-plugin-stanford.js +52 -77
  33. package/dist-esm/plugin/billboardjs-plugin-tableview.js +49 -76
  34. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +49 -76
  35. package/package.json +40 -40
  36. package/src/Chart/api/chart.ts +4 -1
  37. package/src/Chart/api/data.ts +2 -2
  38. package/src/Chart/api/flow.ts +125 -115
  39. package/src/ChartInternal/Axis/AxisRenderer.ts +29 -3
  40. package/src/ChartInternal/ChartInternal.ts +55 -18
  41. package/src/ChartInternal/data/IData.ts +2 -2
  42. package/src/ChartInternal/data/convert.helper.ts +226 -0
  43. package/src/ChartInternal/data/convert.ts +43 -210
  44. package/src/ChartInternal/data/load.ts +5 -4
  45. package/src/ChartInternal/interactions/zoom.ts +17 -4
  46. package/src/ChartInternal/internals/color.ts +59 -36
  47. package/src/ChartInternal/internals/grid.ts +5 -3
  48. package/src/ChartInternal/internals/redraw.ts +5 -2
  49. package/src/ChartInternal/internals/scale.ts +3 -1
  50. package/src/ChartInternal/internals/size.axis.ts +5 -2
  51. package/src/ChartInternal/internals/text.ts +118 -17
  52. package/src/ChartInternal/shape/area.ts +14 -7
  53. package/src/ChartInternal/shape/bar.ts +19 -10
  54. package/src/ChartInternal/shape/point.ts +15 -9
  55. package/src/ChartInternal/shape/polar.ts +1 -1
  56. package/src/Plugin/sparkline/index.ts +22 -11
  57. package/src/Plugin/stanford/index.ts +10 -7
  58. package/src/Plugin/textoverlap/index.ts +4 -1
  59. package/src/config/Options/Options.ts +2 -0
  60. package/src/config/Options/common/boost.ts +31 -0
  61. package/src/config/Options/common/main.ts +15 -1
  62. package/src/config/Options/common/tooltip.ts +1 -1
  63. package/src/config/Options/data/data.ts +11 -3
  64. package/src/config/Options/shape/area.ts +6 -1
  65. package/src/config/Store/State.ts +3 -0
  66. package/src/module/browser.ts +2 -1
  67. package/src/module/generator.ts +18 -16
  68. package/src/module/util.ts +115 -1
  69. package/types/chart.d.ts +2 -2
  70. package/types/options.d.ts +45 -8
@@ -4,10 +4,12 @@
4
4
  */
5
5
  import {select as d3Select} from "d3-selection";
6
6
  import {scaleOrdinal as d3ScaleOrdinal} from "d3-scale";
7
- import {document, window} from "../../module/browser";
7
+ import {document} from "../../module/browser";
8
8
  import {$ARC, $COLOR, $SHAPE} from "../../config/classes";
9
9
  import {KEY} from "../../module/Cache";
10
- import {notEmpty, isFunction, isObject, isString} from "../../module/util";
10
+ import {addCssRules, notEmpty, isFunction, isObject, isString} from "../../module/util";
11
+ import {IArcData, IDataRow} from "../data/IData";
12
+ import {d3Selection} from "../../../types";
11
13
 
12
14
  /**
13
15
  * Set pattern's background color
@@ -34,57 +36,78 @@ const colorizePattern = (pattern, color, id: string) => {
34
36
  };
35
37
  };
36
38
 
39
+ /**
40
+ * Get color pattern from CSS file
41
+ * CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
42
+ * @param {d3Selection} element Chart element
43
+ * @returns {Array}
44
+ * @private
45
+ */
46
+ function getColorFromCss(element: d3Selection): string[] {
47
+ const cacheKey = KEY.colorPattern;
48
+ const {body} = document;
49
+ let pattern = body[cacheKey];
50
+
51
+ if (!pattern) {
52
+ const delimiter = ";";
53
+ const content = element
54
+ .classed($COLOR.colorPattern, true)
55
+ .style("background-image");
56
+
57
+ element.classed($COLOR.colorPattern, false);
58
+
59
+ if (content.indexOf(delimiter) > -1) {
60
+ pattern = content
61
+ .replace(/url[^#]*|["'()]|(\s|%20)/g, "")
62
+ .split(delimiter)
63
+ .map(v => v.trim().replace(/[\"'\s]/g, ""))
64
+ .filter(Boolean);
65
+
66
+ body[cacheKey] = pattern;
67
+ }
68
+ }
69
+
70
+ return pattern;
71
+ }
72
+
37
73
  // Replacement of d3.schemeCategory10.
38
74
  // Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
39
75
  const schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
40
76
 
41
77
  export default {
42
78
  /**
43
- * Get color pattern from CSS file
44
- * CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
45
- * @returns {Array}
79
+ * Add props color css rule to given selector
80
+ * @param {Function} fn Color function
81
+ * @param {string} selector CSS selector
82
+ * @param {Array} props CSS props list
83
+ * @returns {Function}
46
84
  * @private
47
85
  */
48
- getColorFromCss(): string[] {
49
- const cacheKey = KEY.colorPattern;
50
- const {body} = document;
51
- let pattern = body[cacheKey];
52
-
53
- if (!pattern) {
54
- const delimiter = ";";
55
- const span = document.createElement("span");
56
-
57
- span.className = $COLOR.colorPattern;
58
- span.style.display = "none";
59
- body.appendChild(span);
60
-
61
- const content = window.getComputedStyle(span).backgroundImage;
62
-
63
- span.parentNode.removeChild(span);
64
-
65
- if (content.indexOf(delimiter) > -1) {
66
- pattern = content
67
- .replace(/url[^#]*|["'()]|(\s|%20)/g, "")
68
- .split(delimiter)
69
- .map(v => v.trim().replace(/[\"'\s]/g, ""))
70
- .filter(Boolean);
86
+ setColorByRule(fn: Function, selector: string, props: string[]): Function {
87
+ const $$ = this;
88
+ const {config, state: {colorRule, style}} = $$;
89
+ const colorFn = fn || $$.color;
71
90
 
72
- body[cacheKey] = pattern;
73
- }
74
- }
91
+ return config.boost_useCssRule ? (selection: d3Selection) => {
92
+ selection.each((d: IDataRow) => {
93
+ const color = colorFn.call($$, d);
94
+ const shapeSelector = `${$SHAPE.shapes}${$$.getTargetSelectorSuffix(d.id)} .${selector}`;
75
95
 
76
- return pattern;
96
+ (shapeSelector in colorRule) && style.sheet.deleteRule(colorRule[shapeSelector]);
97
+ $$.state.colorRule[shapeSelector] = addCssRules(style, shapeSelector, props.map(v => `${v}: ${color}`));
98
+ });
99
+ } : () => {};
77
100
  },
78
101
 
79
102
  generateColor(): Function {
80
103
  const $$ = this;
81
- const {config} = $$;
104
+ const {$el, config} = $$;
82
105
  const colors = config.data_colors;
83
106
  const callback = config.data_color;
84
107
  const ids: string[] = [];
85
108
 
86
109
  let pattern = notEmpty(config.color_pattern) ? config.color_pattern :
87
- d3ScaleOrdinal($$.getColorFromCss() || schemeCategory10).range();
110
+ d3ScaleOrdinal(getColorFromCss($el.chart) || schemeCategory10).range();
88
111
 
89
112
  const originalColorPattern = pattern;
90
113
 
@@ -103,8 +126,8 @@ export default {
103
126
  $$.patterns = colorizedPatterns;
104
127
  }
105
128
 
106
- return function(d) {
107
- const id: string = d.id || d.data?.id || d;
129
+ return function(d: IDataRow | IArcData | string): string {
130
+ const id: string = (d as IDataRow).id || (d as IArcData).data?.id || d as string;
108
131
  const isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id];
109
132
  let color;
110
133
 
@@ -133,10 +133,12 @@ export default {
133
133
 
134
134
  updateYGrid(): void {
135
135
  const $$ = this;
136
- const {config, state, $el: {grid, main}} = $$;
136
+ const {axis, config, scale, state, $el: {grid, main}} = $$;
137
137
  const isRotated = config.axis_rotated;
138
- const gridValues = $$.axis.y.tickValues() || $$.scale.y.ticks(config.grid_y_ticks);
139
- const pos = d => Math.ceil($$.scale.y(d));
138
+ const pos = d => Math.ceil(scale.y(d));
139
+
140
+ const gridValues =
141
+ axis.y.getGeneratedTicks(config.grid_y_ticks) || $$.scale.y.ticks(config.grid_y_ticks);
140
142
 
141
143
  grid.y = main.select(`.${$GRID.ygrids}`)
142
144
  .selectAll(`.${$GRID.ygrid}`)
@@ -26,7 +26,6 @@ export default {
26
26
  $$.updateSizes(initializing);
27
27
 
28
28
  // update legend and transform each g
29
-
30
29
  if (wth.Legend && config.legend_show) {
31
30
  options.withTransition = !!duration;
32
31
  $$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
@@ -246,7 +245,11 @@ export default {
246
245
  $$.redraw(options, transitions);
247
246
  },
248
247
 
249
- redrawWithoutRescale() {
248
+ /**
249
+ * Redraw without rescale
250
+ * @private
251
+ */
252
+ redrawWithoutRescale(): void {
250
253
  this.redraw({
251
254
  withY: false,
252
255
  withDimension: false,
@@ -169,7 +169,9 @@ export default {
169
169
  const xSubDomain = updateXDomain && org.xDomain;
170
170
 
171
171
  scale.x = $$.getXScale(min.x, max.x, xDomain, () => axis.x.tickOffset());
172
- scale.subX = $$.getXScale(min.x, max.x, xSubDomain, d => (d % 1 ? 0 : axis.subX.tickOffset()));
172
+ scale.subX = $$.getXScale(min.x, max.x, xSubDomain, d => (
173
+ d % 1 ? 0 : (axis.subX ?? axis.x).tickOffset())
174
+ );
173
175
 
174
176
  format.xAxisTick = axis.getXAxisTickFormat();
175
177
  format.subXAxisTick = axis.getXAxisTickFormat(true);
@@ -25,9 +25,12 @@ export default {
25
25
 
26
26
  if ($$.axis) {
27
27
  const position = $$.axis?.getLabelPositionById(id);
28
+ const width = $$.axis.getMaxTickWidth(id, withoutRecompute);
29
+ const gap = width === 0 ? 0.5 : 0;
28
30
 
29
- return $$.axis.getMaxTickWidth(id, withoutRecompute) +
30
- (position.isInner ? 20 : 40);
31
+ return width + (
32
+ position.isInner ? (20 + gap) : 40
33
+ );
31
34
  } else {
32
35
  return 40;
33
36
  }
@@ -12,6 +12,83 @@ import {capitalize, getBoundingRect, getRandom, isFunction, isNumber, isObject,
12
12
  import {IDataRow, IArcData} from "../data/IData";
13
13
  import {AxisType} from "../../../types/types";
14
14
 
15
+ type Coord = {x: number, y: number};
16
+ type Anchor = "start" | "middle" | "end";
17
+
18
+ /**
19
+ * Get text-anchor according text.labels.rotate angle
20
+ * @param {number} angle Angle value
21
+ * @returns {string} Anchor string value
22
+ * @private
23
+ */
24
+ function getRotateAnchor(angle: number): Anchor {
25
+ let anchor: Anchor = "middle";
26
+
27
+ if (angle > 0 && angle <= 170) {
28
+ anchor = "end";
29
+ } else if (angle > 190 && angle <= 360) {
30
+ anchor = "start";
31
+ }
32
+
33
+ return anchor;
34
+ }
35
+
36
+ /**
37
+ * Set rotated position coordinate according text.labels.rotate angle
38
+ * @param {object} d Data object
39
+ * @param {object} pos Position object
40
+ * @param {object} pos.x x coordinate
41
+ * @param {object} pos.y y coordinate
42
+ * @param {string} anchor string value
43
+ * @param {boolean} isRotated If axis is rotated
44
+ * @param {boolean} isInverted If axis is inverted
45
+ * @returns {object} x, y coordinate
46
+ * @private
47
+ */
48
+ function setRotatePos(
49
+ d: IDataRow, pos: Coord, anchor: Anchor, isRotated: boolean, isInverted: boolean
50
+ ): Coord {
51
+ const $$ = this;
52
+ const {value} = d;
53
+ const isCandlestickType = $$.isCandlestickType(d);
54
+ const isNegative = (isNumber(value) && value < 0) || (
55
+ isCandlestickType && !$$.getCandlestickData(d)?._isUp
56
+ );
57
+
58
+ let {x, y} = pos;
59
+ const gap = 4;
60
+ const doubleGap = gap * 2;
61
+
62
+ if (isRotated) {
63
+ if (anchor === "start") {
64
+ x += isNegative ? 0 : doubleGap;
65
+ y += gap;
66
+ } else if (anchor === "middle") {
67
+ x += doubleGap;
68
+ y -= doubleGap;
69
+ } else if (anchor === "end") {
70
+ isNegative && (x -= doubleGap);
71
+ y += gap;
72
+ }
73
+ } else {
74
+ if (anchor === "start") {
75
+ x += gap;
76
+ isNegative && (y += doubleGap * 2);
77
+ } else if (anchor === "middle") {
78
+ y -= doubleGap;
79
+ } else if (anchor === "end") {
80
+ x -= gap;
81
+ isNegative && (y += doubleGap * 2);
82
+ }
83
+
84
+ if (isInverted) {
85
+ y += isNegative ? -17 : (isCandlestickType ? 13 : 7);
86
+ }
87
+ }
88
+
89
+ return {x, y};
90
+ }
91
+
15
92
  export default {
16
93
  opacityForText(d): null | "0" {
17
94
  const $$ = this;
@@ -50,6 +127,7 @@ export default {
50
127
  const mainTextEnter = mainTextUpdate.enter().append("g")
51
128
  .style("opacity", "0")
52
129
  .attr("class", classChartText)
130
+ .call($$.setColorByRule($$.updateTextColor, $TEXT.text, ["fill"]))
53
131
  .style("pointer-events", "none");
54
132
 
55
133
  mainTextEnter.append("g")
@@ -89,7 +167,7 @@ export default {
89
167
 
90
168
  return (config.axis_rotated ? (isEndAnchor ? "end" : "start") : "middle");
91
169
  })
92
- .style("fill", $$.updateTextColor.bind($$))
170
+ .style("fill", $$.colorTextByRule)
93
171
  .style("fill-opacity", "0")
94
172
  .each(function(d, i, texts) {
95
173
  const node = d3Select(this);
@@ -171,34 +249,46 @@ export default {
171
249
 
172
250
  /**
173
251
  * Redraw chartText
174
- * @param {Function} x Positioning function for x
175
- * @param {Function} y Positioning function for y
252
+ * @param {Function} getX Positioning function for x
253
+ * @param {Function} getY Positioning function for y
176
254
  * @param {boolean} forFlow Weather is flow
177
255
  * @param {boolean} withTransition transition is enabled
178
256
  * @returns {Array}
179
257
  * @private
180
258
  */
181
- redrawText(x, y, forFlow?: boolean, withTransition?: boolean): true {
259
+ redrawText(getX, getY, forFlow?: boolean, withTransition?: boolean): true {
182
260
  const $$ = this;
183
- const {$T} = $$;
261
+ const {$T, axis, config} = $$;
184
262
  const t = <string>getRandom(true);
263
+ const isRotated = config.axis_rotated;
264
+ const angle = config.data_labels.rotate;
265
+
266
+ const anchorString = getRotateAnchor(angle);
267
+ const rotateString = angle ? `rotate(${angle})` : "";
185
268
 
186
269
  $$.$el.text
187
- .style("fill", $$.updateTextColor.bind($$))
270
+ .style("fill", $$.colorTextByRule)
188
271
  .attr("filter", $$.updateTextBacgroundColor.bind($$))
189
272
  .style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$))
190
- .each(function(d, i) {
273
+ .each(function(d: IDataRow, i: number) {
191
274
  // do not apply transition for newly added text elements
192
275
  const node = $T(this, !!(withTransition && this.getAttribute("x")), t);
193
-
194
- const posX = x.bind(this)(d, i);
195
- const posY = y.bind(this)(d, i);
276
+ const isInverted = config[`axis_${axis?.getId(d.id)}_inverted`];
277
+ let pos = {
278
+ x: getX.bind(this)(d, i),
279
+ y: getY.bind(this)(d, i)
280
+ };
281
+
282
+ if (angle) {
283
+ pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
284
+ node.attr("text-anchor", anchorString);
285
+ }
196
286
 
197
287
  // when is multiline
198
- if (this.childElementCount) {
199
- node.attr("transform", `translate(${posX} ${posY})`);
288
+ if (this.childElementCount || angle) {
289
+ node.attr("transform", `translate(${pos.x} ${pos.y}) ${rotateString}`);
200
290
  } else {
201
- node.attr("x", posX).attr("y", posY);
291
+ node.attr("x", pos.x).attr("y", pos.y);
202
292
  }
203
293
  });
204
294
 
@@ -338,7 +428,6 @@ export default {
338
428
  const isRotated = config.axis_rotated;
339
429
  let xPos = points[0][0];
340
430
 
341
-
342
431
  if ($$.isCandlestickType(d)) {
343
432
  if (isRotated) {
344
433
  xPos = $$.getCandlestickData(d)?._isUp ?
@@ -384,8 +473,10 @@ export default {
384
473
  */
385
474
  getYForText(points, d, textElement): number {
386
475
  const $$ = this;
387
- const {config, state} = $$;
476
+ const {axis, config, state} = $$;
388
477
  const isRotated = config.axis_rotated;
478
+ const isInverted = config[`axis_${axis?.getId(d.id)}_inverted`];
479
+ const isBarType = $$.isBarType(d);
389
480
  const r = config.point_r;
390
481
  const rect = getBoundingRect(textElement);
391
482
  let {value} = d;
@@ -402,6 +493,10 @@ export default {
402
493
  yPos = value && value._isUp ?
403
494
  points[2][2] - baseY :
404
495
  points[2][1] + (baseY * 4);
496
+
497
+ if (isInverted) {
498
+ yPos += 15 * (value._isUp ? 1 : -1);
499
+ }
405
500
  }
406
501
  } else {
407
502
  if (isRotated) {
@@ -414,16 +509,22 @@ export default {
414
509
  }
415
510
 
416
511
  if (value < 0 || (value === 0 && !state.hasPositiveValue && state.hasNegativeValue)) {
417
- yPos += rect.height + ($$.isBarType(d) ? -baseY : baseY);
512
+ yPos += isInverted ? (isBarType ? -3 : -5) : (
513
+ rect.height + (isBarType ? -baseY : baseY)
514
+ );
418
515
  } else {
419
516
  let diff = -baseY * 2;
420
517
 
421
- if ($$.isBarType(d)) {
518
+ if (isBarType) {
422
519
  diff = -baseY;
423
520
  } else if ($$.isBubbleType(d)) {
424
521
  diff = baseY;
425
522
  }
426
523
 
524
+ if (isInverted) {
525
+ diff = isBarType ? 10 : 15;
526
+ }
527
+
427
528
  yPos += diff;
428
529
  }
429
530
  }
@@ -6,9 +6,13 @@ import {area as d3Area} from "d3-shape";
6
6
  import {select as d3Select} from "d3-selection";
7
7
  import {$AREA, $CIRCLE, $LINE} from "../../config/classes";
8
8
  import {getRandom, isFunction} from "../../module/util";
9
+ import {IData, IDataRow} from "../data/IData";
10
+ import {d3Selection} from "../../../types";
11
+
12
+ type Indices = {[key: string | "__max__"]: number};
9
13
 
10
14
  export default {
11
- initArea(mainLine): void {
15
+ initArea(mainLine: d3Selection): void {
12
16
  const $$ = this;
13
17
  const {config} = $$;
14
18
 
@@ -51,7 +55,7 @@ export default {
51
55
  });
52
56
  },
53
57
 
54
- updateAreaColor(d): string {
58
+ updateAreaColor(d: IDataRow): string {
55
59
  const $$ = this;
56
60
 
57
61
  return $$.config.area_linearGradient ?
@@ -99,7 +103,7 @@ export default {
99
103
  * @param {boolean} isSub Subchart draw
100
104
  * @returns {Array}
101
105
  */
102
- redrawArea(drawFn, withTransition?: boolean, isSub = false) {
106
+ redrawArea(drawFn: Function, withTransition?: boolean, isSub = false): d3Selection[] {
103
107
  const $$ = this;
104
108
  const {area} = (isSub ? this.$el.subchart : this.$el);
105
109
  const {orgAreaOpacity} = $$.state;
@@ -119,7 +123,7 @@ export default {
119
123
  * @returns {Function}
120
124
  * @private
121
125
  */
122
- generateDrawArea(areaIndices, isSub?: boolean): (d) => string {
126
+ generateDrawArea(areaIndices: Indices, isSub?: boolean): (d: IData) => string {
123
127
  const $$ = this;
124
128
  const {config} = $$;
125
129
  const lineConnectNull = config.line_connectNull;
@@ -156,8 +160,9 @@ export default {
156
160
  .x0(value0)
157
161
  .x1(value1) :
158
162
  area.x(xValue)
159
- // @ts-ignore
160
- .y0(config.area_above ? 0 : value0)
163
+ .y0(config.area_above ? 0 : (
164
+ config.area_below ? $$.state.height : value0
165
+ ))
161
166
  .y1(value1);
162
167
 
163
168
  if (!lineConnectNull) {
@@ -182,7 +187,9 @@ export default {
182
187
  };
183
188
  },
184
189
 
185
- generateGetAreaPoints(areaIndices, isSub?: boolean): Function {
190
+ generateGetAreaPoints(
191
+ areaIndices: Indices, isSub?: boolean
192
+ ): (d: IDataRow, i: number) => [number, number][] {
186
193
  // partial duplication of generateGetBarPoints
187
194
  const $$ = this;
188
195
  const {config} = $$;
@@ -57,7 +57,8 @@ export default {
57
57
  // Bars for each data
58
58
  mainBarEnter.append("g")
59
59
  .attr("class", classBars)
60
- .style("cursor", d => (isSelectable?.bind?.($$.api)(d) ? "pointer" : null));
60
+ .style("cursor", d => (isSelectable?.bind?.($$.api)(d) ? "pointer" : null))
61
+ .call($$.setColorByRule(null, $BAR.bar, ["fill"]));
61
62
  },
62
63
 
63
64
  /**
@@ -83,7 +84,7 @@ export default {
83
84
 
84
85
  $root.bar = bar.enter().append("path")
85
86
  .attr("class", classBar)
86
- .style("fill", $$.color)
87
+ .style("fill", $$.colorByRule)
87
88
  .merge(bar)
88
89
  .style("opacity", initialOpacity);
89
90
  },
@@ -102,7 +103,7 @@ export default {
102
103
  return [
103
104
  $$.$T(bar, withTransition, getRandom())
104
105
  .attr("d", d => (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d))
105
- .style("fill", this.color)
106
+ .style("fill", $$.colorByRule)
106
107
  .style("opacity", null)
107
108
  ];
108
109
  },
@@ -149,15 +150,15 @@ export default {
149
150
  const indexX = +isRotated;
150
151
  const indexY = +!indexX;
151
152
 
152
- const isNegative = d.value < 0;
153
+ const isNegative = d.value as number < 0;
153
154
  const pathRadius = ["", ""];
154
155
  let radius = 0;
155
156
 
156
157
  const isGrouped = $$.isGrouped(d.id);
157
- const hasRadius = d.value !== 0 && getRadius;
158
- const isRadiusData = hasRadius && isGrouped ? $$.isStackingRadiusData(d) : false;
158
+ // const hasRadius = d.value !== 0 && getRadius;
159
+ const isRadiusData = getRadius && isGrouped ? $$.isStackingRadiusData(d) : false;
159
160
 
160
- if (hasRadius && (!isGrouped || isRadiusData)) {
161
+ if (getRadius && (!isGrouped || isRadiusData)) {
161
162
  const index = isRotated ? indexY : indexX;
162
163
  const barW = points[2][index] - points[0][index];
163
164
 
@@ -188,9 +189,16 @@ export default {
188
189
  */
189
190
  isStackingRadiusData(d: IDataRow): boolean {
190
191
  const $$ = this;
191
- const {config, data} = $$;
192
+ const {$el, config, data, state} = $$;
192
193
  const {id, index, value} = d;
193
194
 
195
+ // when the data is hidden, check if has rounded edges
196
+ if (state.hiddenTargetIds.indexOf(id) > -1) {
197
+ const target = $el.bar.filter(d => d.id === id && d.value === value);
198
+
199
+ return !target.empty() && /a\d+/i.test(target.attr("d"));
200
+ }
201
+
194
202
  // Find same grouped ids
195
203
  const keys = config.data_groups.find(v => v.indexOf(id) > -1);
196
204
 
@@ -203,7 +211,7 @@ export default {
203
211
  const sortedIds = sortedList
204
212
  .map(v => v.values.filter(
205
213
  v2 => v2.index === index && (
206
- value > 0 ? v2.value > 0 : v2.value < 0
214
+ isNumber(value) && value > 0 ? v2.value > 0 : v2.value < 0
207
215
  ))[0]
208
216
  )
209
217
  .filter(Boolean)
@@ -235,12 +243,13 @@ export default {
235
243
  const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
236
244
  const offset = barOffset(d, i) || y0; // offset is for stacked bar chart
237
245
  const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
246
+ const value = d.value as number;
238
247
  const posX = barX(d);
239
248
  let posY = barY(d);
240
249
 
241
250
  // fix posY not to overflow opposite quadrant
242
251
  if (config.axis_rotated && (
243
- (d.value > 0 && posY < y0) || (d.value < 0 && y0 < posY)
252
+ (value > 0 && posY < y0) || (value < 0 && y0 < posY)
244
253
  )) {
245
254
  posY = y0;
246
255
  }
@@ -102,9 +102,12 @@ export default {
102
102
  enterNode.append("g")
103
103
  .attr("class", classCircles)
104
104
  .style("cursor", d => (isFunction(isSelectable) && isSelectable(d) ? "pointer" : null))
105
+ .call($$.setColorByRule(null, $CIRCLE.circle, ["fill", "stroke"]))
105
106
  .style("opacity", function() {
107
+ const parent = d3Select(this.parentNode);
108
+
106
109
  // if the parent node is .bb-chart-circles (bubble, scatter), initialize <g bb-circles> with opacity "0"
107
- return this.parentNode?.classList.contains("bb-chart-circles") ? "0" : null;
110
+ return parent.attr("class").indexOf($CIRCLE.chartCircles) > -1 ? "0" : null;
108
111
  });
109
112
 
110
113
  // Update date for selected circles
@@ -136,10 +139,10 @@ export default {
136
139
 
137
140
  circles.enter()
138
141
  .filter(Boolean)
139
- .append($$.point("create", this, $$.pointR.bind($$), $$.color));
142
+ .append($$.point("create", this, $$.pointR.bind($$), $$.colorByRule));
140
143
 
141
144
  $root.circle = $root.main.selectAll(`.${$CIRCLE.circles} .${$CIRCLE.circle}`)
142
- .style("stroke", $$.color)
145
+ .style("stroke", $$.colorByRule)
143
146
  .style("opacity", $$.initialOpacityForCircle.bind($$));
144
147
  }
145
148
  },
@@ -154,10 +157,10 @@ export default {
154
157
  return [];
155
158
  }
156
159
 
157
- const fn = $$.point("update", $$, cx, cy, $$.color, withTransition, flow, selectedCircles);
160
+ const fn = $$.point("update", $$, cx, cy, $$.colorByRule, withTransition, flow, selectedCircles);
158
161
  const posAttr = $$.isCirclePoint() ? "c" : "";
159
162
 
160
- const t: any = getRandom();
163
+ const t = getRandom();
161
164
  const opacityStyleFn = $$.opacityForCircle.bind($$);
162
165
  const mainCircles: any[] = [];
163
166
 
@@ -192,7 +195,7 @@ export default {
192
195
  const cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$);
193
196
  const cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$);
194
197
  const withTransition = toggling || isUndefined(d);
195
- const fn = $$.point("update", $$, cx, cy, $$.color, resizing ? false : withTransition);
198
+ const fn = $$.point("update", $$, cx, cy, $$.colorByRule, resizing ? false : withTransition);
196
199
 
197
200
  if (d) {
198
201
  circle = circle
@@ -295,8 +298,11 @@ export default {
295
298
 
296
299
  circles.attr("r", r);
297
300
 
298
- !$$.isCirclePoint() &&
299
- circles.attr("transform", `scale(${r(circles) / $$.config.point_r})`);
301
+ if (!$$.isCirclePoint()) {
302
+ const scale = r(circles) / $$.config.point_r;
303
+
304
+ circles.attr("transform", scale !== 1 ? `scale(${scale})` : null);
305
+ }
300
306
  },
301
307
 
302
308
  pointR(d): number {
@@ -483,7 +489,7 @@ export default {
483
489
  },
484
490
 
485
491
  custom: {
486
- create(element, id, sizeFn, fillStyleFn) {
492
+ create(element, id, fillStyleFn) {
487
493
  return element.append("use")
488
494
  .attr("xlink:href", `#${id}`)
489
495
  .attr("class", this.updatePointClass.bind(this))
@@ -55,7 +55,7 @@ export default {
55
55
  getPolarOuterRadius(d: IArcData, outerRadius: number): number {
56
56
  const dataMax = getDataMax(this);
57
57
 
58
- return (d?.data.values[0].value / dataMax) * outerRadius;
58
+ return ((d?.data.values[0].value ?? 0) / dataMax) * outerRadius;
59
59
  },
60
60
 
61
61
  /**