billboard.js 3.12.1 → 3.12.2-patch

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 (48) hide show
  1. package/README.md +1 -1
  2. package/dist/billboard.css +1 -1
  3. package/dist/billboard.js +46 -27
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +9 -9
  6. package/dist/billboard.pkgd.js +46 -27
  7. package/dist/billboard.pkgd.min.js +16 -16
  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.js +3 -3
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +3 -3
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +3 -3
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +3 -3
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +3 -3
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +5 -5
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3 -3
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +6 -6
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +3 -3
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3 -3
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
  28. package/dist/theme/dark.css +1 -1
  29. package/dist/theme/dark.min.css +1 -1
  30. package/dist/theme/datalab.css +1 -1
  31. package/dist/theme/datalab.min.css +1 -1
  32. package/dist/theme/graph.css +1 -1
  33. package/dist/theme/graph.min.css +1 -1
  34. package/dist/theme/insight.css +1 -1
  35. package/dist/theme/insight.min.css +1 -1
  36. package/dist/theme/modern.css +1 -1
  37. package/dist/theme/modern.min.css +1 -1
  38. package/dist-esm/billboard.js +56 -32
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  44. package/package.json +12 -12
  45. package/src/ChartInternal/data/load.ts +3 -0
  46. package/src/ChartInternal/interactions/zoom.ts +0 -4
  47. package/src/ChartInternal/shape/funnel.ts +49 -25
  48. package/src/module/util.ts +2 -2
@@ -30,15 +30,19 @@ function getSize(checkNeck = false): TSize {
30
30
 
31
31
  // determine if container width to not be less than neck width
32
32
  if (checkNeck) {
33
- const {width: neckWidth} = getNecklSize.call($$, {
33
+ const {width: neckWidth, height: neckHeight} = getNecklSize.call($$, {
34
34
  width: size.width,
35
35
  height: size.height
36
36
  });
37
37
 
38
- // prevent funnel width from being less than neck width
38
+ // prevent neck size to not exceeed funnel size
39
39
  if (size.width < neckWidth) {
40
40
  size.width = neckWidth;
41
41
  }
42
+
43
+ if (size.height < neckHeight) {
44
+ size.height = neckHeight;
45
+ }
42
46
  }
43
47
 
44
48
  return size;
@@ -80,7 +84,7 @@ function getNecklSize(current: TSizeCurrent) {
80
84
  */
81
85
  function getCoord(d: IFunnelData[]) {
82
86
  const $$ = this;
83
- const {top, width} = getSize.call($$, true);
87
+ const {top, left, width} = getSize.call($$, true);
84
88
  const coords: number[][][] = [];
85
89
 
86
90
  d.forEach((d, i) => {
@@ -93,11 +97,11 @@ function getCoord(d: IFunnelData[]) {
93
97
  // | ˅
94
98
  // (3) <-------------- (2)
95
99
  coords.push(d.coords = [
96
- [0, y], // M
97
- [width, y], // 1
98
- [width, i > 0 ? ratio + y : ratio + top], // 2
99
- [0, i > 0 ? ratio + y : ratio + top], // 3
100
- [0, y] // 4
100
+ [left, y], // M
101
+ [left + width, y], // 1
102
+ [left + width, i > 0 ? ratio + y : ratio + top], // 2
103
+ [left, i > 0 ? ratio + y : ratio + top], // 3
104
+ [left, y] // 4
101
105
  ]);
102
106
  });
103
107
 
@@ -105,29 +109,36 @@ function getCoord(d: IFunnelData[]) {
105
109
  }
106
110
 
107
111
  /**
108
- * Get neck path
112
+ * Get clip path
113
+ * @param {boolean} forBackground Determine if clip path for background
109
114
  * @returns {string} path
110
115
  * @private
111
116
  */
112
- function getNeckPath() {
117
+ function getClipPath(forBackground = false): string {
113
118
  const $$ = this;
114
119
  const {width, height, top, left} = getSize.call($$, true);
115
120
  const neck = getNecklSize.call($$, {width, height});
116
-
117
- const rightX = (width + neck.width) / 2;
118
121
  const leftX = (width - neck.width) / 2;
122
+ const rightX = (width + neck.width) / 2;
119
123
  const bodyHeigth = height - neck.height;
120
124
 
121
125
  const coords = [
122
- [0 + left, 0 + top], // M
123
- [width + left, 0 + top], // 1
126
+ [0, 0], // M
127
+ [width, 0], // 1
124
128
  [rightX, bodyHeigth], // 2
125
- [rightX, height + top], // 3
126
- [leftX, height + top], // 4
129
+ [rightX, height], // 3
130
+ [leftX, height], // 4
127
131
  [leftX, bodyHeigth], // 5
128
- [0 + left, 0 + top] // 6
132
+ [0, 0] // 6
129
133
  ];
130
134
 
135
+ if (forBackground) {
136
+ coords.forEach(d => {
137
+ d[0] += left;
138
+ d[1] += top;
139
+ });
140
+ }
141
+
131
142
  return `M${coords.join("L")}z`;
132
143
  }
133
144
 
@@ -158,7 +169,7 @@ function getFunnelData(d: IData[]): IFunnelData[] {
158
169
  * @returns {Array} Updated data object
159
170
  * @private
160
171
  */
161
- function updateRatio(data) {
172
+ function updateRatio(data: IFunnelData[]): IFunnelData[] {
162
173
  const $$ = this;
163
174
  const {height} = getSize.call($$);
164
175
  const total = $$.getTotalDataSum(true);
@@ -270,6 +281,19 @@ export default {
270
281
  .style("fill", $$.color);
271
282
  },
272
283
 
284
+ /**
285
+ * Update funnel path selection
286
+ * @param {object} targets Updated target data
287
+ * @private
288
+ */
289
+ updateFunnel(targets: IData[]): void {
290
+ const $$ = this;
291
+ const {$el: {funnel}} = $$;
292
+ const targetIds = targets.map(({id}) => id);
293
+
294
+ funnel.path = funnel.path.filter(d => targetIds.indexOf(d.id) >= 0);
295
+ },
296
+
273
297
  /**
274
298
  * Generate treemap coordinate points data
275
299
  * @returns {Array} Array of coordinate points
@@ -279,13 +303,15 @@ export default {
279
303
  const $$ = this;
280
304
  const {$el: {funnel}} = $$;
281
305
  const targets = $$.filterTargetsToShow(funnel.path);
306
+ const {top, left, right} = getSize.call($$);
307
+ const center = (left - right) / 2;
282
308
  const points = {};
283
- let accumulatedHeight = getSize.call($$).top ?? 0;
309
+ let accumulatedHeight = top ?? 0;
284
310
 
285
311
  targets.each((d, i) => {
286
312
  points[d.id] = [
287
- [0, accumulatedHeight],
288
- [0, accumulatedHeight += (targets?.[i] ?? d).ratio]
313
+ [center, accumulatedHeight],
314
+ [center, accumulatedHeight += (targets?.[i] ?? d).ratio]
289
315
  ];
290
316
  });
291
317
 
@@ -303,10 +329,8 @@ export default {
303
329
  const coords = getCoord.call($$, updateRatio.call($$, targets.data()));
304
330
 
305
331
  // set neck path
306
- const neckPath = getNeckPath.bind($$)();
307
-
308
- funnel.attr("clip-path", `path('${neckPath}')`);
309
- funnel.background.attr("d", neckPath);
332
+ funnel.attr("clip-path", `path('${getClipPath.bind($$)()}')`);
333
+ funnel.background.attr("d", getClipPath.call($$, true));
310
334
 
311
335
  $T(targets)
312
336
  .attr("d", (d, i) => `M${coords[i].join("L")}z`)
@@ -835,8 +835,8 @@ function convertInputType(mouse: boolean, touch: boolean): "mouse" | "touch" | n
835
835
  // Check if agent has mouse using any-hover, touch devices (e.g iPad) with external mouse will return true as long as mouse is connected
836
836
  // https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
837
837
  // Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
838
- const hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"]
839
- .some(v => matchMedia?.(`(${v})`).matches);
838
+ const hasMouse = mouse &&
839
+ (matchMedia?.("any-hover:hover").matches || matchMedia?.("any-pointer:fine").matches);
840
840
 
841
841
  // fallback to 'mouse' if no input type is detected.
842
842
  return (hasMouse && "mouse") || (hasTouch && "touch") || "mouse";