billboard.js 3.11.3 → 3.12.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 (177) hide show
  1. package/README.md +1 -5
  2. package/dist/billboard.css +13 -1
  3. package/dist/billboard.js +19672 -24210
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +26 -3
  6. package/dist/billboard.pkgd.js +24515 -30430
  7. package/dist/billboard.pkgd.min.js +33 -3
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +429 -1134
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +666 -1524
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1387 -1854
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2760 -3959
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3504 -5057
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2906 -4072
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3076 -4506
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
  28. package/dist/theme/dark.css +12 -1
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +12 -1
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +12 -1
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +12 -1
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +12 -1
  37. package/dist/theme/modern.min.css +3 -4
  38. package/dist-esm/billboard.js +9297 -8527
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +20 -27
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +155 -149
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +302 -289
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +236 -236
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +41 -43
  44. package/package.json +29 -49
  45. package/src/Chart/api/axis.ts +6 -13
  46. package/src/Chart/api/chart.ts +12 -11
  47. package/src/Chart/api/data.ts +8 -7
  48. package/src/Chart/api/export.ts +28 -21
  49. package/src/Chart/api/flow.ts +4 -2
  50. package/src/Chart/api/grid.ts +1 -5
  51. package/src/Chart/api/load.ts +2 -2
  52. package/src/Chart/api/regions.ts +29 -5
  53. package/src/Chart/api/selection.ts +2 -2
  54. package/src/Chart/api/show.ts +2 -3
  55. package/src/Chart/api/subchart.ts +2 -2
  56. package/src/Chart/api/tooltip.ts +8 -9
  57. package/src/Chart/api/x.ts +2 -2
  58. package/src/Chart/api/zoom.ts +2 -2
  59. package/src/ChartInternal/Axis/Axis.ts +119 -44
  60. package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
  61. package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
  62. package/src/ChartInternal/ChartInternal.ts +87 -55
  63. package/src/ChartInternal/data/IData.ts +31 -31
  64. package/src/ChartInternal/data/convert.helper.ts +66 -68
  65. package/src/ChartInternal/data/convert.ts +11 -11
  66. package/src/ChartInternal/data/data.ts +51 -27
  67. package/src/ChartInternal/data/load.ts +7 -6
  68. package/src/ChartInternal/interactions/drag.ts +2 -1
  69. package/src/ChartInternal/interactions/eventrect.ts +84 -32
  70. package/src/ChartInternal/interactions/flow.ts +14 -4
  71. package/src/ChartInternal/interactions/interaction.ts +51 -22
  72. package/src/ChartInternal/interactions/subchart.ts +27 -25
  73. package/src/ChartInternal/interactions/zoom.ts +29 -18
  74. package/src/ChartInternal/internals/category.ts +1 -1
  75. package/src/ChartInternal/internals/class.ts +6 -6
  76. package/src/ChartInternal/internals/clip.ts +8 -4
  77. package/src/ChartInternal/internals/color.ts +70 -42
  78. package/src/ChartInternal/internals/domain.ts +59 -28
  79. package/src/ChartInternal/internals/format.ts +5 -5
  80. package/src/ChartInternal/internals/grid.ts +131 -47
  81. package/src/ChartInternal/internals/legend.ts +93 -61
  82. package/src/ChartInternal/internals/redraw.ts +6 -2
  83. package/src/ChartInternal/internals/region.ts +5 -3
  84. package/src/ChartInternal/internals/scale.ts +28 -15
  85. package/src/ChartInternal/internals/selection.ts +14 -13
  86. package/src/ChartInternal/internals/size.axis.ts +18 -10
  87. package/src/ChartInternal/internals/size.ts +98 -67
  88. package/src/ChartInternal/internals/style.ts +21 -19
  89. package/src/ChartInternal/internals/text.ts +79 -43
  90. package/src/ChartInternal/internals/title.ts +2 -2
  91. package/src/ChartInternal/internals/tooltip.ts +78 -32
  92. package/src/ChartInternal/internals/transform.ts +4 -4
  93. package/src/ChartInternal/internals/type.ts +17 -12
  94. package/src/ChartInternal/shape/arc.ts +78 -44
  95. package/src/ChartInternal/shape/area.ts +19 -22
  96. package/src/ChartInternal/shape/bar.ts +41 -31
  97. package/src/ChartInternal/shape/bubble.ts +5 -5
  98. package/src/ChartInternal/shape/candlestick.ts +15 -13
  99. package/src/ChartInternal/shape/funnel.ts +317 -0
  100. package/src/ChartInternal/shape/gauge.ts +16 -9
  101. package/src/ChartInternal/shape/line.ts +62 -46
  102. package/src/ChartInternal/shape/point.common.ts +1 -4
  103. package/src/ChartInternal/shape/point.ts +54 -34
  104. package/src/ChartInternal/shape/polar.ts +4 -2
  105. package/src/ChartInternal/shape/radar.ts +40 -22
  106. package/src/ChartInternal/shape/shape.ts +84 -58
  107. package/src/ChartInternal/shape/treemap.ts +31 -20
  108. package/src/Plugin/bubblecompare/index.ts +1 -3
  109. package/src/Plugin/sparkline/index.ts +3 -4
  110. package/src/Plugin/stanford/ColorScale.ts +3 -2
  111. package/src/Plugin/stanford/Elements.ts +15 -6
  112. package/src/Plugin/stanford/Options.ts +5 -5
  113. package/src/Plugin/stanford/index.ts +13 -9
  114. package/src/Plugin/tableview/Options.ts +1 -1
  115. package/src/Plugin/tableview/const.ts +1 -4
  116. package/src/Plugin/tableview/index.ts +11 -9
  117. package/src/Plugin/textoverlap/index.ts +4 -6
  118. package/src/config/Options/Options.ts +3 -3
  119. package/src/config/Options/axis/axis.ts +36 -0
  120. package/src/config/Options/axis/x.ts +34 -14
  121. package/src/config/Options/axis/y.ts +13 -13
  122. package/src/config/Options/axis/y2.ts +23 -10
  123. package/src/config/Options/common/color.ts +4 -4
  124. package/src/config/Options/common/grid.ts +4 -4
  125. package/src/config/Options/common/legend.ts +12 -13
  126. package/src/config/Options/common/main.ts +23 -23
  127. package/src/config/Options/common/point.ts +17 -18
  128. package/src/config/Options/common/title.ts +2 -2
  129. package/src/config/Options/common/tooltip.ts +13 -11
  130. package/src/config/Options/data/axis.ts +2 -2
  131. package/src/config/Options/data/data.ts +48 -45
  132. package/src/config/Options/interaction/interaction.ts +1 -1
  133. package/src/config/Options/interaction/subchart.ts +2 -2
  134. package/src/config/Options/interaction/zoom.ts +9 -9
  135. package/src/config/Options/shape/arc.ts +10 -13
  136. package/src/config/Options/shape/area.ts +5 -7
  137. package/src/config/Options/shape/bar.ts +8 -10
  138. package/src/config/Options/shape/bubble.ts +1 -1
  139. package/src/config/Options/shape/candlestick.ts +2 -2
  140. package/src/config/Options/shape/donut.ts +4 -4
  141. package/src/config/Options/shape/funnel.ts +38 -0
  142. package/src/config/Options/shape/gauge.ts +6 -6
  143. package/src/config/Options/shape/line.ts +3 -3
  144. package/src/config/Options/shape/pie.ts +5 -5
  145. package/src/config/Options/shape/polar.ts +3 -3
  146. package/src/config/Options/shape/radar.ts +2 -2
  147. package/src/config/Options/shape/scatter.ts +1 -1
  148. package/src/config/Options/shape/treemap.ts +1 -1
  149. package/src/config/Store/Element.ts +8 -5
  150. package/src/config/Store/State.ts +20 -13
  151. package/src/config/classes.ts +14 -4
  152. package/src/config/config.ts +1 -1
  153. package/src/config/const.ts +2 -0
  154. package/src/config/resolver/axis.ts +4 -4
  155. package/src/config/resolver/interaction.ts +3 -7
  156. package/src/config/resolver/shape.ts +17 -12
  157. package/src/core.ts +2 -3
  158. package/src/index.esm.ts +3 -6
  159. package/src/index.ts +2 -2
  160. package/src/module/Cache.ts +2 -3
  161. package/src/module/browser.ts +15 -10
  162. package/src/module/error.ts +9 -8
  163. package/src/module/generator.ts +3 -5
  164. package/src/module/util.ts +62 -39
  165. package/src/module/worker.ts +14 -11
  166. package/src/scss/billboard.scss +18 -0
  167. package/src/scss/theme/dark.scss +17 -0
  168. package/src/scss/theme/datalab.scss +17 -0
  169. package/src/scss/theme/graph.scss +17 -0
  170. package/src/scss/theme/insight.scss +17 -0
  171. package/src/scss/theme/modern.scss +17 -0
  172. package/types/axis.d.ts +17 -0
  173. package/types/bb.d.ts +1 -0
  174. package/types/index.d.ts +1 -0
  175. package/types/options.d.ts +9 -0
  176. package/types/options.shape.d.ts +26 -1
  177. package/types/types.d.ts +1 -0
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {select as d3Select} from "d3-selection";
6
5
  import {drag as d3Drag} from "d3-drag";
7
- import {$ARC, $AXIS, $COMMON, $SHAPE, $TREEMAP} from "../../config/classes";
6
+ import {select as d3Select} from "d3-selection";
7
+ import {$ARC, $AXIS, $COMMON, $SHAPE} from "../../config/classes";
8
8
  import {KEY} from "../../module/Cache";
9
9
  import {emulateEvent, getPointer, isNumber, isObject} from "../../module/util";
10
10
  import type {IArcDataRow} from "../data/IData";
@@ -55,19 +55,22 @@ export default {
55
55
  */
56
56
  setOverOut(isOver: boolean, d: number | IArcDataRow): void {
57
57
  const $$ = this;
58
- const {config, state: {hasRadar, hasTreemap}, $el: {main}} = $$;
59
- const isArcTreemap = isObject(d);
58
+ const {config, state: {hasFunnel, hasRadar, hasTreemap}, $el: {main}} = $$;
59
+ const isArcishData = isObject(d);
60
60
 
61
61
  // Call event handler
62
- if (isArcTreemap || d !== -1) {
62
+ if (isArcishData || d !== -1) {
63
63
  const callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
64
64
 
65
- config.color_onover && $$.setOverColor(isOver, d, isArcTreemap);
65
+ config.color_onover && $$.setOverColor(isOver, d, isArcishData);
66
66
 
67
- if (isArcTreemap && "id") {
68
- const selector = hasTreemap ? $TREEMAP.treemap : $ARC.arc;
67
+ if (isArcishData && "id") {
68
+ const suffix = $$.getTargetSelectorSuffix((d as IArcDataRow).id);
69
+ const selector = hasFunnel || hasTreemap ?
70
+ `${$COMMON.target + suffix} .${$SHAPE.shape}` :
71
+ $ARC.arc + suffix;
69
72
 
70
- callback(d, main.select(`.${selector}${$$.getTargetSelectorSuffix((d as IArcDataRow).id)}`).node());
73
+ callback(d, main.select(`.${selector}`).node());
71
74
  } else if (!config.tooltip_grouped) {
72
75
  const last = $$.cache.get(KEY.setOverOut) || [];
73
76
 
@@ -83,9 +86,11 @@ export default {
83
86
  });
84
87
 
85
88
  // call onout callback
86
- if (!isOver || shapesAtIndex.empty() || (
87
- last.length === shape.size() && shape.nodes().every(((v, i) => v !== last[i]))
88
- )) {
89
+ if (
90
+ !isOver || shapesAtIndex.empty() || (
91
+ last.length === shape.size() && shape.nodes().every((v, i) => v !== last[i])
92
+ )
93
+ ) {
89
94
  while (last.length) {
90
95
  const target = last.pop();
91
96
 
@@ -156,7 +161,8 @@ export default {
156
161
  .on("end", event => {
157
162
  state.event = event;
158
163
  $$.dragend();
159
- }) : () => {};
164
+ }) :
165
+ () => {};
160
166
  },
161
167
 
162
168
  /**
@@ -168,11 +174,19 @@ export default {
168
174
  */
169
175
  dispatchEvent(type: string, index: number, mouse: [number, number]): void {
170
176
  const $$ = this;
171
- const {config, state: {
172
- eventReceiver, hasAxis, hasRadar, hasTreemap
173
- }, $el: {eventRect, radar, treemap}} = $$;
174
- const element = (
175
- (hasTreemap && eventReceiver.rect) ||
177
+ const {
178
+ config,
179
+ state: {
180
+ eventReceiver,
181
+ hasAxis,
182
+ hasFunnel,
183
+ hasRadar,
184
+ hasTreemap
185
+ },
186
+ $el: {eventRect, funnel, radar, treemap}
187
+ } = $$;
188
+ let element = (
189
+ ((hasFunnel || hasTreemap) && eventReceiver.rect) ||
176
190
  (hasRadar && radar.axes.select(`.${$AXIS.axis}-${index} text`)) || (
177
191
  eventRect || $$.getArcElementByIdOrIndex?.(index)
178
192
  )
@@ -211,9 +225,16 @@ export default {
211
225
  bubbles: hasRadar // radar type needs to bubble up event
212
226
  };
213
227
 
228
+ // for funnel and treemap event bound to <g> node
229
+ if (hasFunnel || hasTreemap) {
230
+ element = (funnel ?? treemap).node();
231
+ }
232
+
214
233
  emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](
215
- hasTreemap ? treemap.node() : element,
216
- type, params);
234
+ element,
235
+ type,
236
+ params
237
+ );
217
238
  }
218
239
  },
219
240
 
@@ -239,7 +260,7 @@ export default {
239
260
  * Unbind all attached events
240
261
  * @private
241
262
  */
242
- unbindAllEvents(): void {
263
+ unbindAllEvents(): void {
243
264
  const $$ = this;
244
265
  const {$el: {arcs, eventRect, legend, region, svg, treemap}, brush} = $$;
245
266
  const list = [
@@ -262,7 +283,15 @@ export default {
262
283
  ].join(" ");
263
284
 
264
285
  // detach all possible event types
265
- [svg, eventRect, region?.list, brush?.getSelection(), arcs?.selectAll("path"), legend?.selectAll("g"), treemap]
286
+ [
287
+ svg,
288
+ eventRect,
289
+ region?.list,
290
+ brush?.getSelection(),
291
+ arcs?.selectAll("path"),
292
+ legend?.selectAll("g"),
293
+ treemap
294
+ ]
266
295
  .forEach(v => v?.on(list, null));
267
296
 
268
297
  $$.unbindZoomEvent?.();
@@ -2,12 +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 {brushSelection as d3BrushSelection, brushX as d3BrushX, brushY as d3BrushY} from "d3-brush";
5
6
  import {select as d3Select} from "d3-selection";
6
- import {
7
- brushX as d3BrushX,
8
- brushY as d3BrushY,
9
- brushSelection as d3BrushSelection
10
- } from "d3-brush";
11
7
  import CLASS from "../../config/classes";
12
8
  import {brushEmpty, capitalize, isArray, isFunction, parseDate} from "../../module/util";
13
9
 
@@ -44,11 +40,12 @@ export default {
44
40
  if (/(start|brush)/.test(type)) {
45
41
  // when brush selection updates happens on one edge, update only chainging edge and
46
42
  // is only for adjustment of given domain range to be used to return current domain range.
47
- type === "brush" && sourceEvent && state.domain && lastSelection?.forEach((v, i) => {
48
- if (v !== selection[i]) {
49
- state.domain[i] = scale.x.orgDomain()[i];
50
- }
51
- });
43
+ type === "brush" && sourceEvent && state.domain &&
44
+ lastSelection?.forEach((v, i) => {
45
+ if (v !== selection[i]) {
46
+ state.domain[i] = scale.x.orgDomain()[i];
47
+ }
48
+ });
52
49
 
53
50
  $$.redrawForBrush(type !== "start");
54
51
  }
@@ -198,19 +195,18 @@ export default {
198
195
  const customHandleClass = "handle--custom";
199
196
 
200
197
  // brush handle shape's path
201
- const path = isRotated ? [
202
- "M8.5 0 a6 6 0 0 0 -6 -6.5 H-2.5 a 6 6 0 0 0 -6 6.5 z m-5 -2 H-3.5 m7 -2 H-3.5z",
203
- "M8.5 0 a6 -6 0 0 1 -6 6.5 H-2.5 a 6 -6 0 0 1 -6 -6.5z m-5 2 H-3.5 m7 2 H-3.5z"
204
- ] : [
205
- "M0 -8.5 A6 6 0 0 0 -6.5 -3.5 V2.5 A6 6 0 0 0 0 8.5 Z M-2 -3.5 V3.5 M-4 -3.5 V3.5z",
206
- "M0 -8.5 A6 6 0 0 1 6.5 -3.5 V2.5 A6 6 0 0 1 0 8.5 Z M2 -3.5 V3.5 M4 -3.5 V3.5z"
207
- ];
198
+ const path = isRotated ?
199
+ [
200
+ "M8.5 0 a6 6 0 0 0 -6 -6.5 H-2.5 a 6 6 0 0 0 -6 6.5 z m-5 -2 H-3.5 m7 -2 H-3.5z",
201
+ "M8.5 0 a6 -6 0 0 1 -6 6.5 H-2.5 a 6 -6 0 0 1 -6 -6.5z m-5 2 H-3.5 m7 2 H-3.5z"
202
+ ] :
203
+ [
204
+ "M0 -8.5 A6 6 0 0 0 -6.5 -3.5 V2.5 A6 6 0 0 0 0 8.5 Z M-2 -3.5 V3.5 M-4 -3.5 V3.5z",
205
+ "M0 -8.5 A6 6 0 0 1 6.5 -3.5 V2.5 A6 6 0 0 1 0 8.5 Z M2 -3.5 V3.5 M4 -3.5 V3.5z"
206
+ ];
208
207
 
209
208
  $$.brush.handle = brush.selectAll(`.${customHandleClass}`)
210
- .data(isRotated ?
211
- [{type: "n"}, {type: "s"}] :
212
- [{type: "w"}, {type: "e"}]
213
- )
209
+ .data(isRotated ? [{type: "n"}, {type: "s"}] : [{type: "w"}, {type: "e"}])
214
210
  .enter()
215
211
  .append("path")
216
212
  .attr("class", customHandleClass)
@@ -271,7 +267,8 @@ export default {
271
267
 
272
268
  // -- Brush --//
273
269
  main.selectAll(`.${CLASS.brush} rect`)
274
- .attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? state.width2 : state.height2);
270
+ .attr(config.axis_rotated ? "width" : "height",
271
+ config.axis_rotated ? state.width2 : state.height2);
275
272
  }
276
273
  },
277
274
 
@@ -339,9 +336,14 @@ export default {
339
336
  */
340
337
  redrawForBrush(callCallbck = true): void {
341
338
  const $$ = this;
342
- const {config: {
343
- subchart_onbrush: onBrush, zoom_rescale: withY
344
- }, scale, state} = $$;
339
+ const {
340
+ config: {
341
+ subchart_onbrush: onBrush,
342
+ zoom_rescale: withY
343
+ },
344
+ scale,
345
+ state
346
+ } = $$;
345
347
 
346
348
  $$.redraw({
347
349
  withTransition: false,
@@ -3,7 +3,11 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {drag as d3Drag} from "d3-drag";
6
- import {zoomIdentity as d3ZoomIdentity, zoom as d3Zoom, zoomTransform as d3ZoomTransform} from "d3-zoom";
6
+ import {
7
+ zoom as d3Zoom,
8
+ zoomIdentity as d3ZoomIdentity,
9
+ zoomTransform as d3ZoomTransform
10
+ } from "d3-zoom";
7
11
  import {$COMMON, $ZOOM} from "../../config/classes";
8
12
  import {callFn, diffDomain, getPointer, isFunction} from "../../module/util";
9
13
 
@@ -79,7 +83,8 @@ export default {
79
83
  * @private
80
84
  */
81
85
  // @ts-ignore
82
- zoom.updateTransformScale = (transform: d3ZoomTransform, correctTransform: boolean): void => {
86
+ zoom.updateTransformScale = (transform: d3ZoomTransform,
87
+ correctTransform: boolean): void => {
83
88
  const isRotated = config.axis_rotated;
84
89
 
85
90
  // in case of resize, update range of orgXScale
@@ -102,7 +107,8 @@ export default {
102
107
  const tX = isRotated ? transform.x : t;
103
108
  const tY = isRotated ? t : transform.y;
104
109
 
105
- $$.$el.eventRect.property("__zoom", d3ZoomIdentity.translate(tX, tY).scale(transform.k));
110
+ $$.$el.eventRect.property("__zoom",
111
+ d3ZoomIdentity.translate(tX, tY).scale(transform.k));
106
112
  }
107
113
 
108
114
  if (!$$.state.xTickOffset) {
@@ -172,7 +178,8 @@ export default {
172
178
  if (
173
179
  !config.zoom_enabled ||
174
180
  $$.filterTargetsToShow($$.data.targets).length === 0 ||
175
- (!scale.zoom && sourceEvent?.type.indexOf("touch") > -1 && sourceEvent?.touches.length === 1)
181
+ (!scale.zoom && sourceEvent?.type.indexOf("touch") > -1 &&
182
+ sourceEvent?.touches.length === 1)
176
183
  ) {
177
184
  return;
178
185
  }
@@ -197,8 +204,8 @@ export default {
197
204
  // - when .unzoom() is called (event.transform === d3ZoomIdentity)
198
205
  const doTransition = config.transition_duration > 0 &&
199
206
  !config.subchart_show && (
200
- state.dragging || isUnZoom || !event.sourceEvent
201
- );
207
+ state.dragging || isUnZoom || !event.sourceEvent
208
+ );
202
209
 
203
210
  $$.redraw({
204
211
  withTransition: doTransition,
@@ -236,9 +243,11 @@ export default {
236
243
  }
237
244
 
238
245
  // if click, do nothing. otherwise, click interaction will be canceled.
239
- if (config.zoom_type === "drag" && (
240
- e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY
241
- )) {
246
+ if (
247
+ config.zoom_type === "drag" && (
248
+ e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY
249
+ )
250
+ ) {
242
251
  return;
243
252
  }
244
253
 
@@ -268,15 +277,17 @@ export default {
268
277
  const xDomain = subX.domain();
269
278
  const delta = 0.015; // arbitrary value
270
279
 
271
- const isfullyShown = $$.config.axis_x_inverted ? (
272
- zoomDomain[0] >= xDomain[0] || (zoomDomain[0] + delta) >= xDomain[0]
273
- ) && (
274
- xDomain[1] >= zoomDomain[1] || xDomain[1] >= (zoomDomain[1] + delta)
275
- ) : (
276
- zoomDomain[0] <= xDomain[0] || (zoomDomain[0] - delta) <= xDomain[0]
277
- ) && (
278
- xDomain[1] <= zoomDomain[1] || xDomain[1] <= (zoomDomain[1] - delta)
279
- );
280
+ const isfullyShown = $$.config.axis_x_inverted ?
281
+ (
282
+ zoomDomain[0] >= xDomain[0] || (zoomDomain[0] + delta) >= xDomain[0]
283
+ ) && (
284
+ xDomain[1] >= zoomDomain[1] || xDomain[1] >= (zoomDomain[1] + delta)
285
+ ) :
286
+ (
287
+ zoomDomain[0] <= xDomain[0] || (zoomDomain[0] - delta) <= xDomain[0]
288
+ ) && (
289
+ xDomain[1] <= zoomDomain[1] || xDomain[1] <= (zoomDomain[1] - delta)
290
+ );
280
291
 
281
292
  // check if the zoomed chart is fully shown, then reset scale when zoom is out as initial
282
293
  if (force || isfullyShown) {
@@ -13,5 +13,5 @@ export default {
13
13
  const {axis_x_categories} = this.config;
14
14
 
15
15
  return axis_x_categories?.[i] ?? i;
16
- },
16
+ }
17
17
  };
@@ -18,7 +18,7 @@ export default {
18
18
  */
19
19
  getClass(type: string, withShape: boolean): Function {
20
20
  const isPlural = /s$/.test(type);
21
- const useIdKey = /^(area|arc|line|treemap)s?$/.test(type);
21
+ const useIdKey = /^(area|arc|line|funnel|treemap)s?$/.test(type);
22
22
  const key = isPlural ? "id" : "index";
23
23
 
24
24
  return (d): string => {
@@ -94,14 +94,15 @@ export default {
94
94
  const target = this.getTargetSelectorSuffix(id);
95
95
 
96
96
  // select target & circle
97
- return `${prefix}.${CLASS.target + target} ${postfix}, ${prefix}.${CLASS.circles + target} ${postfix}`;
97
+ return `${prefix}.${CLASS.target + target} ${postfix}, ${prefix}.${
98
+ CLASS.circles + target
99
+ } ${postfix}`;
98
100
  },
99
101
 
100
102
  selectorTargets(idsValue, prefix: string): string[] | null {
101
103
  const ids = idsValue || [];
102
104
 
103
- return ids.length ?
104
- ids.map(id => this.selectorTarget(id, prefix)) : null;
105
+ return ids.length ? ids.map(id => this.selectorTarget(id, prefix)) : null;
105
106
  },
106
107
 
107
108
  selectorLegend(id: string): string {
@@ -109,7 +110,6 @@ export default {
109
110
  },
110
111
 
111
112
  selectorLegends(ids): string[] | null {
112
- return ids?.length ?
113
- ids.map(id => this.selectorLegend(id)) : null;
113
+ return ids?.length ? ids.map(id => this.selectorLegend(id)) : null;
114
114
  }
115
115
  };
@@ -26,9 +26,11 @@ export default {
26
26
  const $$ = this;
27
27
  const {config} = $$;
28
28
 
29
- if ((!config.clipPath && /-clip$/.test(id)) ||
29
+ if (
30
+ (!config.clipPath && /-clip$/.test(id)) ||
30
31
  (!config.axis_x_clipPath && /-clip-xaxis$/.test(id)) ||
31
- (!config.axis_y_clipPath && /-clip-yaxis$/.test(id))) {
32
+ (!config.axis_y_clipPath && /-clip-yaxis$/.test(id))
33
+ ) {
32
34
  return null;
33
35
  }
34
36
 
@@ -78,7 +80,8 @@ export default {
78
80
  const left = Math.max(30, margin.left) - (isRotated ? 20 : 0);
79
81
  const isInner = config.axis_y_inner;
80
82
 
81
- const x = isInner && !isRotated ? (config.axis_y_label.text ? -20 : -1) :
83
+ const x = isInner && !isRotated ?
84
+ (config.axis_y_label.text ? -20 : -1) :
82
85
  (isRotated ? -(1 + left) : -(left - 1));
83
86
  const y = -(isRotated ? 20 : margin.top);
84
87
  const w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0);
@@ -104,7 +107,8 @@ export default {
104
107
  clip.idXAxisTickTexts = clipId;
105
108
  }
106
109
 
107
- if (!config.axis_x_tick_multiline &&
110
+ if (
111
+ !config.axis_x_tick_multiline &&
108
112
  $$.getAxisTickRotate("x") &&
109
113
  newXAxisHeight !== xAxisHeight
110
114
  ) {
@@ -2,14 +2,14 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {select as d3Select} from "d3-selection";
6
5
  import {scaleOrdinal as d3ScaleOrdinal} from "d3-scale";
7
- import {document} from "../../module/browser";
6
+ import {select as d3Select} from "d3-selection";
7
+ import {d3Selection} from "../../../types";
8
8
  import {$ARC, $COLOR, $SHAPE} from "../../config/classes";
9
+ import {document} from "../../module/browser";
9
10
  import {KEY} from "../../module/Cache";
10
- import {notEmpty, isFunction, isObject, isString} from "../../module/util";
11
+ import {isFunction, isObject, isString, notEmpty} from "../../module/util";
11
12
  import type {IArcData, IDataRow} from "../data/IData";
12
- import {d3Selection} from "../../../types";
13
13
 
14
14
  /**
15
15
  * Set pattern's background color
@@ -72,7 +72,18 @@ function getColorFromCss(element: d3Selection): string[] {
72
72
 
73
73
  // Replacement of d3.schemeCategory10.
74
74
  // Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
75
- const schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
75
+ const schemeCategory10 = [
76
+ "#1f77b4",
77
+ "#ff7f0e",
78
+ "#2ca02c",
79
+ "#d62728",
80
+ "#9467bd",
81
+ "#8c564b",
82
+ "#e377c2",
83
+ "#7f7f7f",
84
+ "#bcbd22",
85
+ "#17becf"
86
+ ];
76
87
 
77
88
  export default {
78
89
  generateColor(): Function {
@@ -82,7 +93,8 @@ export default {
82
93
  const callback = config.data_color;
83
94
  const ids: string[] = [];
84
95
 
85
- let pattern = notEmpty(config.color_pattern) ? config.color_pattern :
96
+ let pattern = notEmpty(config.color_pattern) ?
97
+ config.color_pattern :
86
98
  d3ScaleOrdinal(getColorFromCss($el.chart) || schemeCategory10).range();
87
99
 
88
100
  const originalColorPattern = pattern;
@@ -114,24 +126,24 @@ export default {
114
126
  if (isFunction(colors[id])) {
115
127
  color = colors[id].bind($$.api)(d);
116
128
 
117
- // if specified, choose that color
129
+ // if specified, choose that color
118
130
  } else if (colors[id]) {
119
131
  color = colors[id];
120
132
 
121
- // if not specified, choose from pattern
133
+ // if not specified, choose from pattern
122
134
  } else {
123
135
  if (ids.indexOf(id) < 0) {
124
136
  ids.push(id);
125
137
  }
126
138
 
127
- color = isLine ? originalColorPattern[ids.indexOf(id) % originalColorPattern.length] :
139
+ color = isLine ?
140
+ originalColorPattern[ids.indexOf(id) % originalColorPattern.length] :
128
141
  pattern[ids.indexOf(id) % pattern.length];
129
142
 
130
143
  colors[id] = color;
131
144
  }
132
145
 
133
- return isFunction(callback) ?
134
- callback.bind($$.api)(color, d) : color;
146
+ return isFunction(callback) ? callback.bind($$.api)(color, d) : color;
135
147
  };
136
148
  },
137
149
 
@@ -143,52 +155,66 @@ export default {
143
155
  const asValue = threshold.unit === "value";
144
156
  const max = threshold.max || 100;
145
157
  const values = threshold.values &&
146
- threshold.values.length ? threshold.values : [];
147
-
148
- return notEmpty(threshold) ? function(value) {
149
- const v = asValue ? value : (value * 100 / max);
150
- let color = colors[colors.length - 1];
151
-
152
- for (let i = 0, l = values.length; i < l; i++) {
153
- if (v <= values[i]) {
154
- color = colors[i];
155
- break;
158
+ threshold.values.length ?
159
+ threshold.values :
160
+ [];
161
+
162
+ return notEmpty(threshold) ?
163
+ function(value) {
164
+ const v = asValue ? value : (value * 100 / max);
165
+ let color = colors[colors.length - 1];
166
+
167
+ for (let i = 0, l = values.length; i < l; i++) {
168
+ if (v <= values[i]) {
169
+ color = colors[i];
170
+ break;
171
+ }
156
172
  }
157
- }
158
173
 
159
- return color;
160
- } : null;
174
+ return color;
175
+ } :
176
+ null;
161
177
  },
162
178
 
163
179
  /**
164
180
  * Append data backgound color filter definition
165
- * @param {string} color Color string
181
+ * @param {string|object} color Color string
182
+ * @param {object} attr filter attribute
166
183
  * @private
167
184
  */
168
- generateDataLabelBackgroundColorFilter(color?: string): void {
185
+ generateTextBGColorFilter(color: string | object, attr = {
186
+ x: 0,
187
+ y: 0,
188
+ width: 1,
189
+ height: 1
190
+ }): void {
169
191
  const $$ = this;
170
- const {$el, config, state} = $$;
171
- const backgroundColors = color || config.data_labels_backgroundColors;
192
+ const {$el, state} = $$;
172
193
 
173
- if (backgroundColors) {
194
+ if (color) {
174
195
  let ids: string[] = [];
175
196
 
176
- if (isString(backgroundColors)) {
197
+ if (isString(color)) {
177
198
  ids.push("");
178
- } else if (isObject(backgroundColors)) {
179
- ids = Object.keys(backgroundColors);
199
+ } else if (isObject(color)) {
200
+ ids = Object.keys(color);
180
201
  }
181
202
 
182
203
  ids.forEach(v => {
183
- const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${color ? $$.getTargetSelectorSuffix(color) : ""}`;
204
+ const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${
205
+ isString(color) ? $$.getTargetSelectorSuffix(color) : ""
206
+ }`;
184
207
 
185
208
  $el.defs.append("filter")
186
- .attr("x", "0")
187
- .attr("y", "0")
188
- .attr("width", "1")
189
- .attr("height", "1")
209
+ .attr("x", attr.x)
210
+ .attr("y", attr.y)
211
+ .attr("width", attr.width)
212
+ .attr("height", attr.height)
190
213
  .attr("id", id)
191
- .html(`<feFlood flood-color="${v === "" ? backgroundColors : backgroundColors[v]}" /><feComposite in="SourceGraphic"/>`);
214
+ .html(
215
+ `<feFlood flood-color="${v === "" ? color : color[v]}" />
216
+ <feComposite in="SourceGraphic" />`
217
+ );
192
218
  });
193
219
  }
194
220
  },
@@ -221,8 +247,8 @@ export default {
221
247
  if ((radialGradient || supportedType) && defs.select(`#${id}`).empty()) {
222
248
  const color = $$.color(d);
223
249
  const gradient = {
224
- defs: <null|d3Selection>null,
225
- stops: <[number, string|Function|null, number][]>[]
250
+ defs: <null | d3Selection>null,
251
+ stops: <[number, string | Function | null, number][]>[]
226
252
  };
227
253
 
228
254
  if (radialGradient) {
@@ -256,9 +282,11 @@ export default {
256
282
  .attr("y2", y[1]);
257
283
  }
258
284
 
259
- gradient.stops.forEach((v: [number, string|Function|null, number]) => {
285
+ gradient.stops.forEach((v: [number, string | Function | null, number]) => {
260
286
  const [offset, stopColor, stopOpacity] = v;
261
- const colorValue = isFunction(stopColor) ? stopColor.bind($$.api)(d.id) : stopColor;
287
+ const colorValue = isFunction(stopColor) ?
288
+ stopColor.bind($$.api)(d.id) :
289
+ stopColor;
262
290
 
263
291
  gradient.defs && gradient.defs.append("stop")
264
292
  .attr("offset", offset)