billboard.js 3.3.0 → 3.3.1

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 (72) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +424 -374
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +2284 -2200
  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 +137 -92
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +138 -93
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +3 -119
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +3 -119
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +1862 -1828
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +1998 -1919
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +2000 -1921
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +1866 -1948
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +1866 -1948
  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 +426 -383
  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 +15 -15
  35. package/src/Chart/api/focus.ts +8 -8
  36. package/src/Chart/api/regions.ts +3 -3
  37. package/src/Chart/api/selection.ts +15 -15
  38. package/src/Chart/api/subchart.ts +3 -3
  39. package/src/ChartInternal/Axis/Axis.ts +13 -12
  40. package/src/ChartInternal/ChartInternal.ts +5 -6
  41. package/src/ChartInternal/data/data.ts +3 -3
  42. package/src/ChartInternal/data/load.ts +2 -2
  43. package/src/ChartInternal/interactions/drag.ts +15 -15
  44. package/src/ChartInternal/interactions/eventrect.ts +18 -18
  45. package/src/ChartInternal/interactions/interaction.ts +10 -10
  46. package/src/ChartInternal/interactions/zoom.ts +4 -4
  47. package/src/ChartInternal/internals/color.ts +4 -4
  48. package/src/ChartInternal/internals/domain.ts +1 -1
  49. package/src/ChartInternal/internals/grid.ts +32 -32
  50. package/src/ChartInternal/internals/legend.ts +27 -27
  51. package/src/ChartInternal/internals/redraw.ts +3 -3
  52. package/src/ChartInternal/internals/region.ts +3 -3
  53. package/src/ChartInternal/internals/selection.ts +16 -15
  54. package/src/ChartInternal/internals/size.ts +3 -3
  55. package/src/ChartInternal/internals/text.ts +8 -8
  56. package/src/ChartInternal/internals/title.ts +4 -4
  57. package/src/ChartInternal/internals/tooltip.ts +5 -5
  58. package/src/ChartInternal/internals/transform.ts +5 -5
  59. package/src/ChartInternal/shape/arc.ts +22 -22
  60. package/src/ChartInternal/shape/area.ts +4 -4
  61. package/src/ChartInternal/shape/bar.ts +7 -7
  62. package/src/ChartInternal/shape/candlestick.ts +8 -8
  63. package/src/ChartInternal/shape/gauge.ts +8 -8
  64. package/src/ChartInternal/shape/line.ts +7 -7
  65. package/src/ChartInternal/shape/point.ts +18 -18
  66. package/src/ChartInternal/shape/radar.ts +10 -10
  67. package/src/ChartInternal/shape/shape.ts +4 -2
  68. package/src/Plugin/sparkline/index.ts +2 -2
  69. package/src/Plugin/stanford/index.ts +3 -3
  70. package/src/Plugin/stanford/util.ts +0 -1
  71. package/src/config/classes.ts +154 -66
  72. package/src/module/util.ts +1 -2
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import CLASS from "../../config/classes";
5
+ import {$COMMON, $EVENT, $SHAPE} from "../../config/classes";
6
6
  import {isboolean, getPointer, isFunction} from "../../module/util";
7
7
 
8
8
  export default {
@@ -14,9 +14,9 @@ export default {
14
14
  initEventRect(): void {
15
15
  const $$ = this;
16
16
 
17
- $$.$el.main.select(`.${CLASS.chart}`)
17
+ $$.$el.main.select(`.${$COMMON.chart}`)
18
18
  .append("g")
19
- .attr("class", CLASS.eventRects)
19
+ .attr("class", $EVENT.eventRects)
20
20
  .style("fill-opacity", "0");
21
21
  },
22
22
 
@@ -32,15 +32,15 @@ export default {
32
32
  if ($el.eventRect) {
33
33
  $$.updateEventRect($el.eventRect, true);
34
34
  } else {
35
- const eventRects = $$.$el.main.select(`.${CLASS.eventRects}`)
35
+ const eventRects = $$.$el.main.select(`.${$EVENT.eventRects}`)
36
36
  .style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ? (
37
37
  config.axis_rotated ? "ns-resize" : "ew-resize"
38
38
  ) : null)
39
- .classed(CLASS.eventRectsMultiple, isMultipleX)
40
- .classed(CLASS.eventRectsSingle, !isMultipleX);
39
+ .classed($EVENT.eventRectsMultiple, isMultipleX)
40
+ .classed($EVENT.eventRectsSingle, !isMultipleX);
41
41
 
42
42
  // append event <rect>
43
- const eventRectUpdate = eventRects.selectAll(`.${CLASS.eventRect}`)
43
+ const eventRectUpdate = eventRects.selectAll(`.${$EVENT.eventRect}`)
44
44
  .data([0])
45
45
  .enter()
46
46
  .append("rect");
@@ -139,7 +139,7 @@ export default {
139
139
  .on("touchstart.eventRect touchmove.eventRect", event => {
140
140
  state.event = event;
141
141
 
142
- if (!eventRect.empty() && eventRect.classed(CLASS.eventRect)) {
142
+ if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
143
143
  // if touch points are > 1, means doing zooming interaction. In this case do not execute tooltip codes.
144
144
  if (state.dragging || state.flowing || $$.hasArcType() || event.touches.length > 1) {
145
145
  return;
@@ -154,7 +154,7 @@ export default {
154
154
  .on("touchend.eventRect", event => {
155
155
  state.event = event;
156
156
 
157
- if (!eventRect.empty() && eventRect.classed(CLASS.eventRect)) {
157
+ if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
158
158
  if ($$.hasArcType() || !$$.toggleShape || state.cancelClick) {
159
159
  state.cancelClick && (state.cancelClick = false);
160
160
  }
@@ -199,7 +199,7 @@ export default {
199
199
 
200
200
  // only for init
201
201
  if (!rendered) {
202
- rectElement.attr("class", CLASS.eventRect);
202
+ rectElement.attr("class", $EVENT.eventRect);
203
203
  }
204
204
  }
205
205
 
@@ -334,7 +334,7 @@ export default {
334
334
 
335
335
  // Show cursor as pointer if point is close to mouse position
336
336
  if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
337
- $$.$el.svg.select(`.${CLASS.eventRect}`).style("cursor", "pointer");
337
+ $$.$el.svg.select(`.${$EVENT.eventRect}`).style("cursor", "pointer");
338
338
 
339
339
  if (!state.mouseover) {
340
340
  config.data_onover.call($$.api, closest);
@@ -351,7 +351,7 @@ export default {
351
351
  const $$ = this;
352
352
  const {config, $el: {circle, tooltip}} = $$;
353
353
 
354
- $$.$el.svg.select(`.${CLASS.eventRect}`).style("cursor", null);
354
+ $$.$el.svg.select(`.${$EVENT.eventRect}`).style("cursor", null);
355
355
  $$.hideGridFocus();
356
356
 
357
357
  if (tooltip) {
@@ -366,8 +366,8 @@ export default {
366
366
  /**
367
367
  * Create eventRect for each data on the x-axis.
368
368
  * Register touch and drag events.
369
- * @param {object} eventRectEnter d3.select(CLASS.eventRects) object.
370
- * @returns {object} d3.select(CLASS.eventRects) object.
369
+ * @param {object} eventRectEnter d3.select($EVENT.eventRects) object.
370
+ * @returns {object} d3.select($EVENT.eventRects) object.
371
371
  * @private
372
372
  */
373
373
  generateEventRectsForSingleX(eventRectEnter) {
@@ -476,7 +476,7 @@ export default {
476
476
 
477
477
  const {index} = d;
478
478
 
479
- main.selectAll(`.${CLASS.shape}-${index}`)
479
+ main.selectAll(`.${$SHAPE.shape}-${index}`)
480
480
  .each(function(d2) {
481
481
  if (config.data_selection_grouped || $$.isWithinShape(this, d2)) {
482
482
  $$.toggleShape?.(this, d2, index);
@@ -488,7 +488,7 @@ export default {
488
488
  /**
489
489
  * Create an eventRect,
490
490
  * Register touch and drag events.
491
- * @param {object} eventRectEnter d3.select(CLASS.eventRects) object.
491
+ * @param {object} eventRectEnter d3.select($EVENT.eventRects) object.
492
492
  * @private
493
493
  */
494
494
  generateEventRectsForMultipleXs(eventRectEnter): void {
@@ -538,8 +538,8 @@ export default {
538
538
 
539
539
  // select if selection enabled
540
540
  if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
541
- $$.$el.main.selectAll(`.${CLASS.shapes}${$$.getTargetSelectorSuffix(closest.id)}`)
542
- .selectAll(`.${CLASS.shape}-${closest.index}`)
541
+ $$.$el.main.selectAll(`.${$SHAPE.shapes}${$$.getTargetSelectorSuffix(closest.id)}`)
542
+ .selectAll(`.${$SHAPE.shape}-${closest.index}`)
543
543
  .each(function() {
544
544
  if (config.data_selection_grouped || $$.isWithinShape(this, closest)) {
545
545
  $$.toggleShape?.(this, closest, closest.index);
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import {select as d3Select} from "d3-selection";
6
6
  import {drag as d3Drag} from "d3-drag";
7
- import CLASS from "../../config/classes";
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
 
@@ -27,9 +27,9 @@ export default {
27
27
  }
28
28
  }
29
29
 
30
- main.selectAll(`.${CLASS.shape}-${index}`)
30
+ main.selectAll(`.${$SHAPE.shape}-${index}`)
31
31
  .each(function() {
32
- d3Select(this).classed(CLASS.EXPANDED, true);
32
+ d3Select(this).classed($COMMON.EXPANDED, true);
33
33
 
34
34
  if (isSelectionEnabled) {
35
35
  eventRect.style("cursor", isSelectionGrouped ? "pointer" : null);
@@ -96,8 +96,8 @@ export default {
96
96
  ["bar", "candlestick"]
97
97
  .filter(v => $$.$el[v])
98
98
  .forEach(v => {
99
- reset && $$.$el[v].classed(CLASS.EXPANDED, false);
100
- $$.getShapeByIndex(v, i, id).classed(CLASS.EXPANDED, expand);
99
+ reset && $$.$el[v].classed($COMMON.EXPANDED, false);
100
+ $$.getShapeByIndex(v, i, id).classed($COMMON.EXPANDED, expand);
101
101
  });
102
102
  },
103
103
 
@@ -119,11 +119,11 @@ export default {
119
119
  config.color_onover && $$.setOverColor(isOver, d, isArc);
120
120
 
121
121
  if (isArc) {
122
- callback(d, main.select(`.${CLASS.arc}${$$.getTargetSelectorSuffix(d.id)}`).node());
122
+ callback(d, main.select(`.${$ARC.arc}${$$.getTargetSelectorSuffix(d.id)}`).node());
123
123
  } else if (!config.tooltip_grouped) {
124
124
  let last = $$.cache.get(KEY.setOverOut) || [];
125
125
 
126
- const shape = main.selectAll(`.${CLASS.shape}-${d}`)
126
+ const shape = main.selectAll(`.${$SHAPE.shape}-${d}`)
127
127
  .filter(function(d) {
128
128
  return $$.isWithinShape(this, d);
129
129
  });
@@ -151,7 +151,7 @@ export default {
151
151
  $$.setExpand(d, null, true);
152
152
  }
153
153
 
154
- !$$.isMultipleX() && main.selectAll(`.${CLASS.shape}-${d}`)
154
+ !$$.isMultipleX() && main.selectAll(`.${$SHAPE.shape}-${d}`)
155
155
  .each(function(d) {
156
156
  callback(d, this);
157
157
  });
@@ -213,8 +213,8 @@ export default {
213
213
  const {config, state: {eventReceiver, hasAxis, hasRadar}, $el: {eventRect, arcs, radar}} = $$;
214
214
  const isMultipleX = $$.isMultipleX();
215
215
  const element = (
216
- hasRadar ? radar.axes.select(`.${CLASS.axis}-${index} text`) : (
217
- eventRect || arcs.selectAll(`.${CLASS.target} path`).filter((d, i) => i === index)
216
+ hasRadar ? radar.axes.select(`.${$AXIS.axis}-${index} text`) : (
217
+ eventRect || arcs.selectAll(`.${$COMMON.target} path`).filter((d, i) => i === index)
218
218
  )
219
219
  ).node();
220
220
 
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import {drag as d3Drag} from "d3-drag";
6
6
  import {zoomIdentity as d3ZoomIdentity, zoom as d3Zoom} from "d3-zoom";
7
- import CLASS from "../../config/classes";
7
+ import {$COMMON, $ZOOM} from "../../config/classes";
8
8
  import {callFn, diffDomain, getPointer, isFunction} from "../../module/util";
9
9
 
10
10
  export default {
@@ -301,7 +301,7 @@ export default {
301
301
  if (!zoomRect) {
302
302
  zoomRect = $$.$el.main.append("rect")
303
303
  .attr("clip-path", state.clip.path)
304
- .attr("class", CLASS.zoomBrush)
304
+ .attr("class", $ZOOM.zoomBrush)
305
305
  .attr("width", isRotated ? state.width : 0)
306
306
  .attr("height", isRotated ? 0 : state.height);
307
307
  }
@@ -356,13 +356,13 @@ export default {
356
356
  if (resetButton && config.zoom_type === "drag") {
357
357
  if (!$el.zoomResetBtn) {
358
358
  $el.zoomResetBtn = $$.$el.chart.append("div")
359
- .classed(CLASS.button, true)
359
+ .classed($COMMON.button, true)
360
360
  .append("span")
361
361
  .on("click", function() {
362
362
  isFunction(resetButton.onclick) && resetButton.onclick.bind($$.api)(this);
363
363
  $$.api.unzoom();
364
364
  })
365
- .classed(CLASS.buttonZoomReset, true)
365
+ .classed($ZOOM.buttonZoomReset, true)
366
366
  .text(resetButton.text || "Reset Zoom");
367
367
  } else {
368
368
  $el.zoomResetBtn.style("display", null);
@@ -5,7 +5,7 @@
5
5
  import {select as d3Select} from "d3-selection";
6
6
  import {scaleOrdinal as d3ScaleOrdinal} from "d3-scale";
7
7
  import {document, window} from "../../module/browser";
8
- import CLASS from "../../config/classes";
8
+ import {$ARC, $COLOR, $SHAPE} from "../../config/classes";
9
9
  import {KEY} from "../../module/Cache";
10
10
  import {notEmpty, isFunction, isObject, isString} from "../../module/util";
11
11
 
@@ -54,7 +54,7 @@ export default {
54
54
  const delimiter = ";";
55
55
  const span = document.createElement("span");
56
56
 
57
- span.className = CLASS.colorPattern;
57
+ span.className = $COLOR.colorPattern;
58
58
  span.style.display = "none";
59
59
  body.appendChild(span);
60
60
 
@@ -214,8 +214,8 @@ export default {
214
214
  main.selectAll(
215
215
  isObject(d) ?
216
216
  // when is Arc type
217
- `.${CLASS.arc}${$$.getTargetSelectorSuffix(d.id)}` :
218
- `.${CLASS.shape}-${d}`
217
+ `.${$ARC.arc}${$$.getTargetSelectorSuffix(d.id)}` :
218
+ `.${$SHAPE.shape}-${d}`
219
219
  ).style("fill", color);
220
220
  }
221
221
  };
@@ -109,7 +109,7 @@ export default {
109
109
  .some(v => {
110
110
  const type = v.indexOf("area") > -1 ? "area" : v;
111
111
 
112
- return $$.hasType(v, yTargets) && config[`${type}_zerobased`];
112
+ return $$.hasType(v, yTargets, true) && config[`${type}_zerobased`];
113
113
  });
114
114
 
115
115
  // MEMO: avoid inverting domain unexpectedly
@@ -6,7 +6,7 @@ import {
6
6
  select as d3Select,
7
7
  selectAll as d3SelectAll
8
8
  } from "d3-selection";
9
- import CLASS from "../../config/classes";
9
+ import {$AXIS, $COMMON, $FOCUS, $GRID} from "../../config/classes";
10
10
  import {isArray, isValue} from "../../module/util";
11
11
 
12
12
  // Grid position and text anchor helpers
@@ -72,12 +72,12 @@ export default {
72
72
  const {config, state: {clip}, $el} = $$;
73
73
 
74
74
  if (config.grid_x_lines.length || config.grid_y_lines.length) {
75
- $el.gridLines.main = $el.main.insert("g", `.${CLASS.chart}${config.grid_lines_front ? " + *" : ""}`)
75
+ $el.gridLines.main = $el.main.insert("g", `.${$COMMON.chart}${config.grid_lines_front ? " + *" : ""}`)
76
76
  .attr("clip-path", clip.pathGrid)
77
- .attr("class", `${CLASS.grid} ${CLASS.gridLines}`);
77
+ .attr("class", `${$GRID.grid} ${$GRID.gridLines}`);
78
78
 
79
- $el.gridLines.main.append("g").attr("class", CLASS.xgridLines);
80
- $el.gridLines.main.append("g").attr("class", CLASS.ygridLines);
79
+ $el.gridLines.main.append("g").attr("class", $GRID.xgridLines);
80
+ $el.gridLines.main.append("g").attr("class", $GRID.ygridLines);
81
81
 
82
82
  $el.gridLines.x = d3SelectAll([]);
83
83
  }
@@ -105,15 +105,15 @@ export default {
105
105
  "y2": state.height,
106
106
  };
107
107
 
108
- grid.x = main.select(`.${CLASS.xgrids}`)
109
- .selectAll(`.${CLASS.xgrid}`)
108
+ grid.x = main.select(`.${$GRID.xgrids}`)
109
+ .selectAll(`.${$GRID.xgrid}`)
110
110
  .data(xgridData);
111
111
 
112
112
  grid.x.exit().remove();
113
113
 
114
114
  grid.x = grid.x.enter()
115
115
  .append("line")
116
- .attr("class", CLASS.xgrid)
116
+ .attr("class", $GRID.xgrid)
117
117
  .merge(grid.x);
118
118
 
119
119
  if (!withoutUpdate) {
@@ -138,8 +138,8 @@ export default {
138
138
  const gridValues = $$.axis.y.tickValues() || $$.scale.y.ticks(config.grid_y_ticks);
139
139
  const pos = d => Math.ceil($$.scale.y(d));
140
140
 
141
- grid.y = main.select(`.${CLASS.ygrids}`)
142
- .selectAll(`.${CLASS.ygrid}`)
141
+ grid.y = main.select(`.${$GRID.ygrids}`)
142
+ .selectAll(`.${$GRID.ygrid}`)
143
143
  .data(gridValues);
144
144
 
145
145
  grid.y.exit().remove();
@@ -147,7 +147,7 @@ export default {
147
147
  grid.y = grid.y
148
148
  .enter()
149
149
  .append("line")
150
- .attr("class", CLASS.ygrid)
150
+ .attr("class", $GRID.ygrid)
151
151
  .merge(grid.y);
152
152
 
153
153
  grid.y.attr("x1", isRotated ? pos : 0)
@@ -183,8 +183,8 @@ export default {
183
183
 
184
184
  config.grid_x_show && $$.updateXGrid();
185
185
 
186
- let xLines = main.select(`.${CLASS.xgridLines}`)
187
- .selectAll(`.${CLASS.xgridLine}`)
186
+ let xLines = main.select(`.${$GRID.xgridLines}`)
187
+ .selectAll(`.${$GRID.xgridLine}`)
188
188
  .data(config.grid_x_lines);
189
189
 
190
190
  // exit
@@ -206,7 +206,7 @@ export default {
206
206
  xLines = xgridLine.merge(xLines);
207
207
 
208
208
  $T(xLines
209
- .attr("class", d => `${CLASS.xgridLine} ${d.class || ""}`.trim())
209
+ .attr("class", d => `${$GRID.xgridLine} ${d.class || ""}`.trim())
210
210
  .select("text")
211
211
  .attr("text-anchor", getGridTextAnchor)
212
212
  .attr("dx", getGridTextDx)
@@ -228,8 +228,8 @@ export default {
228
228
 
229
229
  config.grid_y_show && $$.updateYGrid();
230
230
 
231
- let ygridLines = $el.main.select(`.${CLASS.ygridLines}`)
232
- .selectAll(`.${CLASS.ygridLine}`)
231
+ let ygridLines = $el.main.select(`.${$GRID.ygridLines}`)
232
+ .selectAll(`.${$GRID.ygridLine}`)
233
233
  .data(config.grid_y_lines);
234
234
 
235
235
  // exit
@@ -253,7 +253,7 @@ export default {
253
253
  const yv = $$.yv.bind($$);
254
254
 
255
255
  $T(ygridLines
256
- .attr("class", d => `${CLASS.ygridLine} ${d.class || ""}`.trim())
256
+ .attr("class", d => `${$GRID.ygridLine} ${d.class || ""}`.trim())
257
257
  .select("line"))
258
258
  .attr("x1", isRotated ? yv : 0)
259
259
  .attr("x2", isRotated ? yv : width)
@@ -307,32 +307,32 @@ export default {
307
307
  const $$ = this;
308
308
  const {config, state: {clip}, $el} = $$;
309
309
  const isFront = config.grid_front;
310
- const className = `.${CLASS[isFront && $el.gridLines.main ? "gridLines" : "chart"]}${isFront ? " + *" : ""}`;
310
+ const className = `.${isFront && $el.gridLines.main ? $GRID.gridLines : $COMMON.chart}${isFront ? " + *" : ""}`;
311
311
 
312
312
  const grid = $el.main.insert("g", className)
313
313
  .attr("clip-path", clip.pathGrid)
314
- .attr("class", CLASS.grid);
314
+ .attr("class", $GRID.grid);
315
315
 
316
316
  $el.grid.main = grid;
317
317
 
318
318
  config.grid_x_show &&
319
- grid.append("g").attr("class", CLASS.xgrids);
319
+ grid.append("g").attr("class", $GRID.xgrids);
320
320
 
321
321
  config.grid_y_show &&
322
- grid.append("g").attr("class", CLASS.ygrids);
322
+ grid.append("g").attr("class", $GRID.ygrids);
323
323
 
324
324
  if (config.interaction_enabled && config.grid_focus_show) {
325
325
  grid.append("g")
326
- .attr("class", CLASS.xgridFocus)
326
+ .attr("class", $FOCUS.xgridFocus)
327
327
  .append("line")
328
- .attr("class", CLASS.xgridFocus);
328
+ .attr("class", $FOCUS.xgridFocus);
329
329
 
330
330
  // to show xy focus grid line, should be 'tooltip.grouped=false'
331
331
  if (config.grid_focus_y && !config.tooltip_grouped) {
332
332
  grid.append("g")
333
- .attr("class", CLASS.ygridFocus)
333
+ .attr("class", $FOCUS.ygridFocus)
334
334
  .append("line")
335
- .attr("class", CLASS.ygridFocus);
335
+ .attr("class", $FOCUS.ygridFocus);
336
336
  }
337
337
  }
338
338
  },
@@ -346,7 +346,7 @@ export default {
346
346
  const $$ = this;
347
347
  const {config, state: {width, height}} = $$;
348
348
  const isRotated = config.axis_rotated;
349
- const focusEl = $$.$el.main.selectAll(`line.${CLASS.xgridFocus}, line.${CLASS.ygridFocus}`);
349
+ const focusEl = $$.$el.main.selectAll(`line.${$FOCUS.xgridFocus}, line.${$FOCUS.ygridFocus}`);
350
350
 
351
351
  const dataToShow = (data || [focusEl.datum()]).filter(d => d && isValue($$.getBaseValue(d)));
352
352
 
@@ -369,7 +369,7 @@ export default {
369
369
  };
370
370
  let xy;
371
371
 
372
- if (el.classed(CLASS.xgridFocus)) {
372
+ if (el.classed($FOCUS.xgridFocus)) {
373
373
  // will contain 'x1, y1, x2, y2' order
374
374
  xy = isRotated ?
375
375
  [
@@ -413,7 +413,7 @@ export default {
413
413
  const {state: {inputType, resizing}, $el: {main}} = $$;
414
414
 
415
415
  if (inputType === "mouse" || !resizing) {
416
- main.selectAll(`line.${CLASS.xgridFocus}, line.${CLASS.ygridFocus}`)
416
+ main.selectAll(`line.${$FOCUS.xgridFocus}, line.${$FOCUS.ygridFocus}`)
417
417
  .style("visibility", "hidden");
418
418
 
419
419
  $$.hideCircleFocus?.();
@@ -423,7 +423,7 @@ export default {
423
423
  updateGridFocus(): boolean {
424
424
  const $$ = this;
425
425
  const {state: {inputType, width, height, resizing}, $el: {grid}} = $$;
426
- const xgridFocus = grid.main.select(`line.${CLASS.xgridFocus}`);
426
+ const xgridFocus = grid.main.select(`line.${$FOCUS.xgridFocus}`);
427
427
 
428
428
  if (inputType === "touch") {
429
429
  if (xgridFocus.empty()) {
@@ -448,7 +448,7 @@ export default {
448
448
 
449
449
  generateGridData(type: string, scale) {
450
450
  const $$ = this;
451
- const tickNum = $$.$el.main.select(`.${CLASS.axisX}`)
451
+ const tickNum = $$.$el.main.select(`.${$AXIS.axisX}`)
452
452
  .selectAll(".tick")
453
453
  .size();
454
454
  let gridData: Date[] = [];
@@ -490,8 +490,8 @@ export default {
490
490
  const {config, $T} = $$;
491
491
  const toRemove = $$.getGridFilterToRemove(params);
492
492
  const toShow = line => !toRemove(line);
493
- const classLines = forX ? CLASS.xgridLines : CLASS.ygridLines;
494
- const classLine = forX ? CLASS.xgridLine : CLASS.ygridLine;
493
+ const classLines = forX ? $GRID.xgridLines : $GRID.ygridLines;
494
+ const classLine = forX ? $GRID.xgridLine : $GRID.ygridLine;
495
495
 
496
496
  $T($$.$el.main.select(`.${classLines}`)
497
497
  .selectAll(`.${classLine}`)
@@ -7,7 +7,7 @@ import {
7
7
  namespaces as d3Namespaces
8
8
  } from "d3-selection";
9
9
  import {document} from "../../module/browser";
10
- import CLASS from "../../config/classes";
10
+ import {$FOCUS, $GAUGE, $LEGEND} from "../../config/classes";
11
11
  import {KEY} from "../../module/Cache";
12
12
  import {callFn, isDefined, getOption, isEmpty, isFunction, notEmpty, tplProcess} from "../../module/util";
13
13
 
@@ -26,7 +26,7 @@ export default {
26
26
  if (config.legend_show) {
27
27
  if (!config.legend_contents_bindto) {
28
28
  $el.legend = $$.$el.svg.append("g")
29
- .classed(CLASS.legend, true)
29
+ .classed($LEGEND.legend, true)
30
30
  .attr("transform", $$.getTranslate("legend"));
31
31
  }
32
32
 
@@ -68,8 +68,8 @@ export default {
68
68
  }
69
69
 
70
70
  // toggle legend state
71
- $el.legend.selectAll(`.${CLASS.legendItem}`)
72
- .classed(CLASS.legendItemHidden, function(id) {
71
+ $el.legend.selectAll(`.${$LEGEND.legendItem}`)
72
+ .classed($LEGEND.legendItemHidden, function(id) {
73
73
  const hide = !$$.isTargetToShow(id);
74
74
 
75
75
  if (hide) {
@@ -209,7 +209,7 @@ export default {
209
209
  const {legend} = this.$el;
210
210
 
211
211
  if (legend) {
212
- legend.select(`.${CLASS.legendItem}-${id} line`)
212
+ legend.select(`.${$LEGEND.legendItem}-${id} line`)
213
213
  .style("stroke", color);
214
214
  }
215
215
  },
@@ -251,7 +251,7 @@ export default {
251
251
  * @private
252
252
  */
253
253
  opacityForUnfocusedLegend(legendItem): string | null {
254
- return legendItem.classed(CLASS.legendItemHidden) ? null : "0.3";
254
+ return legendItem.classed($LEGEND.legendItemHidden) ? null : "0.3";
255
255
  },
256
256
 
257
257
  /**
@@ -265,9 +265,9 @@ export default {
265
265
  const {$el: {legend}, $T} = $$;
266
266
  const targetIdz = $$.mapToTargetIds(targetIds);
267
267
 
268
- legend && $T(legend.selectAll(`.${CLASS.legendItem}`)
268
+ legend && $T(legend.selectAll(`.${$LEGEND.legendItem}`)
269
269
  .filter(id => targetIdz.indexOf(id) >= 0)
270
- .classed(CLASS.legendItemFocused, focus))
270
+ .classed($FOCUS.legendItemFocused, focus))
271
271
  .style("opacity", function() {
272
272
  return focus ? null :
273
273
  $$.opacityForUnfocusedLegend.call($$, d3Select(this));
@@ -282,8 +282,8 @@ export default {
282
282
  const $$ = this;
283
283
  const {$el: {legend}, $T} = $$;
284
284
 
285
- legend && $T(legend.selectAll(`.${CLASS.legendItem}`)
286
- .classed(CLASS.legendItemFocused, false))
285
+ legend && $T(legend.selectAll(`.${$LEGEND.legendItem}`)
286
+ .classed($FOCUS.legendItemFocused, false))
287
287
  .style("opacity", null);
288
288
  },
289
289
 
@@ -353,7 +353,7 @@ export default {
353
353
  data = (!state.redrawing && cache.get(cacheKey)) || {};
354
354
 
355
355
  if (!data[id]) {
356
- data[id] = $$.getTextRect(textElement, CLASS.legendItem);
356
+ data[id] = $$.getTextRect(textElement, $LEGEND.legendItem);
357
357
  cache.add(cacheKey, data);
358
358
  }
359
359
 
@@ -379,7 +379,7 @@ export default {
379
379
  const node = d3Select(this);
380
380
  const itemClass = (!node.empty() && node.attr("class")) || "";
381
381
 
382
- return itemClass + $$.generateClass(CLASS.legendItem, id);
382
+ return itemClass + $$.generateClass($LEGEND.legendItem, id);
383
383
  })
384
384
  .style("visibility", id => ($$.isLegendToShow(id) ? null : "hidden"));
385
385
 
@@ -395,7 +395,7 @@ export default {
395
395
  api.toggle(id);
396
396
 
397
397
  d3Select(this)
398
- .classed(CLASS.legendItemFocused, false);
398
+ .classed($FOCUS.legendItemFocused, false);
399
399
  }
400
400
  }
401
401
 
@@ -405,10 +405,10 @@ export default {
405
405
  !isTouch && item
406
406
  .on("mouseout", function(event, id) {
407
407
  if (!callFn(config.legend_item_onout, api, id)) {
408
- d3Select(this).classed(CLASS.legendItemFocused, false);
408
+ d3Select(this).classed($FOCUS.legendItemFocused, false);
409
409
 
410
410
  if (hasGauge) {
411
- $$.undoMarkOverlapped($$, `.${CLASS.gaugeValue}`);
411
+ $$.undoMarkOverlapped($$, `.${$GAUGE.gaugeValue}`);
412
412
  }
413
413
 
414
414
  $$.api.revert();
@@ -416,10 +416,10 @@ export default {
416
416
  })
417
417
  .on("mouseover", function(event, id) {
418
418
  if (!callFn(config.legend_item_onover, api, id)) {
419
- d3Select(this).classed(CLASS.legendItemFocused, true);
419
+ d3Select(this).classed($FOCUS.legendItemFocused, true);
420
420
 
421
421
  if (hasGauge) {
422
- $$.markOverlapped(id, $$, `.${CLASS.gaugeValue}`);
422
+ $$.markOverlapped(id, $$, `.${$GAUGE.gaugeValue}`);
423
423
  }
424
424
 
425
425
  if (!state.transiting && $$.isTargetToShow(id)) {
@@ -567,7 +567,7 @@ export default {
567
567
  const pos = -200;
568
568
 
569
569
  // Define g for legend area
570
- const l = legend.selectAll(`.${CLASS.legendItem}`)
570
+ const l = legend.selectAll(`.${$LEGEND.legendItem}`)
571
571
  .data(targetIdz)
572
572
  .enter()
573
573
  .append("g");
@@ -584,7 +584,7 @@ export default {
584
584
  .attr("y", isLegendRightOrInset ? pos : yForLegendText);
585
585
 
586
586
  l.append("rect")
587
- .attr("class", CLASS.legendItemEvent)
587
+ .attr("class", $LEGEND.legendItemEvent)
588
588
  .style("fill-opacity", "0")
589
589
  .attr("x", isLegendRightOrInset ? xForLegendRect : pos)
590
590
  .attr("y", isLegendRightOrInset ? pos : yForLegendRect);
@@ -616,7 +616,7 @@ export default {
616
616
 
617
617
  return document.createElementNS(d3Namespaces.svg, ("hasValidPointType" in $$) && $$.hasValidPointType(point) ? point : "use");
618
618
  })
619
- .attr("class", CLASS.legendItemPoint)
619
+ .attr("class", $LEGEND.legendItemPoint)
620
620
  .style("fill", getColor)
621
621
  .style("pointer-events", "none")
622
622
  .attr("href", (data, idx, selection) => {
@@ -628,7 +628,7 @@ export default {
628
628
  });
629
629
  } else {
630
630
  l.append("line")
631
- .attr("class", CLASS.legendItemTile)
631
+ .attr("class", $LEGEND.legendItemTile)
632
632
  .style("stroke", getColor)
633
633
  .style("pointer-events", "none")
634
634
  .attr("x1", isLegendRightOrInset ? x1ForLegendTile : pos)
@@ -639,11 +639,11 @@ export default {
639
639
  }
640
640
 
641
641
  // Set background for inset legend
642
- background = legend.select(`.${CLASS.legendBackground} rect`);
642
+ background = legend.select(`.${$LEGEND.legendBackground} rect`);
643
643
 
644
644
  if (state.isLegendInset && maxWidth > 0 && background.size() === 0) {
645
- background = legend.insert("g", `.${CLASS.legendItem}`)
646
- .attr("class", CLASS.legendBackground)
645
+ background = legend.insert("g", `.${$LEGEND.legendItem}`)
646
+ .attr("class", $LEGEND.legendBackground)
647
647
  .append("rect");
648
648
  }
649
649
 
@@ -658,7 +658,7 @@ export default {
658
658
  .attr("x", xForLegendText)
659
659
  .attr("y", yForLegendText);
660
660
 
661
- const rects = legend.selectAll(`rect.${CLASS.legendItemEvent}`)
661
+ const rects = legend.selectAll(`rect.${$LEGEND.legendItemEvent}`)
662
662
  .data(targetIdz);
663
663
 
664
664
  $T(rects, withTransition)
@@ -668,7 +668,7 @@ export default {
668
668
  .attr("y", yForLegendRect);
669
669
 
670
670
  if (usePoint) {
671
- const tiles = legend.selectAll(`.${CLASS.legendItemPoint}`)
671
+ const tiles = legend.selectAll(`.${$LEGEND.legendItemPoint}`)
672
672
  .data(targetIdz);
673
673
 
674
674
  $T(tiles, withTransition)
@@ -707,7 +707,7 @@ export default {
707
707
  .attr("height", height);
708
708
  });
709
709
  } else {
710
- const tiles = legend.selectAll(`line.${CLASS.legendItemTile}`)
710
+ const tiles = legend.selectAll(`line.${$LEGEND.legendItemTile}`)
711
711
  .data(targetIdz);
712
712
 
713
713
  $T(tiles, withTransition)
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {transition as d3Transition} from "d3-transition";
6
- import CLASS from "../../config/classes";
6
+ import {$COMMON, $SELECT, $TEXT} from "../../config/classes";
7
7
  import {generateWait} from "../../module/generator";
8
8
  import {callFn, capitalize, getOption, isTabVisible, notEmpty} from "../../module/util";
9
9
 
@@ -47,7 +47,7 @@ export default {
47
47
  $$.axis.redrawAxis(targetsToShow, wth, transitions, flow, initializing);
48
48
 
49
49
  // Data empty label positioning and text.
50
- config.data_empty_label_text && main.select(`text.${CLASS.text}.${CLASS.empty}`)
50
+ config.data_empty_label_text && main.select(`text.${$TEXT.text}.${$COMMON.empty}`)
51
51
  .attr("x", state.width / 2)
52
52
  .attr("y", state.height / 2)
53
53
  .text(config.data_empty_label_text)
@@ -69,7 +69,7 @@ export default {
69
69
 
70
70
 
71
71
  // circles for select
72
- $el.text && main.selectAll(`.${CLASS.selectedCircles}`)
72
+ $el.text && main.selectAll(`.${$SELECT.selectedCircles}`)
73
73
  .filter($$.isBarType.bind($$))
74
74
  .selectAll("circle")
75
75
  .remove();