billboard.js 3.12.0 → 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.
- package/README.md +1 -1
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +57 -35
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +9 -9
- package/dist/billboard.pkgd.js +224 -202
- package/dist/billboard.pkgd.min.js +16 -16
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +3 -3
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +3 -3
- package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-textoverlap.js +3 -3
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +5 -5
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +6 -6
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/billboard.js +72 -39
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +12 -12
- package/src/ChartInternal/data/load.ts +3 -0
- package/src/ChartInternal/interactions/zoom.ts +0 -4
- package/src/ChartInternal/shape/funnel.ts +49 -25
- package/src/ChartInternal/shape/treemap.ts +19 -10
- package/src/module/util.ts +2 -2
- package/types/types.d.ts +1 -0
|
@@ -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
|
|
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
|
-
[
|
|
97
|
-
[width, y], // 1
|
|
98
|
-
[width, i > 0 ? ratio + y : ratio + top], // 2
|
|
99
|
-
[
|
|
100
|
-
[
|
|
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
|
|
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
|
|
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
|
|
123
|
-
[width
|
|
126
|
+
[0, 0], // M
|
|
127
|
+
[width, 0], // 1
|
|
124
128
|
[rightX, bodyHeigth], // 2
|
|
125
|
-
[rightX, height
|
|
126
|
-
[leftX, height
|
|
129
|
+
[rightX, height], // 3
|
|
130
|
+
[leftX, height], // 4
|
|
127
131
|
[leftX, bodyHeigth], // 5
|
|
128
|
-
[0
|
|
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 =
|
|
309
|
+
let accumulatedHeight = top ?? 0;
|
|
284
310
|
|
|
285
311
|
targets.each((d, i) => {
|
|
286
312
|
points[d.id] = [
|
|
287
|
-
[
|
|
288
|
-
[
|
|
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
|
-
|
|
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`)
|
|
@@ -63,6 +63,24 @@ function convertDataToTreemapData(data: IData[]): ITreemapData[] {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Get hierarchy data
|
|
68
|
+
* @param {object} data Data object
|
|
69
|
+
* @returns {Array} Array of hierarchy data
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
function getHierachyData(data) {
|
|
73
|
+
const $$ = this;
|
|
74
|
+
const hierarchyData = d3Hierarchy(data).sum(d => d.value);
|
|
75
|
+
const sortFn = $$.getSortCompareFn(true);
|
|
76
|
+
|
|
77
|
+
return [
|
|
78
|
+
$$.treemap(
|
|
79
|
+
sortFn ? hierarchyData.sort(sortFn) : hierarchyData
|
|
80
|
+
)
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
|
|
66
84
|
export default {
|
|
67
85
|
initTreemap(): void {
|
|
68
86
|
const $$ = this;
|
|
@@ -80,15 +98,6 @@ export default {
|
|
|
80
98
|
$$.treemap = d3Treemap()
|
|
81
99
|
.tile($$.getTreemapTile());
|
|
82
100
|
|
|
83
|
-
$$.treemapFn = data => {
|
|
84
|
-
const hierarchyData = d3Hierarchy(data).sum(d => d.value);
|
|
85
|
-
const sortFn = $$.getSortCompareFn(true);
|
|
86
|
-
|
|
87
|
-
return $$.treemap(
|
|
88
|
-
sortFn ? hierarchyData.sort(sortFn) : hierarchyData
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
101
|
$el.defs
|
|
93
102
|
.append("clipPath")
|
|
94
103
|
.attr("id", clip.id)
|
|
@@ -198,7 +207,7 @@ export default {
|
|
|
198
207
|
updateTargetsForTreemap(targets: IData): void {
|
|
199
208
|
const $$ = this;
|
|
200
209
|
const {$el: {treemap}} = $$;
|
|
201
|
-
const treemapData =
|
|
210
|
+
const treemapData = getHierachyData.call($$, $$.getTreemapData(targets ?? $$.data.targets));
|
|
202
211
|
|
|
203
212
|
// using $el.treemap reference can alter data, so select treemap <g> again
|
|
204
213
|
treemap.data(treemapData);
|
package/src/module/util.ts
CHANGED
|
@@ -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 &&
|
|
839
|
-
.
|
|
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";
|