billboard.js 3.11.2 → 3.12.0-next.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 (171) hide show
  1. package/README.md +2 -6
  2. package/dist/billboard.css +5 -1
  3. package/dist/billboard.js +19431 -24292
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +26 -3
  6. package/dist/billboard.pkgd.js +22301 -29057
  7. package/dist/billboard.pkgd.min.js +33 -3
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +423 -1134
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +660 -1524
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +339 -1324
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1701 -3424
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2385 -4462
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1783 -3467
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2031 -3979
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
  28. package/dist/theme/dark.css +5 -1
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +5 -1
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +5 -1
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +5 -1
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +5 -1
  37. package/dist/theme/modern.min.css +3 -4
  38. package/dist-esm/billboard.js +9051 -8666
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +19 -25
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +149 -148
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +295 -286
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +235 -234
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +40 -41
  44. package/package.json +26 -46
  45. package/src/Chart/api/axis.ts +6 -13
  46. package/src/Chart/api/chart.ts +12 -11
  47. package/src/Chart/api/data.ts +8 -7
  48. package/src/Chart/api/export.ts +28 -21
  49. package/src/Chart/api/flow.ts +4 -2
  50. package/src/Chart/api/grid.ts +1 -5
  51. package/src/Chart/api/load.ts +2 -2
  52. package/src/Chart/api/regions.ts +29 -5
  53. package/src/Chart/api/selection.ts +2 -2
  54. package/src/Chart/api/show.ts +2 -3
  55. package/src/Chart/api/subchart.ts +2 -2
  56. package/src/Chart/api/tooltip.ts +5 -7
  57. package/src/Chart/api/x.ts +2 -2
  58. package/src/Chart/api/zoom.ts +2 -2
  59. package/src/ChartInternal/Axis/Axis.ts +119 -44
  60. package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
  61. package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
  62. package/src/ChartInternal/ChartInternal.ts +79 -51
  63. package/src/ChartInternal/data/IData.ts +22 -29
  64. package/src/ChartInternal/data/convert.helper.ts +66 -68
  65. package/src/ChartInternal/data/convert.ts +11 -11
  66. package/src/ChartInternal/data/data.ts +40 -23
  67. package/src/ChartInternal/data/load.ts +7 -6
  68. package/src/ChartInternal/interactions/drag.ts +2 -1
  69. package/src/ChartInternal/interactions/eventrect.ts +54 -25
  70. package/src/ChartInternal/interactions/flow.ts +14 -4
  71. package/src/ChartInternal/interactions/interaction.ts +34 -12
  72. package/src/ChartInternal/interactions/subchart.ts +27 -25
  73. package/src/ChartInternal/interactions/zoom.ts +29 -18
  74. package/src/ChartInternal/internals/category.ts +1 -1
  75. package/src/ChartInternal/internals/class.ts +5 -5
  76. package/src/ChartInternal/internals/clip.ts +9 -10
  77. package/src/ChartInternal/internals/color.ts +70 -42
  78. package/src/ChartInternal/internals/domain.ts +59 -28
  79. package/src/ChartInternal/internals/format.ts +5 -5
  80. package/src/ChartInternal/internals/grid.ts +130 -47
  81. package/src/ChartInternal/internals/legend.ts +99 -66
  82. package/src/ChartInternal/internals/redraw.ts +3 -2
  83. package/src/ChartInternal/internals/region.ts +5 -3
  84. package/src/ChartInternal/internals/scale.ts +28 -15
  85. package/src/ChartInternal/internals/selection.ts +14 -13
  86. package/src/ChartInternal/internals/size.axis.ts +18 -10
  87. package/src/ChartInternal/internals/size.ts +97 -66
  88. package/src/ChartInternal/internals/style.ts +21 -19
  89. package/src/ChartInternal/internals/text.ts +64 -39
  90. package/src/ChartInternal/internals/title.ts +2 -2
  91. package/src/ChartInternal/internals/tooltip.ts +83 -34
  92. package/src/ChartInternal/internals/transform.ts +2 -2
  93. package/src/ChartInternal/internals/type.ts +12 -12
  94. package/src/ChartInternal/shape/arc.ts +78 -44
  95. package/src/ChartInternal/shape/area.ts +19 -22
  96. package/src/ChartInternal/shape/bar.ts +41 -31
  97. package/src/ChartInternal/shape/bubble.ts +5 -5
  98. package/src/ChartInternal/shape/candlestick.ts +15 -13
  99. package/src/ChartInternal/shape/gauge.ts +16 -9
  100. package/src/ChartInternal/shape/line.ts +62 -46
  101. package/src/ChartInternal/shape/point.common.ts +1 -4
  102. package/src/ChartInternal/shape/point.ts +52 -32
  103. package/src/ChartInternal/shape/polar.ts +4 -2
  104. package/src/ChartInternal/shape/radar.ts +40 -22
  105. package/src/ChartInternal/shape/shape.ts +84 -58
  106. package/src/ChartInternal/shape/treemap.ts +29 -20
  107. package/src/Plugin/bubblecompare/index.ts +1 -3
  108. package/src/Plugin/sparkline/index.ts +3 -4
  109. package/src/Plugin/stanford/ColorScale.ts +3 -2
  110. package/src/Plugin/stanford/Elements.ts +15 -6
  111. package/src/Plugin/stanford/Options.ts +5 -5
  112. package/src/Plugin/stanford/index.ts +13 -9
  113. package/src/Plugin/tableview/Options.ts +1 -1
  114. package/src/Plugin/tableview/const.ts +1 -4
  115. package/src/Plugin/tableview/index.ts +11 -9
  116. package/src/Plugin/textoverlap/index.ts +4 -6
  117. package/src/config/Options/Options.ts +3 -3
  118. package/src/config/Options/axis/axis.ts +36 -0
  119. package/src/config/Options/axis/x.ts +12 -13
  120. package/src/config/Options/axis/y.ts +13 -13
  121. package/src/config/Options/axis/y2.ts +23 -10
  122. package/src/config/Options/common/color.ts +4 -4
  123. package/src/config/Options/common/grid.ts +4 -4
  124. package/src/config/Options/common/legend.ts +13 -14
  125. package/src/config/Options/common/main.ts +23 -23
  126. package/src/config/Options/common/point.ts +17 -18
  127. package/src/config/Options/common/title.ts +2 -2
  128. package/src/config/Options/common/tooltip.ts +13 -11
  129. package/src/config/Options/data/axis.ts +2 -2
  130. package/src/config/Options/data/data.ts +45 -45
  131. package/src/config/Options/interaction/interaction.ts +1 -1
  132. package/src/config/Options/interaction/subchart.ts +2 -2
  133. package/src/config/Options/interaction/zoom.ts +9 -9
  134. package/src/config/Options/shape/arc.ts +10 -13
  135. package/src/config/Options/shape/area.ts +5 -7
  136. package/src/config/Options/shape/bar.ts +8 -10
  137. package/src/config/Options/shape/bubble.ts +1 -1
  138. package/src/config/Options/shape/candlestick.ts +2 -2
  139. package/src/config/Options/shape/donut.ts +4 -4
  140. package/src/config/Options/shape/gauge.ts +6 -6
  141. package/src/config/Options/shape/line.ts +3 -3
  142. package/src/config/Options/shape/pie.ts +5 -5
  143. package/src/config/Options/shape/polar.ts +3 -3
  144. package/src/config/Options/shape/radar.ts +2 -2
  145. package/src/config/Options/shape/scatter.ts +1 -1
  146. package/src/config/Options/shape/treemap.ts +1 -1
  147. package/src/config/Store/Element.ts +8 -5
  148. package/src/config/Store/State.ts +19 -13
  149. package/src/config/classes.ts +6 -4
  150. package/src/config/config.ts +1 -1
  151. package/src/config/resolver/axis.ts +4 -4
  152. package/src/config/resolver/interaction.ts +3 -7
  153. package/src/config/resolver/shape.ts +11 -12
  154. package/src/core.ts +2 -3
  155. package/src/index.esm.ts +2 -6
  156. package/src/index.ts +2 -2
  157. package/src/module/Cache.ts +2 -3
  158. package/src/module/browser.ts +15 -10
  159. package/src/module/error.ts +9 -8
  160. package/src/module/generator.ts +3 -5
  161. package/src/module/util.ts +60 -37
  162. package/src/module/worker.ts +14 -11
  163. package/src/scss/billboard.scss +6 -0
  164. package/src/scss/theme/dark.scss +6 -0
  165. package/src/scss/theme/datalab.scss +6 -0
  166. package/src/scss/theme/graph.scss +6 -0
  167. package/src/scss/theme/insight.scss +6 -0
  168. package/src/scss/theme/modern.scss +6 -0
  169. package/types/axis.d.ts +7 -0
  170. package/types/options.d.ts +7 -0
  171. package/types/options.shape.d.ts +7 -0
@@ -3,16 +3,15 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {
6
- scaleTime as d3ScaleTime,
7
- scaleUtc as d3ScaleUtc,
8
6
  scaleLinear as d3ScaleLinear,
9
7
  scaleLog as d3ScaleLog,
10
- scaleSymlog as d3ScaleSymlog
8
+ scaleSymlog as d3ScaleSymlog,
9
+ scaleTime as d3ScaleTime,
10
+ scaleUtc as d3ScaleUtc
11
11
  } from "d3-scale";
12
12
  import {isString, isValue, parseDate} from "../../module/util";
13
13
  import type {IDataRow, IGridData} from "../data/IData";
14
14
 
15
-
16
15
  /**
17
16
  * Get scale
18
17
  * @param {string} [type='linear'] Scale type
@@ -48,7 +47,8 @@ export default {
48
47
  */
49
48
  getXScale(min: number, max: number, domain: number[], offset: Function) {
50
49
  const $$ = this;
51
- const scale = ($$.state.loading !== "append" && $$.scale.zoom) || getScale($$.axis.getAxisType("x"), min, max);
50
+ const scale = ($$.state.loading !== "append" && $$.scale.zoom) ||
51
+ getScale($$.axis.getAxisType("x"), min, max);
52
52
 
53
53
  return $$.getCustomizedXScale(
54
54
  domain ? scale.domain(domain) : scale,
@@ -121,9 +121,7 @@ export default {
121
121
  if (!arguments.length) {
122
122
  domain = this.orgDomain();
123
123
 
124
- return isInverted ?
125
- [domain[0] + 1, domain[1]] :
126
- [domain[0], domain[1] + 1];
124
+ return isInverted ? [domain[0] + 1, domain[1]] : [domain[0], domain[1] + 1];
127
125
  }
128
126
 
129
127
  scaleValue.domain(domain);
@@ -143,7 +141,12 @@ export default {
143
141
  */
144
142
  updateScales(isInit: boolean, updateXDomain = true): void {
145
143
  const $$ = this;
146
- const {axis, config, format, org, scale,
144
+ const {
145
+ axis,
146
+ config,
147
+ format,
148
+ org,
149
+ scale,
147
150
  state: {current, width, height, width2, height2, hasAxis, hasTreemap}
148
151
  } = $$;
149
152
 
@@ -173,8 +176,8 @@ export default {
173
176
 
174
177
  scale.x = $$.getXScale(min.x, max.x, xDomain, () => axis.x.tickOffset());
175
178
  scale.subX = $$.getXScale(min.x, max.x, xSubDomain, d => (
176
- d % 1 ? 0 : (axis.subX ?? axis.x).tickOffset())
177
- );
179
+ d % 1 ? 0 : (axis.subX ?? axis.x).tickOffset()
180
+ ));
178
181
 
179
182
  format.xAxisTick = axis.getXAxisTickFormat();
180
183
  format.subXAxisTick = axis.getXAxisTickFormat(true);
@@ -186,17 +189,27 @@ export default {
186
189
  }
187
190
 
188
191
  // y Axis
189
- scale.y = $$.getYScale("y", min.y, max.y, scale.y ? scale.y.domain() : config.axis_y_default);
192
+ scale.y = $$.getYScale("y", min.y, max.y,
193
+ scale.y ? scale.y.domain() : config.axis_y_default);
190
194
  scale.subY = $$.getYScale(
191
- "y", min.subY, max.subY, scale.subY ? scale.subY.domain() : config.axis_y_default);
195
+ "y",
196
+ min.subY,
197
+ max.subY,
198
+ scale.subY ? scale.subY.domain() : config.axis_y_default
199
+ );
192
200
 
193
201
  axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit);
194
202
 
195
203
  // y2 Axis
196
204
  if (config.axis_y2_show) {
197
- scale.y2 = $$.getYScale("y2", min.y, max.y, scale.y2 ? scale.y2.domain() : config.axis_y2_default);
205
+ scale.y2 = $$.getYScale("y2", min.y, max.y,
206
+ scale.y2 ? scale.y2.domain() : config.axis_y2_default);
198
207
  scale.subY2 = $$.getYScale(
199
- "y2", min.subY, max.subY, scale.subY2 ? scale.subY2.domain() : config.axis_y2_default);
208
+ "y2",
209
+ min.subY,
210
+ max.subY,
211
+ scale.subY2 ? scale.subY2.domain() : config.axis_y2_default
212
+ );
200
213
 
201
214
  axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
202
215
  }
@@ -3,9 +3,9 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {select as d3Select} from "d3-selection";
6
- import drag from "../interactions/drag";
7
6
  import {$SELECT, $SHAPE} from "../../config/classes";
8
7
  import {callFn} from "../../module/util";
8
+ import drag from "../interactions/drag";
9
9
 
10
10
  export default {
11
11
  ...drag,
@@ -37,8 +37,7 @@ export default {
37
37
  .attr("cx", cx)
38
38
  .attr("cy", cy)
39
39
  .attr("stroke", $$.color)
40
- .attr("r", d2 => $$.pointSelectR(d2) * 1.4)
41
- ).attr("r", r);
40
+ .attr("r", d2 => $$.pointSelectR(d2) * 1.4)).attr("r", r);
42
41
  },
43
42
 
44
43
  /**
@@ -56,8 +55,7 @@ export default {
56
55
 
57
56
  // remove selected-circle from low layer g
58
57
  $T(main.select(`.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(d.id)}`)
59
- .selectAll(`.${$SELECT.selectedCircle}-${i}`)
60
- )
58
+ .selectAll(`.${$SELECT.selectedCircle}-${i}`))
61
59
  .attr("r", 0)
62
60
  .remove();
63
61
  },
@@ -134,12 +132,11 @@ export default {
134
132
  getToggle(that, d): Function {
135
133
  const $$ = this;
136
134
 
137
- return that.nodeName === "path" ?
138
- $$.togglePath : (
139
- $$.isStepType(d) ?
140
- () => {} : // circle is hidden in step chart, so treat as within the click area
141
- $$.togglePoint
142
- );
135
+ return that.nodeName === "path" ? $$.togglePath : (
136
+ $$.isStepType(d) ?
137
+ () => {} : // circle is hidden in step chart, so treat as within the click area
138
+ $$.togglePoint
139
+ );
143
140
  },
144
141
 
145
142
  /**
@@ -168,7 +165,11 @@ export default {
168
165
  }
169
166
 
170
167
  main.selectAll(selector)
171
- .selectAll(focusOnly ? `.${$SELECT.selectedCircle}` : `.${$SHAPE.shape}.${$SELECT.SELECTED}`)
168
+ .selectAll(
169
+ focusOnly ?
170
+ `.${$SELECT.selectedCircle}` :
171
+ `.${$SHAPE.shape}.${$SELECT.SELECTED}`
172
+ )
172
173
  .classed($SELECT.SELECTED, false)
173
174
  .each(function(d) {
174
175
  const shape = d3Select(this);
@@ -183,5 +184,5 @@ export default {
183
184
  toggle(!isSelected, shape, d, i);
184
185
  }
185
186
  }
186
- },
187
+ }
187
188
  };
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {isNumber} from "../../module/util";
6
5
  import type {AxisType} from "../../../types/types";
6
+ import {isNumber} from "../../module/util";
7
7
 
8
8
  export default {
9
9
  /**
@@ -32,7 +32,9 @@ export default {
32
32
  return width + (
33
33
  $$.config.padding?.mode === "fit" ?
34
34
  position.isInner ? (10 + gap) : 10 :
35
- position.isInner ? (20 + gap) : 40
35
+ position.isInner ?
36
+ (20 + gap) :
37
+ 40
36
38
  );
37
39
  } else {
38
40
  return 40;
@@ -48,8 +50,9 @@ export default {
48
50
  const isInner = config[`axis_${id}_inner`];
49
51
  const hasLabelText = config[`axis_${id}_label`].text;
50
52
  const defaultHeight = 13;
51
- let h = config.padding?.mode === "fit" ? (isInner && !hasLabelText ? (id === "y" ? 1 : 0) : 20) : 30;
52
-
53
+ let h = config.padding?.mode === "fit" ?
54
+ (isInner && !hasLabelText ? (id === "y" ? 1 : 0) : 20) :
55
+ 30;
53
56
 
54
57
  if (id === "x" && !config.axis_x_show) {
55
58
  return 8;
@@ -61,8 +64,10 @@ export default {
61
64
 
62
65
  if (id === "y" && !config.axis_y_show) {
63
66
  return config.legend_show &&
64
- !isLegendRight &&
65
- !isLegendInset ? 10 : 1;
67
+ !isLegendRight &&
68
+ !isLegendInset ?
69
+ 10 :
70
+ 1;
66
71
  }
67
72
 
68
73
  if (id === "y2" && !config.axis_y2_show) {
@@ -75,7 +80,10 @@ export default {
75
80
  !config.axis_x_tick_autorotate || $$.needToRotateXAxisTickTexts()
76
81
  );
77
82
 
78
- if ((config.axis_x_tick_multiline || isXAxisTickRotated) && maxtickSize.height > defaultHeight) {
83
+ if (
84
+ (config.axis_x_tick_multiline || isXAxisTickRotated) &&
85
+ maxtickSize.height > defaultHeight
86
+ ) {
79
87
  h += maxtickSize.height - defaultHeight;
80
88
  }
81
89
 
@@ -130,15 +138,15 @@ export default {
130
138
  state.axis.x.tickCount = tickCount;
131
139
  }
132
140
 
133
- if ($el.svg &&
141
+ if (
142
+ $el.svg &&
134
143
  config.axis_x_tick_autorotate &&
135
144
  config.axis_x_tick_fit &&
136
145
  !config.axis_x_tick_multiline &&
137
146
  !config.axis_x_tick_culling &&
138
147
  allowedXAxisTypes
139
148
  ) {
140
- rotate = $$.needToRotateXAxisTickTexts() ?
141
- config.axis_x_tick_rotate : 0;
149
+ rotate = $$.needToRotateXAxisTickTexts() ? config.axis_x_tick_rotate : 0;
142
150
  }
143
151
  }
144
152
 
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {document} from "../../module/browser";
6
5
  import {$AXIS, $SUBCHART} from "../../config/classes";
6
+ import {document} from "../../module/browser";
7
7
  import {KEY} from "../../module/Cache";
8
- import {ceil10, capitalize, isNumber, isEmpty, isString, isUndefined} from "../../module/util";
8
+ import {capitalize, ceil10, isEmpty, isNumber, isString, isUndefined} from "../../module/util";
9
9
 
10
10
  export default {
11
11
  /**
@@ -77,9 +77,7 @@ export default {
77
77
  let height = 0;
78
78
 
79
79
  if (h) {
80
- height = /px$/.test(h) ?
81
- parseInt(h, 10) :
82
- this.getParentRectValue("height");
80
+ height = /px$/.test(h) ? parseInt(h, 10) : this.getParentRectValue("height");
83
81
  }
84
82
 
85
83
  return height;
@@ -96,9 +94,12 @@ export default {
96
94
  let labelWidth = 0;
97
95
 
98
96
  // if axis label position set to inner, exclude from the value
99
- if (hasAxis && (
100
- isString(leftLabel) || isString(leftLabel.text) || /^inner-/.test(leftLabel?.position)
101
- )) {
97
+ if (
98
+ hasAxis && (
99
+ isString(leftLabel) || isString(leftLabel.text) ||
100
+ /^inner-/.test(leftLabel?.position)
101
+ )
102
+ ) {
102
103
  const label = $el.main.select(`.${leftAxisClass}-label`);
103
104
 
104
105
  if (!label.empty()) {
@@ -174,29 +175,36 @@ export default {
174
175
  * @returns {number} padding value
175
176
  * @private
176
177
  */
177
- getCurrentPaddingByDirection(type: "top" | "bottom" | "left" | "right", withoutRecompute = false, withXAxisTickTextOverflow = false): number {
178
+ getCurrentPaddingByDirection(type: "top" | "bottom" | "left" | "right",
179
+ withoutRecompute = false, withXAxisTickTextOverflow = false): number {
178
180
  const $$ = this;
179
181
  const {config, $el, state: {hasAxis}} = $$;
180
182
  const isRotated = config.axis_rotated;
181
183
  const isFitPadding = config.padding?.mode === "fit";
182
- const paddingOption = isNumber(config[`padding_${type}`]) ? config[`padding_${type}`] : undefined;
183
- const axisId = hasAxis ? {
184
- top: isRotated ? "y2" : null,
185
- bottom: isRotated ? "y" : "x",
186
- left: isRotated ? "x" : "y",
187
- right: isRotated ? null : "y2"
188
- }[type] : null;
184
+ const paddingOption = isNumber(config[`padding_${type}`]) ?
185
+ config[`padding_${type}`] :
186
+ undefined;
187
+ const axisId = hasAxis ?
188
+ {
189
+ top: isRotated ? "y2" : null,
190
+ bottom: isRotated ? "y" : "x",
191
+ left: isRotated ? "x" : "y",
192
+ right: isRotated ? null : "y2"
193
+ }[type] :
194
+ null;
189
195
 
190
196
  const isLeftRight = /^(left|right)$/.test(type);
191
197
  const isAxisInner = axisId && config[`axis_${axisId}_inner`];
192
198
  const isAxisShow = axisId && config[`axis_${axisId}_show`];
193
199
  const axesLen = axisId ? config[`axis_${axisId}_axes`].length : 0;
194
200
 
195
- let axisSize = axisId ? (
196
- isLeftRight ?
197
- $$.getAxisWidthByAxisId(axisId, withoutRecompute) :
198
- $$.getHorizontalAxisHeight(axisId)
199
- ) : 0;
201
+ let axisSize = axisId ?
202
+ (
203
+ isLeftRight ?
204
+ $$.getAxisWidthByAxisId(axisId, withoutRecompute) :
205
+ $$.getHorizontalAxisHeight(axisId)
206
+ ) :
207
+ 0;
200
208
  const defaultPadding = 20;
201
209
  let gap = 0;
202
210
 
@@ -205,8 +213,10 @@ export default {
205
213
  }
206
214
 
207
215
  let padding = hasAxis && isLeftRight && (
208
- isAxisInner || (isUndefined(paddingOption) && !isAxisShow)
209
- ) ? 0 : (
216
+ isAxisInner || (isUndefined(paddingOption) && !isAxisShow)
217
+ ) ?
218
+ 0 :
219
+ (
210
220
  isFitPadding ? (isAxisShow ? axisSize : 0) + (paddingOption ?? 0) : (
211
221
  isUndefined(paddingOption) ? axisSize : paddingOption
212
222
  )
@@ -218,14 +228,21 @@ export default {
218
228
  }
219
229
 
220
230
  if (type === "right") {
221
- padding += isRotated ? (
222
- !isFitPadding && isUndefined(paddingOption) ? 10 : 2
223
- ) : !isAxisShow || isAxisInner ? (isFitPadding ? 2 : 1) : 0;
224
-
225
- padding += withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
231
+ padding += isRotated ?
232
+ (
233
+ !isFitPadding && isUndefined(paddingOption) ? 10 : 2
234
+ ) :
235
+ !isAxisShow || isAxisInner ?
236
+ (isFitPadding ? 2 : 1) :
237
+ 0;
238
+
239
+ padding += withXAxisTickTextOverflow ?
240
+ $$.axis.getXAxisTickTextY2Overflow(defaultPadding) :
241
+ 0;
226
242
  } else if (type === "left" && isRotated && isUndefined(paddingOption)) {
227
243
  padding = !config.axis_x_show ?
228
- 1 : (isFitPadding ? axisSize : Math.max(axisSize, 40));
244
+ 1 :
245
+ (isFitPadding ? axisSize : Math.max(axisSize, 40));
229
246
  }
230
247
  } else {
231
248
  if (type === "top") {
@@ -242,9 +259,9 @@ export default {
242
259
  return padding + (axisSize * axesLen) - gap;
243
260
  },
244
261
 
245
- getCurrentPadding(withXAxisTickTextOverflow = false): {
246
- top: number, bottom: number, left: number, right: number
247
- } {
262
+ getCurrentPadding(
263
+ withXAxisTickTextOverflow = false
264
+ ): {top: number, bottom: number, left: number, right: number} {
248
265
  const $$ = this;
249
266
  const [top, bottom, left, right] = ["top", "bottom", "left", "right"]
250
267
  .map(v => $$.getCurrentPaddingByDirection(v, null, withXAxisTickTextOverflow));
@@ -269,10 +286,12 @@ export default {
269
286
  !isNum && Object.keys(v as object).forEach(key => {
270
287
  // when data.lables=true, do not reset top padding
271
288
  p[key] = (
272
- !isEmpty(config.data_labels) &&
273
- config.data_labels !== false &&
274
- key === "top"
275
- ) ? v[key] : 0;
289
+ !isEmpty(config.data_labels) &&
290
+ config.data_labels !== false &&
291
+ key === "top"
292
+ ) ?
293
+ v[key] :
294
+ 0;
276
295
  });
277
296
  } else {
278
297
  p = v;
@@ -306,50 +325,60 @@ export default {
306
325
 
307
326
  const legendSize = {
308
327
  right: config.legend_show && state.isLegendRight ?
309
- $$.getLegendWidth() + (isFitPadding ? 0 : 20) : 0,
310
- bottom: !config.legend_show || state.isLegendRight || state.isLegendInset ? 0 : currLegend.height
328
+ $$.getLegendWidth() + (isFitPadding ? 0 : 20) :
329
+ 0,
330
+ bottom: !config.legend_show || state.isLegendRight || state.isLegendInset ?
331
+ 0 :
332
+ currLegend.height
311
333
  };
312
334
 
313
335
  const xAxisHeight = isRotated || isNonAxis ? 0 : $$.getHorizontalAxisHeight("x");
314
336
 
315
- const subchartXAxisHeight = config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ?
316
- xAxisHeight : 30;
337
+ const subchartXAxisHeight =
338
+ config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ? xAxisHeight : 30;
317
339
  const subchartHeight = config.subchart_show && !isNonAxis ?
318
- (config.subchart_size_height + subchartXAxisHeight) : 0;
340
+ (config.subchart_size_height + subchartXAxisHeight) :
341
+ 0;
319
342
 
320
343
  // when needle is shown with legend, it need some bottom space to not overlap with legend text
321
344
  const gaugeHeight = $$.hasType("gauge") && config.arc_needle_show &&
322
- !config.gauge_fullCircle && !config.gauge_label_show ? 10 : 0;
345
+ !config.gauge_fullCircle && !config.gauge_label_show ?
346
+ 10 :
347
+ 0;
323
348
 
324
349
  const padding = $$.getCurrentPadding(true);
325
350
 
326
351
  // for main
327
- state.margin = !isNonAxis && isRotated ? {
328
- top: padding.top,
329
- right: isNonAxis ? 0 : padding.right + legendSize.right,
330
- bottom: legendSize.bottom + padding.bottom,
331
- left: subchartHeight + (isNonAxis ? 0 : padding.left)
332
- } : {
333
- top: (isFitPadding ? 0 : 4) + padding.top, // for top tick text
334
- right: isNonAxis ? 0 : padding.right + legendSize.right,
335
- bottom: gaugeHeight + subchartHeight + legendSize.bottom + padding.bottom,
336
- left: isNonAxis ? 0 : padding.left
337
- };
352
+ state.margin = !isNonAxis && isRotated ?
353
+ {
354
+ top: padding.top,
355
+ right: isNonAxis ? 0 : padding.right + legendSize.right,
356
+ bottom: legendSize.bottom + padding.bottom,
357
+ left: subchartHeight + (isNonAxis ? 0 : padding.left)
358
+ } :
359
+ {
360
+ top: (isFitPadding ? 0 : 4) + padding.top, // for top tick text
361
+ right: isNonAxis ? 0 : padding.right + legendSize.right,
362
+ bottom: gaugeHeight + subchartHeight + legendSize.bottom + padding.bottom,
363
+ left: isNonAxis ? 0 : padding.left
364
+ };
338
365
 
339
366
  state.margin = $$.getResettedPadding(state.margin);
340
367
 
341
368
  // for subchart
342
- state.margin2 = isRotated ? {
343
- top: state.margin.top,
344
- right: NaN,
345
- bottom: 20 + legendSize.bottom,
346
- left: $$.state.rotatedPadding.left
347
- } : {
348
- top: state.current.height - subchartHeight - legendSize.bottom,
349
- right: NaN,
350
- bottom: subchartXAxisHeight + legendSize.bottom,
351
- left: state.margin.left
352
- };
369
+ state.margin2 = isRotated ?
370
+ {
371
+ top: state.margin.top,
372
+ right: NaN,
373
+ bottom: 20 + legendSize.bottom,
374
+ left: $$.state.rotatedPadding.left
375
+ } :
376
+ {
377
+ top: state.current.height - subchartHeight - legendSize.bottom,
378
+ right: NaN,
379
+ bottom: subchartXAxisHeight + legendSize.bottom,
380
+ left: state.margin.left
381
+ };
353
382
 
354
383
  // for legend
355
384
  state.margin3 = {
@@ -373,10 +402,12 @@ export default {
373
402
  }
374
403
 
375
404
  state.width2 = isRotated ?
376
- state.margin.left - state.rotatedPadding.left - state.rotatedPadding.right : state.width;
405
+ state.margin.left - state.rotatedPadding.left - state.rotatedPadding.right :
406
+ state.width;
377
407
 
378
408
  state.height2 = isRotated ?
379
- state.height : state.current.height - state.margin2.top - state.margin2.bottom;
409
+ state.height :
410
+ state.current.height - state.margin2.top - state.margin2.bottom;
380
411
 
381
412
  if (state.width2 < 0) {
382
413
  state.width2 = 0;
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {$SHAPE} from "../../config/classes";
6
5
  import type {d3Selection} from "../../../types/types";
7
- import type {IDataRow} from "../data/IData";
6
+ import {$SHAPE} from "../../config/classes";
8
7
  import {addCssRules, isFunction, isString} from "../../module/util";
8
+ import type {IDataRow} from "../data/IData";
9
9
 
10
10
  export default {
11
11
  /**
@@ -21,23 +21,25 @@ export default {
21
21
  const $$ = this;
22
22
  const {config, state: {cssRule, style}} = $$;
23
23
 
24
- return config.boost_useCssRule ? (selection: d3Selection) => {
25
- selection.each((d: IDataRow) => {
26
- const res = propsFn && propsFn?.call($$, d);
27
- const shapeSelector = `${
28
- withShape ? `.${$SHAPE.shapes + $$.getTargetSelectorSuffix(d.id)}` : ""
29
- }${selector}`;
24
+ return config.boost_useCssRule ?
25
+ (selection: d3Selection) => {
26
+ selection.each((d: IDataRow) => {
27
+ const res = propsFn && propsFn?.call($$, d);
28
+ const shapeSelector = `${
29
+ withShape ? `.${$SHAPE.shapes + $$.getTargetSelectorSuffix(d.id)}` : ""
30
+ }${selector}`;
30
31
 
31
- (selector in cssRule) && style.sheet.deleteRule(cssRule[shapeSelector]);
32
- $$.state.cssRule[shapeSelector] = addCssRules(
33
- style,
34
- shapeSelector,
35
- props.filter(Boolean).map(v => (
36
- isString(res) && v.indexOf(":") === -1 ? `${v}: ${res}` : (v || "")
37
- ))
38
- );
39
- });
40
- } : () => {};
32
+ (selector in cssRule) && style.sheet.deleteRule(cssRule[shapeSelector]);
33
+ $$.state.cssRule[shapeSelector] = addCssRules(
34
+ style,
35
+ shapeSelector,
36
+ props.filter(Boolean).map(v => (
37
+ isString(res) && v.indexOf(":") === -1 ? `${v}: ${res}` : (v || "")
38
+ ))
39
+ );
40
+ });
41
+ } :
42
+ () => {};
41
43
  },
42
44
 
43
45
  /**
@@ -46,7 +48,7 @@ export default {
46
48
  * @returns {string|null}
47
49
  * @private
48
50
  */
49
- getStylePropValue(v: Function|string): string|null {
51
+ getStylePropValue(v: Function | string): string | null {
50
52
  const {config: {boost_useCssRule: useCssRule}} = this;
51
53
 
52
54
  return useCssRule ? null : isFunction(v) ? v.bind(this) : v;