billboard.js 3.3.0 → 3.3.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 (75) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +489 -399
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +2491 -2239
  6. package/dist/billboard.pkgd.min.js +2 -2
  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 +166 -103
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +166 -103
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +32 -130
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +32 -130
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +2004 -1842
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +2168 -1943
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +2170 -1945
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +2036 -1972
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +2037 -1973
  22. package/dist/theme/datalab.css +1 -1
  23. package/dist/theme/datalab.min.css +2 -2
  24. package/dist/theme/graph.css +1 -1
  25. package/dist/theme/graph.min.css +2 -2
  26. package/dist/theme/insight.css +1 -1
  27. package/dist/theme/insight.min.css +2 -2
  28. package/dist-esm/billboard.js +481 -412
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -4
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +129 -77
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +135 -80
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +4 -8
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +4 -7
  34. package/package.json +28 -28
  35. package/src/Chart/api/chart.ts +1 -1
  36. package/src/Chart/api/focus.ts +8 -8
  37. package/src/Chart/api/regions.ts +3 -3
  38. package/src/Chart/api/selection.ts +15 -15
  39. package/src/Chart/api/subchart.ts +10 -10
  40. package/src/ChartInternal/Axis/Axis.ts +16 -14
  41. package/src/ChartInternal/ChartInternal.ts +7 -8
  42. package/src/ChartInternal/data/data.ts +3 -3
  43. package/src/ChartInternal/data/load.ts +2 -2
  44. package/src/ChartInternal/interactions/drag.ts +15 -15
  45. package/src/ChartInternal/interactions/eventrect.ts +18 -18
  46. package/src/ChartInternal/interactions/interaction.ts +10 -10
  47. package/src/ChartInternal/interactions/zoom.ts +4 -4
  48. package/src/ChartInternal/internals/color.ts +4 -4
  49. package/src/ChartInternal/internals/domain.ts +1 -1
  50. package/src/ChartInternal/internals/format.ts +9 -4
  51. package/src/ChartInternal/internals/grid.ts +32 -32
  52. package/src/ChartInternal/internals/legend.ts +27 -27
  53. package/src/ChartInternal/internals/redraw.ts +6 -5
  54. package/src/ChartInternal/internals/region.ts +3 -3
  55. package/src/ChartInternal/internals/selection.ts +16 -15
  56. package/src/ChartInternal/internals/size.ts +3 -3
  57. package/src/ChartInternal/internals/text.ts +8 -8
  58. package/src/ChartInternal/internals/title.ts +4 -4
  59. package/src/ChartInternal/internals/tooltip.ts +5 -5
  60. package/src/ChartInternal/internals/transform.ts +5 -5
  61. package/src/ChartInternal/shape/arc.ts +22 -22
  62. package/src/ChartInternal/shape/area.ts +4 -4
  63. package/src/ChartInternal/shape/bar.ts +7 -7
  64. package/src/ChartInternal/shape/candlestick.ts +8 -8
  65. package/src/ChartInternal/shape/gauge.ts +8 -8
  66. package/src/ChartInternal/shape/line.ts +7 -7
  67. package/src/ChartInternal/shape/point.ts +18 -18
  68. package/src/ChartInternal/shape/radar.ts +10 -10
  69. package/src/ChartInternal/shape/shape.ts +4 -2
  70. package/src/Plugin/sparkline/index.ts +2 -2
  71. package/src/Plugin/stanford/index.ts +3 -3
  72. package/src/Plugin/stanford/util.ts +0 -1
  73. package/src/config/Options/common/tooltip.ts +10 -1
  74. package/src/config/classes.ts +154 -66
  75. package/src/module/util.ts +21 -13
@@ -6,108 +6,196 @@
6
6
  * CSS class names definition
7
7
  * @private
8
8
  */
9
- export default {
9
+ export const $COMMON = {
10
+ button: "bb-button",
11
+ chart: "bb-chart",
12
+ empty: "bb-empty",
13
+ main: "bb-main",
14
+ target: "bb-target",
15
+ EXPANDED: "_expanded_"
16
+ };
17
+
18
+ export const $ARC = {
10
19
  arc: "bb-arc",
11
20
  arcLabelLine: "bb-arc-label-line",
12
21
  arcs: "bb-arcs",
22
+ chartArc: "bb-chart-arc",
23
+ chartArcs: "bb-chart-arcs",
24
+ chartArcsBackground: "bb-chart-arcs-background",
25
+ chartArcsTitle: "bb-chart-arcs-title"
26
+ };
27
+
28
+ export const $AREA = {
13
29
  area: "bb-area",
14
- areas: "bb-areas",
30
+ areas: "bb-areas"
31
+ };
32
+
33
+ export const $AXIS = {
15
34
  axis: "bb-axis",
16
35
  axisX: "bb-axis-x",
17
36
  axisXLabel: "bb-axis-x-label",
18
37
  axisY: "bb-axis-y",
19
38
  axisY2: "bb-axis-y2",
20
39
  axisY2Label: "bb-axis-y2-label",
21
- axisYLabel: "bb-axis-y-label",
40
+ axisYLabel: "bb-axis-y-label"
41
+ };
42
+
43
+ export const $BAR = {
22
44
  bar: "bb-bar",
23
45
  bars: "bb-bars",
24
- brush: "bb-brush",
25
- button: "bb-button",
26
- buttonZoomReset: "bb-zoom-reset",
46
+ chartBar: "bb-chart-bar",
47
+ chartBars: "bb-chart-bars"
48
+ };
49
+
50
+ export const $CANDLESTICK = {
27
51
  candlestick: "bb-candlestick",
28
52
  candlesticks: "bb-candlesticks",
29
- chart: "bb-chart",
30
- chartArc: "bb-chart-arc",
31
- chartArcs: "bb-chart-arcs",
32
- chartArcsBackground: "bb-chart-arcs-background",
33
- chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
34
- chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
35
- chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
36
- chartArcsTitle: "bb-chart-arcs-title",
37
- chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
38
- chartBar: "bb-chart-bar",
39
- chartBars: "bb-chart-bars",
40
53
  chartCandlestick: "bb-chart-candlestick",
41
54
  chartCandlesticks: "bb-chart-candlesticks",
55
+ valueDown: "bb-value-down",
56
+ valueUp: "bb-value-up"
57
+ };
58
+
59
+ export const $CIRCLE = {
42
60
  chartCircles: "bb-chart-circles",
43
- chartLine: "bb-chart-line",
44
- chartLines: "bb-chart-lines",
45
- chartRadar: "bb-chart-radar",
46
- chartRadars: "bb-chart-radars",
47
- chartText: "bb-chart-text",
48
- chartTexts: "bb-chart-texts",
49
61
  circle: "bb-circle",
50
- circles: "bb-circles",
62
+ circles: "bb-circles"
63
+ };
64
+
65
+ export const $COLOR = {
51
66
  colorPattern: "bb-color-pattern",
52
- colorScale: "bb-colorscale",
53
- defocused: "bb-defocused",
67
+ colorScale: "bb-colorscale"
68
+ };
69
+
70
+ export const $DRAG = {
54
71
  dragarea: "bb-dragarea",
55
- empty: "bb-empty",
72
+ INCLUDED: "_included_"
73
+ };
74
+
75
+ export const $GAUGE = {
76
+ chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
77
+ chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
78
+ chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
79
+ chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
80
+ gaugeValue: "bb-gauge-value"
81
+ };
82
+
83
+ export const $LEGEND = {
84
+ legend: "bb-legend",
85
+ legendBackground: "bb-legend-background",
86
+ legendItem: "bb-legend-item",
87
+ legendItemEvent: "bb-legend-item-event",
88
+ legendItemHidden: "bb-legend-item-hidden",
89
+ legendItemPoint: "bb-legend-item-point",
90
+ legendItemTile: "bb-legend-item-tile"
91
+ };
92
+
93
+ export const $LINE = {
94
+ chartLine: "bb-chart-line",
95
+ chartLines: "bb-chart-lines",
96
+ line: "bb-line",
97
+ lines: "bb-lines"
98
+ };
99
+
100
+ export const $EVENT = {
56
101
  eventRect: "bb-event-rect",
57
102
  eventRects: "bb-event-rects",
58
103
  eventRectsMultiple: "bb-event-rects-multiple",
59
104
  eventRectsSingle: "bb-event-rects-single",
105
+
106
+ };
107
+
108
+ export const $FOCUS = {
60
109
  focused: "bb-focused",
61
- gaugeValue: "bb-gauge-value",
110
+ defocused: "bb-defocused",
111
+ legendItemFocused: "bb-legend-item-focused",
112
+ xgridFocus: "bb-xgrid-focus",
113
+ ygridFocus: "bb-ygrid-focus"
114
+ };
115
+
116
+ export const $GRID = {
62
117
  grid: "bb-grid",
63
118
  gridLines: "bb-grid-lines",
64
- legend: "bb-legend",
65
- legendBackground: "bb-legend-background",
66
- legendItem: "bb-legend-item",
67
- legendItemEvent: "bb-legend-item-event",
68
- legendItemFocused: "bb-legend-item-focused",
69
- legendItemHidden: "bb-legend-item-hidden",
70
- legendItemPoint: "bb-legend-item-point",
71
- legendItemTile: "bb-legend-item-tile",
119
+ xgrid: "bb-xgrid",
120
+ xgridLine: "bb-xgrid-line",
121
+ xgridLines: "bb-xgrid-lines",
122
+ xgrids: "bb-xgrids",
123
+ ygrid: "bb-ygrid",
124
+ ygridLine: "bb-ygrid-line",
125
+ ygridLines: "bb-ygrid-lines",
126
+ ygrids: "bb-ygrids"
127
+ };
128
+
129
+ export const $RADAR = {
130
+ chartRadar: "bb-chart-radar",
131
+ chartRadars: "bb-chart-radars",
72
132
  level: "bb-level",
73
- levels: "bb-levels",
74
- line: "bb-line",
75
- lines: "bb-lines",
76
- main: "bb-main",
133
+ levels: "bb-levels"
134
+ };
135
+
136
+ export const $REGION = {
77
137
  region: "bb-region",
78
- regions: "bb-regions",
138
+ regions: "bb-regions"
139
+ };
140
+
141
+ export const $SELECT = {
79
142
  selectedCircle: "bb-selected-circle",
80
143
  selectedCircles: "bb-selected-circles",
144
+ SELECTED: "_selected_"
145
+ };
146
+
147
+ export const $SHAPE = {
81
148
  shape: "bb-shape",
82
149
  shapes: "bb-shapes",
83
- stanfordElements: "bb-stanford-elements",
84
- stanfordLine: "bb-stanford-line",
85
- stanfordLines: "bb-stanford-lines",
86
- stanfordRegion: "bb-stanford-region",
87
- stanfordRegions: "bb-stanford-regions",
88
- subchart: "bb-subchart",
89
- target: "bb-target",
150
+ };
151
+
152
+ export const $SUBCHART = {
153
+ brush: "bb-brush",
154
+ subchart: "bb-subchart"
155
+ };
156
+
157
+ export const $TEXT = {
158
+ chartText: "bb-chart-text",
159
+ chartTexts: "bb-chart-texts",
90
160
  text: "bb-text",
91
161
  texts: "bb-texts",
92
162
  title: "bb-title",
163
+ TextOverlapping: "text-overlapping"
164
+ };
165
+
166
+ export const $TOOLTIP = {
93
167
  tooltip: "bb-tooltip",
94
168
  tooltipContainer: "bb-tooltip-container",
95
- tooltipName: "bb-tooltip-name",
96
- valueDown: "bb-value-down",
97
- valueUp: "bb-value-up",
98
- xgrid: "bb-xgrid",
99
- xgridFocus: "bb-xgrid-focus",
100
- xgridLine: "bb-xgrid-line",
101
- xgridLines: "bb-xgrid-lines",
102
- xgrids: "bb-xgrids",
103
- ygrid: "bb-ygrid",
104
- ygridFocus: "bb-ygrid-focus",
105
- ygridLine: "bb-ygrid-line",
106
- ygridLines: "bb-ygrid-lines",
107
- ygrids: "bb-ygrids",
108
- zoomBrush: "bb-zoom-brush",
109
- EXPANDED: "_expanded_",
110
- SELECTED: "_selected_",
111
- INCLUDED: "_included_",
112
- TextOverlapping: "text-overlapping"
169
+ tooltipName: "bb-tooltip-name"
170
+ };
171
+
172
+ export const $ZOOM = {
173
+ buttonZoomReset: "bb-zoom-reset",
174
+ zoomBrush: "bb-zoom-brush"
175
+ };
176
+
177
+ export default {
178
+ ...$COMMON,
179
+ ...$ARC,
180
+ ...$AREA,
181
+ ...$AXIS,
182
+ ...$BAR,
183
+ ...$CANDLESTICK,
184
+ ...$CIRCLE,
185
+ ...$COLOR,
186
+ ...$DRAG,
187
+ ...$GAUGE,
188
+ ...$LEGEND,
189
+ ...$LINE,
190
+ ...$EVENT,
191
+ ...$FOCUS,
192
+ ...$GRID,
193
+ ...$RADAR,
194
+ ...$REGION,
195
+ ...$SELECT,
196
+ ...$SHAPE,
197
+ ...$SUBCHART,
198
+ ...$TEXT,
199
+ ...$TOOLTIP,
200
+ ...$ZOOM
113
201
  };
@@ -7,7 +7,6 @@ import {pointer as d3Pointer} from "d3-selection";
7
7
  import {brushSelection as d3BrushSelection} from "d3-brush";
8
8
  import {d3Selection} from "../../types/types";
9
9
  import {document, window} from "./browser";
10
- import CLASS from "../config/classes";
11
10
 
12
11
  export {
13
12
  asHalfPixel,
@@ -284,7 +283,7 @@ function getBrushSelection(ctx) {
284
283
  if (event && event.type === "brush") {
285
284
  selection = event.selection;
286
285
  // check from brush area selection
287
- } else if (main && (selection = main.select(`.${CLASS.brush}`).node())) {
286
+ } else if (main && (selection = main.select(".bb-brush").node())) {
288
287
  selection = d3BrushSelection(selection);
289
288
  }
290
289
 
@@ -313,11 +312,13 @@ function getBoundingRect(node): {
313
312
  /**
314
313
  * Retrun random number
315
314
  * @param {boolean} asStr Convert returned value as string
315
+ * @param {number} min Minimum value
316
+ * @param {number} max Maximum value
316
317
  * @returns {number|string}
317
318
  * @private
318
319
  */
319
- function getRandom(asStr: boolean = true): number | string {
320
- 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);
321
322
 
322
323
  return asStr ? String(rand) : rand;
323
324
  }
@@ -731,21 +732,28 @@ function isTabVisible(): boolean {
731
732
  * @private
732
733
  */
733
734
  function convertInputType(mouse: boolean, touch: boolean): "mouse" | "touch" | null {
734
- let isMobile = false;
735
+ let hasTouch = false;
735
736
 
736
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Mobile_Tablet_or_Desktop
737
- if (/Mobi/.test(window.navigator.userAgent) && touch) {
737
+ if (touch) {
738
738
  // Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
739
- const hasTouchPoints = window.navigator && "maxTouchPoints" in window.navigator && window.navigator.maxTouchPoints > 0;
739
+ if (window.navigator && "maxTouchPoints" in window.navigator) {
740
+ hasTouch = window.navigator.maxTouchPoints > 0;
740
741
 
741
742
  // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
742
743
  // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
743
- const hasTouch = ("ontouchmove" in window || (window.DocumentTouch && document instanceof window.DocumentTouch));
744
-
745
- isMobile = hasTouchPoints || hasTouch;
744
+ } else if ("ontouchmove" in window || (window.DocumentTouch && document instanceof window.DocumentTouch)) {
745
+ hasTouch = true;
746
+ } else {
747
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#avoiding_user_agent_detection
748
+ const mQ = window.matchMedia && matchMedia("(pointer:coarse)");
749
+
750
+ if (mQ && mQ.media === "(pointer:coarse)") {
751
+ hasTouch = !!mQ.matches;
752
+ }
753
+ }
746
754
  }
747
755
 
748
- const hasMouse = mouse && !isMobile ? ("onmouseover" in window) : false;
756
+ const hasMouse = mouse && !hasTouch ? ("onmouseover" in window) : false;
749
757
 
750
- return (hasMouse && "mouse") || (isMobile && "touch") || null;
758
+ return (hasMouse && "mouse") || (hasTouch && "touch") || null;
751
759
  }