billboard.js 3.3.2 → 3.4.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.
- package/dist/billboard.css +19 -14
- package/dist/billboard.js +474 -100
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +478 -104
- package/dist/billboard.pkgd.min.js +2 -2
- 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 +39 -17
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +39 -17
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +34 -14
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +34 -14
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +6 -6
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +43 -21
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +43 -21
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +38 -18
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +38 -18
- package/dist/theme/datalab.css +24 -20
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +24 -20
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +24 -20
- package/dist/theme/insight.min.css +2 -2
- package/dist-esm/billboard.js +419 -88
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -5
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +3 -5
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +22 -22
- package/src/Chart/api/axis.ts +90 -25
- package/src/Chart/api/focus.ts +3 -2
- package/src/ChartInternal/Axis/Axis.ts +10 -7
- package/src/ChartInternal/ChartInternal.ts +31 -17
- package/src/ChartInternal/data/data.ts +1 -1
- package/src/ChartInternal/interactions/flow.ts +1 -1
- package/src/ChartInternal/internals/color.ts +4 -3
- package/src/ChartInternal/internals/format.ts +5 -1
- package/src/ChartInternal/internals/redraw.ts +3 -0
- package/src/ChartInternal/internals/text.ts +1 -1
- package/src/ChartInternal/internals/transform.ts +4 -1
- package/src/ChartInternal/internals/type.ts +5 -0
- package/src/ChartInternal/shape/arc.ts +41 -17
- package/src/ChartInternal/shape/polar.ts +132 -0
- package/src/ChartInternal/shape/radar.ts +4 -4
- package/src/config/Options/common/main.ts +19 -2
- package/src/config/Options/data/data.ts +3 -0
- package/src/config/Options/shape/polar.ts +81 -0
- package/src/config/classes.ts +6 -3
- package/src/config/const.ts +3 -0
- package/src/config/resolver/shape.ts +4 -0
- package/src/core.ts +1 -0
- package/src/index.esm.ts +1 -0
- package/src/module/generator.ts +12 -4
- package/src/module/util.ts +22 -9
- package/src/scss/billboard.scss +13 -0
- package/src/scss/theme/datalab.scss +13 -0
- package/src/scss/theme/graph.scss +13 -0
- package/src/scss/theme/insight.scss +13 -0
- package/types/bb.d.ts +1 -0
- package/types/chart.d.ts +8 -8
- package/types/options.d.ts +79 -2
- package/types/types.d.ts +2 -0
package/src/module/util.ts
CHANGED
|
@@ -312,11 +312,13 @@ function getBoundingRect(node): {
|
|
|
312
312
|
/**
|
|
313
313
|
* Retrun random number
|
|
314
314
|
* @param {boolean} asStr Convert returned value as string
|
|
315
|
+
* @param {number} min Minimum value
|
|
316
|
+
* @param {number} max Maximum value
|
|
315
317
|
* @returns {number|string}
|
|
316
318
|
* @private
|
|
317
319
|
*/
|
|
318
|
-
function getRandom(asStr: boolean = true): number | string {
|
|
319
|
-
const rand = Math.random();
|
|
320
|
+
function getRandom(asStr: boolean = true, min = 0, max = 10000): number | string {
|
|
321
|
+
const rand = Math.floor(Math.random() * (max - min) + min);
|
|
320
322
|
|
|
321
323
|
return asStr ? String(rand) : rand;
|
|
322
324
|
}
|
|
@@ -730,28 +732,39 @@ function isTabVisible(): boolean {
|
|
|
730
732
|
* @private
|
|
731
733
|
*/
|
|
732
734
|
function convertInputType(mouse: boolean, touch: boolean): "mouse" | "touch" | null {
|
|
735
|
+
const {DocumentTouch, matchMedia, navigator} = window;
|
|
733
736
|
let hasTouch = false;
|
|
734
737
|
|
|
735
738
|
if (touch) {
|
|
736
739
|
// Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
|
|
737
|
-
if (
|
|
738
|
-
hasTouch =
|
|
740
|
+
if (navigator && "maxTouchPoints" in navigator) {
|
|
741
|
+
hasTouch = navigator.maxTouchPoints > 0;
|
|
739
742
|
|
|
740
743
|
// Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
|
|
741
744
|
// On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
|
|
742
|
-
} else if ("ontouchmove" in window || (
|
|
745
|
+
} else if ("ontouchmove" in window || (DocumentTouch && document instanceof DocumentTouch)) {
|
|
743
746
|
hasTouch = true;
|
|
744
747
|
} else {
|
|
745
748
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#avoiding_user_agent_detection
|
|
746
|
-
|
|
749
|
+
if (matchMedia?.("(pointer:coarse)").matches) {
|
|
750
|
+
hasTouch = true;
|
|
751
|
+
} else {
|
|
752
|
+
// Only as a last resort, fall back to user agent sniffing
|
|
753
|
+
const UA = navigator.userAgent;
|
|
747
754
|
|
|
748
|
-
|
|
749
|
-
|
|
755
|
+
hasTouch = (
|
|
756
|
+
/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) ||
|
|
757
|
+
/\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA)
|
|
758
|
+
);
|
|
750
759
|
}
|
|
751
760
|
}
|
|
752
761
|
}
|
|
753
762
|
|
|
754
|
-
|
|
763
|
+
// 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
|
|
764
|
+
// https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
|
|
765
|
+
// Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
|
|
766
|
+
const hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"]
|
|
767
|
+
.some(v => matchMedia?.(`(${v})`).matches);
|
|
755
768
|
|
|
756
769
|
return (hasMouse && "mouse") || (hasTouch && "touch") || null;
|
|
757
770
|
}
|
package/src/scss/billboard.scss
CHANGED
|
@@ -250,6 +250,19 @@ text.bb-chart-arcs-gauge-title {
|
|
|
250
250
|
.bb-chart-arcs-gauge-min {
|
|
251
251
|
fill: #777;
|
|
252
252
|
}
|
|
253
|
+
|
|
254
|
+
/*-- Polar --*/
|
|
255
|
+
.bb-levels {
|
|
256
|
+
circle {
|
|
257
|
+
fill: none;
|
|
258
|
+
stroke: #848282;
|
|
259
|
+
stroke-width: .5px;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
text {
|
|
263
|
+
fill: #848282;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
253
266
|
}
|
|
254
267
|
|
|
255
268
|
/*-- Radar --*/
|
|
@@ -314,6 +314,19 @@ text.bb-chart-arcs-gauge-title {
|
|
|
314
314
|
fill: #eaeaea;
|
|
315
315
|
stroke-width: 0;
|
|
316
316
|
}
|
|
317
|
+
|
|
318
|
+
/*-- Polar --*/
|
|
319
|
+
.bb-levels {
|
|
320
|
+
circle {
|
|
321
|
+
fill: none;
|
|
322
|
+
stroke: #848282;
|
|
323
|
+
stroke-width: .5px;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
text {
|
|
327
|
+
fill: #848282;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
317
330
|
}
|
|
318
331
|
|
|
319
332
|
.bb-chart-arc {
|
|
@@ -332,6 +332,19 @@ text.bb-chart-arcs-gauge-title {
|
|
|
332
332
|
fill: #eaeaea;
|
|
333
333
|
stroke-width: 0;
|
|
334
334
|
}
|
|
335
|
+
|
|
336
|
+
/*-- Polar --*/
|
|
337
|
+
.bb-levels {
|
|
338
|
+
circle {
|
|
339
|
+
fill: none;
|
|
340
|
+
stroke: #848282;
|
|
341
|
+
stroke-width: .5px;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
text {
|
|
345
|
+
fill: #848282;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
335
348
|
}
|
|
336
349
|
|
|
337
350
|
.bb-chart-arc {
|
|
@@ -312,6 +312,19 @@ text.bb-chart-arcs-gauge-title {
|
|
|
312
312
|
fill: #eaeaea;
|
|
313
313
|
stroke-width: 0;
|
|
314
314
|
}
|
|
315
|
+
|
|
316
|
+
/*-- Polar --*/
|
|
317
|
+
.bb-levels {
|
|
318
|
+
circle {
|
|
319
|
+
fill: none;
|
|
320
|
+
stroke: #848282;
|
|
321
|
+
stroke-width: .5px;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
text {
|
|
325
|
+
fill: #848282;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
315
328
|
}
|
|
316
329
|
|
|
317
330
|
.bb-chart-arc {
|
package/types/bb.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export function donut(): "donut";
|
|
|
45
45
|
export function gauge(): "gauge";
|
|
46
46
|
export function line(): "line";
|
|
47
47
|
export function pie(): "pie";
|
|
48
|
+
export function polar(): "polar";
|
|
48
49
|
export function radar(): "radar";
|
|
49
50
|
export function scatter(): "scatter";
|
|
50
51
|
export function spline(): "spline";
|
package/types/chart.d.ts
CHANGED
|
@@ -177,16 +177,16 @@ export interface Chart {
|
|
|
177
177
|
* Get and set axis min value.
|
|
178
178
|
* @param min If min is given, specified axis' min value will be updated. If no argument is given, the current min values for each axis will be returned.
|
|
179
179
|
*/
|
|
180
|
-
min(min?: number | { [key: string]: number }): number | {
|
|
181
|
-
[key: string]: number |
|
|
180
|
+
min(min?: number | false | { [key: string]: number }): number | {
|
|
181
|
+
[key: string]: number | undefined
|
|
182
182
|
};
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* Get and set axis max value.
|
|
186
186
|
* @param max If max is given, specified axis' max value will be updated. If no argument is given, the current max values for each axis will be returned.
|
|
187
187
|
*/
|
|
188
|
-
max(max?: number | { [key: string]: number }): number | {
|
|
189
|
-
[key: string]: number |
|
|
188
|
+
max(max?: number | false | { [key: string]: number }): number | {
|
|
189
|
+
[key: string]: number | undefined
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
/**
|
|
@@ -194,11 +194,11 @@ export interface Chart {
|
|
|
194
194
|
* @param range If range is given, specified axis' min and max value will be updated. If no argument is given, the current min and max values for each axis will be returned.
|
|
195
195
|
*/
|
|
196
196
|
range(range?: {
|
|
197
|
-
min?: number | { [key: string]: number };
|
|
198
|
-
max?: number | { [key: string]: number };
|
|
197
|
+
min?: number | false | { [key: string]: number | false };
|
|
198
|
+
max?: number | false | { [key: string]: number | false };
|
|
199
199
|
}): {
|
|
200
|
-
min: number | { [key: string]: number };
|
|
201
|
-
max: number | { [key: string]: number };
|
|
200
|
+
min: number | { [key: string]: number | undefined };
|
|
201
|
+
max: number | { [key: string]: number | undefined };
|
|
202
202
|
};
|
|
203
203
|
};
|
|
204
204
|
|
package/types/options.d.ts
CHANGED
|
@@ -461,6 +461,78 @@ export interface ChartOptions {
|
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
|
|
464
|
+
polar?: {
|
|
465
|
+
label?: {
|
|
466
|
+
/**
|
|
467
|
+
* Show or hide label on each polar piece.
|
|
468
|
+
*/
|
|
469
|
+
show?: boolean;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Set threshold ratio to show/hide labels.
|
|
473
|
+
*/
|
|
474
|
+
threshold?: number;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Set formatter for the label on each polar piece.
|
|
478
|
+
*/
|
|
479
|
+
format?(this: Chart, value: number, ratio: number, id: string): string;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Set ratio of labels position.
|
|
483
|
+
*/
|
|
484
|
+
ratio?: ((this: Chart, d: DataItem, radius: number, h: number) => void) | number
|
|
485
|
+
};
|
|
486
|
+
level?: {
|
|
487
|
+
/**
|
|
488
|
+
* Set the level depth.
|
|
489
|
+
*/
|
|
490
|
+
depth?: number;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Set level max value.
|
|
494
|
+
*/
|
|
495
|
+
max?: number;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Show or hide level.
|
|
499
|
+
*/
|
|
500
|
+
show?: boolean;
|
|
501
|
+
|
|
502
|
+
text?: {
|
|
503
|
+
/**
|
|
504
|
+
* Set label text's background color.
|
|
505
|
+
*/
|
|
506
|
+
backgroundColor?: string;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Set format function for the level value.
|
|
510
|
+
*/
|
|
511
|
+
format?: (this: Chart, x: string) => string;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Show or hide level text.
|
|
515
|
+
*/
|
|
516
|
+
show?: boolean;
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Set padding between data.
|
|
522
|
+
*/
|
|
523
|
+
padAngle?: number;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Sets the gap between pie arcs.
|
|
527
|
+
*/
|
|
528
|
+
padding?: number;
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Set starting angle where data draws.
|
|
532
|
+
*/
|
|
533
|
+
startAngle?: number;
|
|
534
|
+
};
|
|
535
|
+
|
|
464
536
|
pie?: {
|
|
465
537
|
label?: {
|
|
466
538
|
/**
|
|
@@ -732,15 +804,20 @@ export interface ChartOptions {
|
|
|
732
804
|
*/
|
|
733
805
|
onrendered?(this: Chart): void;
|
|
734
806
|
|
|
807
|
+
/**
|
|
808
|
+
* Set a callback to execute when the chart is clicked.
|
|
809
|
+
*/
|
|
810
|
+
onclick?(this: Chart, event: Event): void;
|
|
811
|
+
|
|
735
812
|
/**
|
|
736
813
|
* Set a callback to execute when mouse/touch enters the chart.
|
|
737
814
|
*/
|
|
738
|
-
onover?(this: Chart): void;
|
|
815
|
+
onover?(this: Chart, event: Event): void;
|
|
739
816
|
|
|
740
817
|
/**
|
|
741
818
|
* Set a callback to execute when mouse/touch leaves the chart.
|
|
742
819
|
*/
|
|
743
|
-
onout?(this: Chart): void;
|
|
820
|
+
onout?(this: Chart, event: Event): void;
|
|
744
821
|
|
|
745
822
|
/**
|
|
746
823
|
* Set a callback to execute when user resizes the screen.
|
package/types/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {Selection} from "d3-selection";
|
|
6
|
+
import {Transition} from "d3-transition";
|
|
6
7
|
|
|
7
8
|
export type PrimitiveArray = Array<
|
|
8
9
|
string | boolean | number | Date | null |
|
|
@@ -10,6 +11,7 @@ export type PrimitiveArray = Array<
|
|
|
10
11
|
>;
|
|
11
12
|
export type ArrayOrString = string[] | string;
|
|
12
13
|
export type d3Selection = Selection<any, any, any, any>;
|
|
14
|
+
export type d3Transition = Transition<any, any, any, any>;
|
|
13
15
|
export type ChartTypes = "area"
|
|
14
16
|
| "area-line-range"
|
|
15
17
|
| "area-spline"
|