billboard.js 4.0.2 → 4.0.3

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 (223) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +102 -71
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +16 -17
  5. package/dist/billboard.pkgd.js +102 -71
  6. package/dist/billboard.pkgd.min.js +22 -23
  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 +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
  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.pkgd.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2 -2
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2 -2
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2 -2
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
  27. package/dist/theme/dark.css +1 -1
  28. package/dist/theme/dark.min.css +1 -1
  29. package/dist/theme/datalab.css +1 -1
  30. package/dist/theme/datalab.min.css +1 -1
  31. package/dist/theme/graph.css +1 -1
  32. package/dist/theme/graph.min.css +1 -1
  33. package/dist/theme/insight.css +1 -1
  34. package/dist/theme/insight.min.css +1 -1
  35. package/dist/theme/modern.css +1 -1
  36. package/dist/theme/modern.min.css +1 -1
  37. package/dist-esm/Chart/Chart.js +1 -1
  38. package/dist-esm/Chart/api/axis.js +1 -1
  39. package/dist-esm/Chart/api/category.js +1 -1
  40. package/dist-esm/Chart/api/chart.js +1 -1
  41. package/dist-esm/Chart/api/color.js +1 -1
  42. package/dist-esm/Chart/api/data.js +1 -1
  43. package/dist-esm/Chart/api/export.js +1 -1
  44. package/dist-esm/Chart/api/flow.js +1 -1
  45. package/dist-esm/Chart/api/focus.js +7 -11
  46. package/dist-esm/Chart/api/grid.js +1 -1
  47. package/dist-esm/Chart/api/group.js +1 -1
  48. package/dist-esm/Chart/api/legend.js +1 -1
  49. package/dist-esm/Chart/api/load.js +1 -1
  50. package/dist-esm/Chart/api/regions.js +1 -1
  51. package/dist-esm/Chart/api/selection.js +1 -1
  52. package/dist-esm/Chart/api/show.js +1 -1
  53. package/dist-esm/Chart/api/stubs.js +1 -1
  54. package/dist-esm/Chart/api/subchart.js +1 -1
  55. package/dist-esm/Chart/api/tooltip.js +1 -1
  56. package/dist-esm/Chart/api/x.js +1 -1
  57. package/dist-esm/Chart/api/zoom.js +1 -1
  58. package/dist-esm/ChartInternal/Axis/Axis.js +1 -1
  59. package/dist-esm/ChartInternal/Axis/AxisRenderer.js +1 -1
  60. package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +1 -1
  61. package/dist-esm/ChartInternal/ChartInternal.js +1 -1
  62. package/dist-esm/ChartInternal/data/convert.helper.js +1 -1
  63. package/dist-esm/ChartInternal/data/convert.js +1 -1
  64. package/dist-esm/ChartInternal/data/data.js +15 -6
  65. package/dist-esm/ChartInternal/data/load.js +1 -1
  66. package/dist-esm/ChartInternal/interactions/drag.js +1 -1
  67. package/dist-esm/ChartInternal/interactions/eventrect.js +1 -1
  68. package/dist-esm/ChartInternal/interactions/flow.js +1 -1
  69. package/dist-esm/ChartInternal/interactions/interaction.js +1 -1
  70. package/dist-esm/ChartInternal/interactions/subchart.js +1 -1
  71. package/dist-esm/ChartInternal/interactions/zoom.js +1 -1
  72. package/dist-esm/ChartInternal/internals/category.js +1 -1
  73. package/dist-esm/ChartInternal/internals/class.js +1 -1
  74. package/dist-esm/ChartInternal/internals/clip.js +1 -1
  75. package/dist-esm/ChartInternal/internals/color.js +5 -5
  76. package/dist-esm/ChartInternal/internals/domain.js +1 -1
  77. package/dist-esm/ChartInternal/internals/format.js +1 -1
  78. package/dist-esm/ChartInternal/internals/grid.js +1 -1
  79. package/dist-esm/ChartInternal/internals/legend.js +1 -1
  80. package/dist-esm/ChartInternal/internals/redraw.js +1 -1
  81. package/dist-esm/ChartInternal/internals/region.js +1 -1
  82. package/dist-esm/ChartInternal/internals/scale.js +1 -1
  83. package/dist-esm/ChartInternal/internals/selection.js +1 -1
  84. package/dist-esm/ChartInternal/internals/size.axis.js +1 -1
  85. package/dist-esm/ChartInternal/internals/size.js +1 -1
  86. package/dist-esm/ChartInternal/internals/style.js +1 -1
  87. package/dist-esm/ChartInternal/internals/text.arc.js +1 -1
  88. package/dist-esm/ChartInternal/internals/text.js +2 -2
  89. package/dist-esm/ChartInternal/internals/text.util.js +1 -1
  90. package/dist-esm/ChartInternal/internals/title.js +1 -1
  91. package/dist-esm/ChartInternal/internals/tooltip.js +1 -1
  92. package/dist-esm/ChartInternal/internals/transform.js +1 -1
  93. package/dist-esm/ChartInternal/internals/type.js +26 -34
  94. package/dist-esm/ChartInternal/shape/arc.js +1 -1
  95. package/dist-esm/ChartInternal/shape/area.js +1 -1
  96. package/dist-esm/ChartInternal/shape/bar.js +23 -7
  97. package/dist-esm/ChartInternal/shape/bubble.js +1 -1
  98. package/dist-esm/ChartInternal/shape/candlestick.js +1 -1
  99. package/dist-esm/ChartInternal/shape/core/barRadius.js +1 -1
  100. package/dist-esm/ChartInternal/shape/core/bubble.js +1 -1
  101. package/dist-esm/ChartInternal/shape/core/candlestick.js +1 -1
  102. package/dist-esm/ChartInternal/shape/core/dataRegion.js +1 -1
  103. package/dist-esm/ChartInternal/shape/core/geometry.js +1 -1
  104. package/dist-esm/ChartInternal/shape/core/path.js +1 -1
  105. package/dist-esm/ChartInternal/shape/core/point.js +1 -1
  106. package/dist-esm/ChartInternal/shape/core/treemap.js +1 -1
  107. package/dist-esm/ChartInternal/shape/funnel.js +1 -1
  108. package/dist-esm/ChartInternal/shape/gauge.js +1 -1
  109. package/dist-esm/ChartInternal/shape/line.js +2 -2
  110. package/dist-esm/ChartInternal/shape/point.js +22 -10
  111. package/dist-esm/ChartInternal/shape/polar.js +1 -1
  112. package/dist-esm/ChartInternal/shape/radar.js +1 -1
  113. package/dist-esm/ChartInternal/shape/shape.js +19 -4
  114. package/dist-esm/ChartInternal/shape/treemap.js +1 -1
  115. package/dist-esm/canvas/CanvasAxisRenderer.js +1 -1
  116. package/dist-esm/canvas/CanvasEngine.js +1 -1
  117. package/dist-esm/canvas/CanvasPainter.js +1 -1
  118. package/dist-esm/canvas/CanvasRenderer.js +1 -1
  119. package/dist-esm/canvas/CanvasTheme.js +1 -1
  120. package/dist-esm/canvas/HitDetector.js +1 -1
  121. package/dist-esm/canvas/axisTicks.js +1 -1
  122. package/dist-esm/canvas/classes.js +1 -1
  123. package/dist-esm/canvas/color.js +1 -1
  124. package/dist-esm/canvas/geometry.js +1 -1
  125. package/dist-esm/canvas/labels.js +1 -1
  126. package/dist-esm/canvas/pointPattern.js +1 -1
  127. package/dist-esm/canvas/util.js +1 -1
  128. package/dist-esm/config/Options/Options.js +1 -1
  129. package/dist-esm/config/Options/axis/axis.js +1 -1
  130. package/dist-esm/config/Options/axis/x.js +1 -1
  131. package/dist-esm/config/Options/axis/y.js +1 -1
  132. package/dist-esm/config/Options/axis/y2.js +1 -1
  133. package/dist-esm/config/Options/common/boost.js +1 -1
  134. package/dist-esm/config/Options/common/color.js +1 -1
  135. package/dist-esm/config/Options/common/grid.js +1 -1
  136. package/dist-esm/config/Options/common/legend.js +1 -1
  137. package/dist-esm/config/Options/common/main.js +1 -1
  138. package/dist-esm/config/Options/common/point.js +1 -1
  139. package/dist-esm/config/Options/common/title.js +1 -1
  140. package/dist-esm/config/Options/common/tooltip.js +1 -1
  141. package/dist-esm/config/Options/data/axis.js +1 -1
  142. package/dist-esm/config/Options/data/data.js +1 -1
  143. package/dist-esm/config/Options/data/selection.js +1 -1
  144. package/dist-esm/config/Options/interaction/interaction.js +1 -1
  145. package/dist-esm/config/Options/interaction/subchart.js +1 -1
  146. package/dist-esm/config/Options/interaction/zoom.js +1 -1
  147. package/dist-esm/config/Options/shape/arc.js +1 -1
  148. package/dist-esm/config/Options/shape/area.js +1 -1
  149. package/dist-esm/config/Options/shape/bar.js +1 -1
  150. package/dist-esm/config/Options/shape/bubble.js +1 -1
  151. package/dist-esm/config/Options/shape/candlestick.js +1 -1
  152. package/dist-esm/config/Options/shape/donut.js +1 -1
  153. package/dist-esm/config/Options/shape/funnel.js +1 -1
  154. package/dist-esm/config/Options/shape/gauge.js +1 -1
  155. package/dist-esm/config/Options/shape/line.js +1 -1
  156. package/dist-esm/config/Options/shape/pie.js +1 -1
  157. package/dist-esm/config/Options/shape/polar.js +1 -1
  158. package/dist-esm/config/Options/shape/radar.js +1 -1
  159. package/dist-esm/config/Options/shape/scatter.js +1 -1
  160. package/dist-esm/config/Options/shape/spline.js +1 -1
  161. package/dist-esm/config/Options/shape/treemap.js +1 -1
  162. package/dist-esm/config/Store/Element.js +1 -1
  163. package/dist-esm/config/Store/State.js +1 -1
  164. package/dist-esm/config/Store/Store.js +1 -1
  165. package/dist-esm/config/classes.js +1 -1
  166. package/dist-esm/config/config.js +1 -1
  167. package/dist-esm/config/const.js +1 -1
  168. package/dist-esm/config/resolver/axis.core.js +1 -1
  169. package/dist-esm/config/resolver/axis.js +1 -1
  170. package/dist-esm/config/resolver/canvas.js +1 -1
  171. package/dist-esm/config/resolver/canvasShape.js +1 -1
  172. package/dist-esm/config/resolver/category.js +1 -1
  173. package/dist-esm/config/resolver/export.js +1 -1
  174. package/dist-esm/config/resolver/flow.js +1 -1
  175. package/dist-esm/config/resolver/grid.js +1 -1
  176. package/dist-esm/config/resolver/interaction/selection.js +1 -1
  177. package/dist-esm/config/resolver/interaction/subchart.js +1 -1
  178. package/dist-esm/config/resolver/interaction/zoom.js +1 -1
  179. package/dist-esm/config/resolver/regions.js +1 -1
  180. package/dist-esm/config/resolver/shape/arc.helpers.js +1 -1
  181. package/dist-esm/config/resolver/shape/area.js +1 -1
  182. package/dist-esm/config/resolver/shape/axis.helpers.js +1 -1
  183. package/dist-esm/config/resolver/shape/bar.js +1 -1
  184. package/dist-esm/config/resolver/shape/bubble.js +1 -1
  185. package/dist-esm/config/resolver/shape/candlestick.js +1 -1
  186. package/dist-esm/config/resolver/shape/donut.js +1 -1
  187. package/dist-esm/config/resolver/shape/funnel.js +1 -1
  188. package/dist-esm/config/resolver/shape/gauge.js +1 -1
  189. package/dist-esm/config/resolver/shape/line.js +1 -1
  190. package/dist-esm/config/resolver/shape/pie.js +1 -1
  191. package/dist-esm/config/resolver/shape/polar.js +1 -1
  192. package/dist-esm/config/resolver/shape/radar.js +1 -1
  193. package/dist-esm/config/resolver/shape/scatter.js +1 -1
  194. package/dist-esm/config/resolver/shape/treemap.js +1 -1
  195. package/dist-esm/core.js +3 -3
  196. package/dist-esm/index.canvas.js +1 -1
  197. package/dist-esm/index.esm.js +1 -1
  198. package/dist-esm/module/Cache.js +1 -1
  199. package/dist-esm/module/browser.js +1 -1
  200. package/dist-esm/module/dsv.js +1 -1
  201. package/dist-esm/module/error.js +1 -1
  202. package/dist-esm/module/generator.js +1 -1
  203. package/dist-esm/module/sanitize.js +1 -1
  204. package/dist-esm/module/util/brush.js +1 -1
  205. package/dist-esm/module/util/dom.js +1 -1
  206. package/dist-esm/module/util/object.js +1 -1
  207. package/dist-esm/module/util/type-checks.js +1 -1
  208. package/dist-esm/module/worker.js +1 -1
  209. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  210. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  211. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  212. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  213. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  214. package/package.json +1 -1
  215. package/src/Chart/api/focus.ts +8 -12
  216. package/src/ChartInternal/data/data.ts +15 -5
  217. package/src/ChartInternal/internals/color.ts +5 -4
  218. package/src/ChartInternal/internals/text.ts +1 -1
  219. package/src/ChartInternal/internals/type.ts +26 -32
  220. package/src/ChartInternal/shape/bar.ts +26 -7
  221. package/src/ChartInternal/shape/line.ts +1 -1
  222. package/src/ChartInternal/shape/point.ts +26 -12
  223. package/src/ChartInternal/shape/shape.ts +25 -3
@@ -6,6 +6,26 @@ import {TYPE, TYPE_BY_CATEGORY} from "../../config/const";
6
6
  import {isArray, isNumber, isString} from "../../module/util";
7
7
  import type {IData} from "../data/IData";
8
8
 
9
+ // Module-level constant: avoids re-creating the list on every isInterpolationType() call
10
+ // https://github.com/d3/d3-shape#curves
11
+ const INTERPOLATION_TYPES = new Set([
12
+ "basis",
13
+ "basis-closed",
14
+ "basis-open",
15
+ "bundle",
16
+ "cardinal",
17
+ "cardinal-closed",
18
+ "cardinal-open",
19
+ "catmull-rom",
20
+ "catmull-rom-closed",
21
+ "catmull-rom-open",
22
+ "linear",
23
+ "linear-closed",
24
+ "monotone-x",
25
+ "monotone-y",
26
+ "natural"
27
+ ]);
28
+
9
29
  export default {
10
30
  /**
11
31
  * Check if the given chart type is valid
@@ -68,29 +88,20 @@ export default {
68
88
  const {config, state: {current}} = $$;
69
89
  const types = config.data_types;
70
90
  const targets = targetsValue || $$.data.targets;
71
- let has = false;
72
91
 
73
92
  if (!checkFromData && current.types?.indexOf(type) > -1) {
74
- has = true;
93
+ return true;
75
94
  } else if (targets?.length) {
76
- targets.forEach(target => {
95
+ return targets.some(target => {
77
96
  const t = types[target.id];
78
97
 
79
- if (t === type || (!t && type === "line")) {
80
- has = true;
81
- }
98
+ return t === type || (!t && type === "line");
82
99
  });
83
100
  } else if (Object.keys(types).length) {
84
- Object.keys(types).forEach(id => {
85
- if (types[id] === type) {
86
- has = true;
87
- }
88
- });
89
- } else {
90
- has = config.data_type === type;
101
+ return Object.values(types).some(t => t === type);
91
102
  }
92
103
 
93
- return has;
104
+ return config.data_type === type;
94
105
  },
95
106
 
96
107
  /**
@@ -266,24 +277,7 @@ export default {
266
277
  return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
267
278
  },
268
279
 
269
- // https://github.com/d3/d3-shape#curves
270
280
  isInterpolationType(type: string): boolean {
271
- return [
272
- "basis",
273
- "basis-closed",
274
- "basis-open",
275
- "bundle",
276
- "cardinal",
277
- "cardinal-closed",
278
- "cardinal-open",
279
- "catmull-rom",
280
- "catmull-rom-closed",
281
- "catmull-rom-open",
282
- "linear",
283
- "linear-closed",
284
- "monotone-x",
285
- "monotone-y",
286
- "natural"
287
- ].indexOf(type) >= 0;
281
+ return INTERPOLATION_TYPES.has(type);
288
282
  }
289
283
  };
@@ -110,7 +110,7 @@ export default {
110
110
 
111
111
  $root.bar = bar.enter().append("path")
112
112
  .attr("class", classBar)
113
- .style("fill", $$.updateBarColor.bind($$))
113
+ .style("fill", $$.generateUpdateBarColor())
114
114
  .merge(bar)
115
115
  .style("opacity", initialOpacity);
116
116
 
@@ -118,6 +118,19 @@ export default {
118
118
  $$.setRatioForGroupedData($root.bar.data());
119
119
  },
120
120
 
121
+ /**
122
+ * Generate bar color accessor, hoisting the bound color function
123
+ * to be created once per call (not per datum)
124
+ * @returns {function} Color accessor
125
+ * @private
126
+ */
127
+ generateUpdateBarColor(): (d: IBarData) => string | null {
128
+ const $$ = this;
129
+ const fn = $$.getStylePropValue($$.color) || (() => null);
130
+
131
+ return (d: IBarData) => getShapeColorWithGradient.call($$, d, "bar_linearGradient", fn);
132
+ },
133
+
121
134
  /**
122
135
  * Update bar color
123
136
  * @param {object} d Data object
@@ -125,10 +138,7 @@ export default {
125
138
  * @private
126
139
  */
127
140
  updateBarColor(d: IBarData): string | null {
128
- const $$ = this;
129
- const fn = $$.getStylePropValue($$.color);
130
-
131
- return getShapeColorWithGradient.call($$, d, "bar_linearGradient", fn || (() => null));
141
+ return this.generateUpdateBarColor()(d);
132
142
  },
133
143
 
134
144
  /**
@@ -183,7 +193,7 @@ export default {
183
193
 
184
194
  return path[0];
185
195
  })
186
- .style("fill", $$.updateBarColor.bind($$))
196
+ .style("fill", $$.generateUpdateBarColor())
187
197
  .style("clip-path", d => d.clipPath)
188
198
  .style("opacity", null)
189
199
  ];
@@ -215,6 +225,7 @@ export default {
215
225
  const getPoints = $$.generateGetBarPoints(barIndices, isSub);
216
226
  const getRadius = getBarRadiusResolver($$);
217
227
  const stackingRadiusSet = getRadius ? getStackingBarRadiusSet($$) : new Set<string>();
228
+ const connectLineCache = new Map<string, string | null>();
218
229
 
219
230
  return (d: IBarData, i: number): BarPath => {
220
231
  // 4 points that make a bar
@@ -264,7 +275,15 @@ export default {
264
275
 
265
276
  const coords: BarPath = [`M${points[0][indexX]},${points[0][indexY]}${path}z`];
266
277
 
267
- if (_getConnectLineType.call($$, d.id)) {
278
+ // Memoize per series id: config lookup + regex runs once per id, not per bar
279
+ let connectLineType = connectLineCache.get(d.id);
280
+
281
+ if (connectLineType === undefined) {
282
+ connectLineType = _getConnectLineType.call($$, d.id);
283
+ connectLineCache.set(d.id, connectLineType);
284
+ }
285
+
286
+ if (connectLineType) {
268
287
  coords.push(config.axis_rotated ?
269
288
  {
270
289
  x: points[0][indexX],
@@ -266,7 +266,7 @@ export default {
266
266
  if (hasNullDataValue) {
267
267
  const dx = x(data.x) - x(prevData.x);
268
268
  const dy = y(data.value) - y(prevData.value);
269
- const dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
269
+ const dd = Math.sqrt(dx * dx + dy * dy);
270
270
 
271
271
  diff = style[0] / dd; // dash
272
272
  diffx2 = diff * style[1]; // gap
@@ -186,7 +186,7 @@ export default {
186
186
  circles.exit().remove();
187
187
 
188
188
  const pointR = $$.pointR.bind($$);
189
- const updateCircleColor = $$.updateCircleColor.bind($$);
189
+ const updateCircleColor = $$.generateUpdateCircleColor();
190
190
  const initialOpacityForCircle = $$.initialOpacityForCircle.bind($$);
191
191
 
192
192
  circles.enter()
@@ -199,6 +199,21 @@ export default {
199
199
  }
200
200
  },
201
201
 
202
+ /**
203
+ * Generate circle color accessor, hoisting the bound color function
204
+ * to be created once per call (not per datum)
205
+ * @returns {function} Color accessor
206
+ * @private
207
+ */
208
+ generateUpdateCircleColor(): (d: IDataRow) => string | null {
209
+ const $$ = this;
210
+ const fn = $$.getStylePropValue($$.color);
211
+
212
+ return (d: IDataRow) => (
213
+ $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : (fn ? fn(d) : null)
214
+ );
215
+ },
216
+
202
217
  /**
203
218
  * Update circle color
204
219
  * @param {object} d Data object
@@ -206,10 +221,7 @@ export default {
206
221
  * @private
207
222
  */
208
223
  updateCircleColor(d: IDataRow): string | null {
209
- const $$ = this;
210
- const fn = $$.getStylePropValue($$.color);
211
-
212
- return $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : (fn ? fn(d) : null);
224
+ return this.generateUpdateCircleColor()(d);
213
225
  },
214
226
 
215
227
  redrawCircle(cx: Function, cy: Function, withTransition: boolean, flow, isSub = false) {
@@ -225,6 +237,7 @@ export default {
225
237
  const posAttr = $$.isCirclePoint() ? "c" : "";
226
238
  const t = getRandom();
227
239
  const opacityStyleFn = $$.opacityForCircle.bind($$);
240
+ const updateCircleColor = $$.generateUpdateCircleColor();
228
241
 
229
242
  // For standard circle type, batch the update across all circles in one pass
230
243
  if ($$.isCirclePoint()) {
@@ -245,14 +258,14 @@ export default {
245
258
  $T(sel.filter(function() {
246
259
  return !!this.getAttribute("cx");
247
260
  }), true, `${t}-pos`)
248
- .attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
261
+ .attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
249
262
 
250
263
  sel.filter(function() {
251
264
  return !this.getAttribute("cx");
252
265
  })
253
- .attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
266
+ .attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
254
267
  } else {
255
- sel.attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
268
+ sel.attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
256
269
  }
257
270
 
258
271
  const result = $T(sel, withTransition || !rendered, t)
@@ -264,7 +277,7 @@ export default {
264
277
  ];
265
278
  }
266
279
 
267
- const fn = $$.point("update", $$, cx, cy, $$.updateCircleColor.bind($$), withTransition,
280
+ const fn = $$.point("update", $$, cx, cy, updateCircleColor, withTransition,
268
281
  flow, selectedCircles);
269
282
  const mainCircles: any[] = [];
270
283
 
@@ -410,9 +423,10 @@ export default {
410
423
  cy = y;
411
424
  }
412
425
 
413
- return Math.sqrt(
414
- Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)
415
- ) < (r || pointSensitivity);
426
+ const dx = cx - mouse[0];
427
+ const dy = cy - mouse[1];
428
+
429
+ return Math.sqrt(dx * dx + dy * dy) < (r || pointSensitivity);
416
430
  },
417
431
 
418
432
  updatePointClass(d) {
@@ -700,8 +700,17 @@ export default {
700
700
  const areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub);
701
701
  const yScale = $$.getYScaleById.bind($$);
702
702
 
703
+ // per-series cache: y0 depends only on the id and is stable within one draw pass
704
+ const y0Cache = new Map<string, number>();
705
+
703
706
  return function(d, i) {
704
- const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
707
+ let y0 = y0Cache.get(d.id);
708
+
709
+ if (y0 === undefined) {
710
+ y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)) as number;
711
+ y0Cache.set(d.id, y0);
712
+ }
713
+
705
714
  const offset = areaOffset(d, i) || y0;
706
715
  const posX = x(d);
707
716
  const value = d.value as number;
@@ -745,12 +754,25 @@ export default {
745
754
  const barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub);
746
755
  const yScale = $$.getYScaleById.bind($$);
747
756
 
757
+ // per-series cache: y0/isInverted depend only on the id and are stable within one draw pass
758
+ const idCache = new Map<string, {y0: number, isInverted: boolean}>();
759
+
748
760
  return (d, i) => {
749
761
  const {id} = d;
750
- const y0 = yScale.call($$, id, isSub)($$.getShapeYMin(id));
762
+ let idInfo = idCache.get(id);
763
+
764
+ if (!idInfo) {
765
+ idInfo = {
766
+ y0: yScale.call($$, id, isSub)($$.getShapeYMin(id)),
767
+ isInverted: config[`axis_${$$.axis.getId(id)}_inverted`]
768
+ };
769
+
770
+ idCache.set(id, idInfo);
771
+ }
772
+
773
+ const {y0, isInverted} = idInfo;
751
774
  const offset = barOffset(d, i) || y0;
752
775
  const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
753
- const isInverted = config[`axis_${$$.axis.getId(id)}_inverted`];
754
776
  const value = d.value as number;
755
777
  const posX = barX(d);
756
778
  let posY = barY(d);