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.
Files changed (67) hide show
  1. package/dist/billboard.css +19 -14
  2. package/dist/billboard.js +474 -100
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +478 -104
  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 +39 -17
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +39 -17
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +34 -14
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +34 -14
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +6 -6
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +43 -21
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +43 -21
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +38 -18
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +38 -18
  22. package/dist/theme/datalab.css +24 -20
  23. package/dist/theme/datalab.min.css +2 -2
  24. package/dist/theme/graph.css +24 -20
  25. package/dist/theme/graph.min.css +2 -2
  26. package/dist/theme/insight.css +24 -20
  27. package/dist/theme/insight.min.css +2 -2
  28. package/dist-esm/billboard.js +419 -88
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -5
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +3 -5
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  34. package/package.json +22 -22
  35. package/src/Chart/api/axis.ts +90 -25
  36. package/src/Chart/api/focus.ts +3 -2
  37. package/src/ChartInternal/Axis/Axis.ts +10 -7
  38. package/src/ChartInternal/ChartInternal.ts +31 -17
  39. package/src/ChartInternal/data/data.ts +1 -1
  40. package/src/ChartInternal/interactions/flow.ts +1 -1
  41. package/src/ChartInternal/internals/color.ts +4 -3
  42. package/src/ChartInternal/internals/format.ts +5 -1
  43. package/src/ChartInternal/internals/redraw.ts +3 -0
  44. package/src/ChartInternal/internals/text.ts +1 -1
  45. package/src/ChartInternal/internals/transform.ts +4 -1
  46. package/src/ChartInternal/internals/type.ts +5 -0
  47. package/src/ChartInternal/shape/arc.ts +41 -17
  48. package/src/ChartInternal/shape/polar.ts +132 -0
  49. package/src/ChartInternal/shape/radar.ts +4 -4
  50. package/src/config/Options/common/main.ts +19 -2
  51. package/src/config/Options/data/data.ts +3 -0
  52. package/src/config/Options/shape/polar.ts +81 -0
  53. package/src/config/classes.ts +6 -3
  54. package/src/config/const.ts +3 -0
  55. package/src/config/resolver/shape.ts +4 -0
  56. package/src/core.ts +1 -0
  57. package/src/index.esm.ts +1 -0
  58. package/src/module/generator.ts +12 -4
  59. package/src/module/util.ts +22 -9
  60. package/src/scss/billboard.scss +13 -0
  61. package/src/scss/theme/datalab.scss +13 -0
  62. package/src/scss/theme/graph.scss +13 -0
  63. package/src/scss/theme/insight.scss +13 -0
  64. package/types/bb.d.ts +1 -0
  65. package/types/chart.d.ts +8 -8
  66. package/types/options.d.ts +79 -2
  67. package/types/types.d.ts +2 -0
@@ -501,7 +501,7 @@ export default {
501
501
  * @returns {boolean}
502
502
  * @private
503
503
  */
504
- meetsLabelThreshold(ratio: number = 0, type: "bar" | "donut" | "gauge" | "pie"): boolean {
504
+ meetsLabelThreshold(ratio: number = 0, type: "bar" | "donut" | "gauge" | "pie" | "polar"): boolean {
505
505
  const $$ = this;
506
506
  const {config} = $$;
507
507
  const threshold = config[`${type}_label_threshold`] || 0;
@@ -5,7 +5,7 @@
5
5
  import {$ARC, $AXIS} from "../../config/classes";
6
6
  import {asHalfPixel} from "../../module/util";
7
7
 
8
- type TranslateParam = "main" | "context" | "legend" | "x" | "y" | "y2" | "subX" | "arc" | "radar";
8
+ type TranslateParam = "main" | "context" | "legend" | "x" | "y" | "y2" | "subX" | "arc" | "radar" | "polar";
9
9
 
10
10
  export default {
11
11
  getTranslate(target: TranslateParam, index = 0): string {
@@ -44,6 +44,9 @@ export default {
44
44
  } else if (target === "arc") {
45
45
  x = state.arcWidth / 2;
46
46
  y = state.arcHeight / 2;
47
+ } else if (target === "polar") {
48
+ x = state.arcWidth / 2;
49
+ y = state.arcHeight / 2;
47
50
  } else if (target === "radar") {
48
51
  const [width] = $$.getRadarSize();
49
52
 
@@ -187,6 +187,10 @@ export default {
187
187
  return this.isTypeOf(d, "donut");
188
188
  },
189
189
 
190
+ isPolarType(d): boolean {
191
+ return this.isTypeOf(d, "polar");
192
+ },
193
+
190
194
  isRadarType(d): boolean {
191
195
  return this.isTypeOf(d, "radar");
192
196
  },
@@ -195,6 +199,7 @@ export default {
195
199
  return this.isPieType(d) ||
196
200
  this.isDonutType(d) ||
197
201
  this.isGaugeType(d) ||
202
+ this.isPolarType(d) ||
198
203
  this.isRadarType(d);
199
204
  },
200
205
 
@@ -12,17 +12,17 @@ import {document} from "../../module/browser";
12
12
  import {$ARC, $COMMON, $FOCUS, $GAUGE} from "../../config/classes";
13
13
  import {callFn, endall, isFunction, isNumber, isObject, isUndefined, setTextValue} from "../../module/util";
14
14
  import {d3Selection} from "../../../types/types";
15
- import {IData} from "../data/IData";
15
+ import {IArcData, IData} from "../data/IData";
16
16
 
17
17
  export default {
18
18
  initPie(): void {
19
19
  const $$ = this;
20
20
  const {config} = $$;
21
21
  const dataType = config.data_type;
22
- const padding = config.pie_padding;
22
+ const padding = config[`${dataType}_padding`];
23
23
  const startingAngle = config[`${dataType}_startingAngle`] || 0;
24
24
  const padAngle = (
25
- $$.hasType("pie") && padding ? padding * 0.01 :
25
+ padding ? padding * 0.01 :
26
26
  config[`${dataType}_padAngle`]
27
27
  ) || 0;
28
28
 
@@ -37,7 +37,8 @@ export default {
37
37
  updateRadius(): void {
38
38
  const $$ = this;
39
39
  const {config, state} = $$;
40
- const padding = config.pie_padding;
40
+ const dataType = config.data_type;
41
+ const padding = config[`${dataType}_padding`];
41
42
  const w = config.gauge_width || config.donut_width;
42
43
  const gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length *
43
44
  config.gauge_arcs_minWidth;
@@ -72,7 +73,7 @@ export default {
72
73
  * @returns {object}
73
74
  * @private
74
75
  */
75
- getRadius(d): {innerRadius: number, outerRadius: number} {
76
+ getRadius(d: IArcData): {innerRadius: number, outerRadius: number} {
76
77
  const $$ = this;
77
78
  const data = d?.data;
78
79
  let {innerRadius, outerRadius} = $$.state;
@@ -194,6 +195,7 @@ export default {
194
195
  const {state} = $$;
195
196
  const singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
196
197
  const hasMultiArcGauge = $$.hasMultiArcGauge();
198
+ const hasPolar = $$.hasType("polar");
197
199
 
198
200
  const arc = d3Arc()
199
201
  .innerRadius((d: any) => {
@@ -205,8 +207,15 @@ export default {
205
207
  })
206
208
  .outerRadius((d: any) => {
207
209
  const {outerRadius} = $$.getRadius(d);
210
+ let radius = outerRadius;
208
211
 
209
- return hasMultiArcGauge ? (state.radius - singleArcWidth * d.index) : outerRadius;
212
+ if (hasMultiArcGauge) {
213
+ radius = state.radius - singleArcWidth * d.index;
214
+ } else if (hasPolar) {
215
+ radius = $$.getPolarOuterRadius(d, outerRadius);
216
+ }
217
+
218
+ return radius;
210
219
  });
211
220
 
212
221
  const newArc = function(d, withoutUpdate) {
@@ -253,6 +262,7 @@ export default {
253
262
  radius = state.radius - singleArcWidth * d.index + expandWidth;
254
263
  } else {
255
264
  const {outerRadius} = $$.getRadius(d);
265
+
256
266
  let {radiusExpanded} = state;
257
267
 
258
268
  if (state.radius !== outerRadius) {
@@ -276,6 +286,12 @@ export default {
276
286
  return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
277
287
  },
278
288
 
289
+ /**
290
+ * Set transform attributes to arc label text
291
+ * @param {Object} d Data object
292
+ * @returns {string} Translate attribute string
293
+ * @private
294
+ */
279
295
  transformForArcLabel(d): string {
280
296
  const $$ = this;
281
297
  const {config, state: {radiusExpanded}} = $$;
@@ -292,13 +308,19 @@ export default {
292
308
 
293
309
  translate = `translate(${x},${y})`;
294
310
  } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
295
- const {outerRadius} = $$.getRadius(d);
311
+ let {outerRadius} = $$.getRadius(d);
312
+
313
+ if ($$.hasType("polar")) {
314
+ outerRadius = $$.getPolarOuterRadius(d, outerRadius);
315
+ }
316
+
296
317
  const c = this.svgArc.centroid(updated);
297
318
  const [x, y] = c.map(v => (isNaN(v) ? 0 : v));
298
319
  const h = Math.sqrt(x * x + y * y);
299
320
 
300
- let ratio = ($$.hasType("donut") && config.donut_label_ratio) ||
301
- ($$.hasType("pie") && config.pie_label_ratio);
321
+ let ratio = ["donut", "pie", "polar"]
322
+ .filter($$.hasType.bind($$))
323
+ .map(v => config[`${v}_label_ratio`])?.[0];
302
324
 
303
325
  if (ratio) {
304
326
  ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
@@ -337,7 +359,7 @@ export default {
337
359
  const updated = $$.updateAngle(d);
338
360
  const ratio = $$.getRatio("arc", updated);
339
361
  const isUnderThreshold = $$.meetsLabelThreshold(ratio,
340
- ($$.hasType("donut") && "donut") || ($$.hasType("gauge") && "gauge") || ($$.hasType("pie") && "pie")
362
+ ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))?.[0]
341
363
  );
342
364
 
343
365
  if (isUnderThreshold) {
@@ -453,20 +475,20 @@ export default {
453
475
  const $$ = this;
454
476
  const {config} = $$;
455
477
 
456
- return ["pie", "donut", "gauge"]
478
+ return ["donut", "gauge", "pie", "polar"]
457
479
  .some(v => $$.hasType(v) && config[`${v}_label_show`]);
458
480
  },
459
481
 
460
482
  getArcLabelFormat(): number | string {
461
483
  const $$ = this;
462
484
  const {config} = $$;
463
- let format = config.pie_label_format;
485
+ let format = v => v;
464
486
 
465
- if ($$.hasType("gauge")) {
466
- format = config.gauge_label_format;
467
- } else if ($$.hasType("donut")) {
468
- format = config.donut_label_format;
469
- }
487
+ ["donut", "gauge", "pie", "polar"]
488
+ .filter($$.hasType.bind($$))
489
+ .forEach(v => {
490
+ format = config[`${v}_label_format`];
491
+ });
470
492
 
471
493
  return isFunction(format) ? format.bind($$.api) : format;
472
494
  },
@@ -611,6 +633,7 @@ export default {
611
633
  const interpolated = interpolate(t);
612
634
 
613
635
  interpolated.data = d.data; // data.id will be updated by interporator
636
+
614
637
  return $$.getArc(interpolated, true);
615
638
  };
616
639
  })
@@ -646,6 +669,7 @@ export default {
646
669
  // bind arc events
647
670
  hasInteraction && $$.bindArcEvent(mainArc);
648
671
 
672
+ $$.hasType("polar") && $$.redrawPolar();
649
673
  $$.hasType("gauge") && $$.redrawBackgroundArcs();
650
674
 
651
675
  $$.redrawArcText(duration);
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ import {$LEVEL} from "../../config/classes";
6
+ import {getRange} from "../../module/util";
7
+ import {IArcData, IData} from "../data/IData";
8
+
9
+ /**
10
+ * Get data max value
11
+ * @param {object} $$ ChartInternal instance
12
+ * @returns {number} max value
13
+ * @private
14
+ */
15
+ function getDataMax($$): number {
16
+ const levelMax = $$.config.polar_level_max;
17
+ let dataMax = $$.getMinMaxData().max[0].value;
18
+
19
+ // Apply level max only when is greater than the data max value
20
+ if (levelMax && levelMax > dataMax) {
21
+ dataMax = levelMax;
22
+ }
23
+
24
+ return dataMax;
25
+ }
26
+
27
+ export default {
28
+ /**
29
+ * Initialize polar
30
+ * @private
31
+ */
32
+ initPolar(): void {
33
+ const $$ = this;
34
+ const {$el: {arcs}, config} = $$;
35
+ const levelTextShow: boolean = config.polar_level_text_show;
36
+ const levelTextBgColor: string = config.polar_level_text_backgroundColor;
37
+
38
+ // append <g> for level
39
+ arcs.levels = arcs.append("g")
40
+ .attr("class", $LEVEL.levels);
41
+
42
+ // set level text background color
43
+ if (levelTextShow && levelTextBgColor) {
44
+ $$.generateDataLabelBackgroundColorFilter(levelTextBgColor);
45
+ }
46
+ },
47
+
48
+ /**
49
+ * Get polar outer radius according to the data value
50
+ * @param {object} d Data object
51
+ * @param {numbet} outerRadius Outer radius
52
+ * @returns {number} outer radius
53
+ * @private
54
+ */
55
+ getPolarOuterRadius(d: IArcData, outerRadius: number): number {
56
+ const dataMax = getDataMax(this);
57
+
58
+ return (d?.data.values[0].value / dataMax) * outerRadius;
59
+ },
60
+
61
+ /**
62
+ * Update polar based on given data array
63
+ * @param {object} targets Data object
64
+ * @private
65
+ */
66
+ updateTargetsForPolar(targets: IData[]): void {
67
+ // borrow from Arc
68
+ this.updateTargetsForArc(targets);
69
+ },
70
+
71
+ /**
72
+ * Called whenever redraw happens
73
+ * @private
74
+ */
75
+ redrawPolar(): void {
76
+ const $$ = this;
77
+ const {config} = $$;
78
+
79
+ config.polar_level_show && $$.updatePolarLevel();
80
+ },
81
+
82
+ /**
83
+ * Update polar level circle
84
+ * @private
85
+ */
86
+ updatePolarLevel(): void {
87
+ const $$ = this;
88
+ const {config, state, $el: {arcs: {levels}}} = $$;
89
+
90
+ const depth: number = config.polar_level_depth;
91
+ const dataMax = getDataMax($$);
92
+ const levelData = getRange(0, depth);
93
+ const outerRadius = state.radius;
94
+ const levelRatio = levelData.map(l => outerRadius * ((l + 1) / depth));
95
+ const levelTextFormat = (config.polar_level_text_format || function() {}).bind($$.api);
96
+
97
+ const level = levels
98
+ .selectAll(`.${$LEVEL.level}`)
99
+ .data(levelData);
100
+
101
+ level.exit().remove();
102
+
103
+ const levelEnter = level.enter().append("g")
104
+ .attr("class", (d, i) => `${$LEVEL.level} ${$LEVEL.level}-${i}`);
105
+
106
+ // cx, cy, translate: Set center as origin (0,0) so that it can share same center with arcs
107
+ levelEnter.append("circle");
108
+
109
+ levelEnter
110
+ .merge(level)
111
+ .selectAll("circle")
112
+ .style("visibility", config.polar_level_show ? null : "hidden")
113
+ .attr("cx", 0)
114
+ .attr("cy", 0)
115
+ .attr("r", d => levelRatio[d]);
116
+
117
+ if (config.polar_level_text_show) {
118
+ const levelTextBackgroundColor = config.polar_level_text_backgroundColor;
119
+ const defsId = `#${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(levelTextBackgroundColor)}`;
120
+
121
+ levelEnter.append("text")
122
+ .style("text-anchor", "middle");
123
+
124
+ levelEnter
125
+ .merge(level)
126
+ .selectAll("text")
127
+ .attr("dy", d => -levelRatio[d] + 5)
128
+ .attr("filter", levelTextBackgroundColor ? `url(${defsId})` : null)
129
+ .text(d => levelTextFormat(dataMax / levelData.length * (d + 1)));
130
+ }
131
+ }
132
+ };
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import {select as d3Select} from "d3-selection";
6
6
  import {KEY} from "../../module/Cache";
7
- import {$AXIS, $COMMON, $RADAR, $SHAPE, $TEXT} from "../../config/classes";
7
+ import {$AXIS, $COMMON, $LEVEL, $RADAR, $SHAPE, $TEXT} from "../../config/classes";
8
8
  import {getMinMax, getRange, isDefined, isEmpty, isNumber, isUndefined, setTextValue, toArray} from "../../module/util";
9
9
 
10
10
  /**
@@ -40,7 +40,7 @@ export default {
40
40
 
41
41
  // level
42
42
  $el.radar.levels = $el.radar.append("g")
43
- .attr("class", $RADAR.levels);
43
+ .attr("class", $LEVEL.levels);
44
44
 
45
45
  // axis
46
46
  $el.radar.axes = $el.radar.append("g")
@@ -176,13 +176,13 @@ export default {
176
176
  });
177
177
 
178
178
  const level = radarLevels
179
- .selectAll(`.${$RADAR.level}`)
179
+ .selectAll(`.${$LEVEL.level}`)
180
180
  .data(levelData);
181
181
 
182
182
  level.exit().remove();
183
183
 
184
184
  const levelEnter = level.enter().append("g")
185
- .attr("class", (d, i) => `${$RADAR.level} ${$RADAR.level}-${i}`);
185
+ .attr("class", (d, i) => `${$LEVEL.level} ${$LEVEL.level}-${i}`);
186
186
 
187
187
  levelEnter.append("polygon")
188
188
  .style("visibility", config.radar_level_show ? null : "hidden");
@@ -151,6 +151,21 @@ export default {
151
151
  */
152
152
  resize_auto: true,
153
153
 
154
+ /**
155
+ * Set a callback to execute when the chart is clicked.
156
+ * @name onclick
157
+ * @memberof Options
158
+ * @type {Function}
159
+ * @default undefined
160
+ * @example
161
+ * onclick: function(event) {
162
+ * this; // chart instance itself
163
+ * event; // native event object
164
+ * ...
165
+ * }
166
+ */
167
+ onclick: <(() => void)|undefined> undefined,
168
+
154
169
  /**
155
170
  * Set a callback to execute when mouse/touch enters the chart.
156
171
  * @name onover
@@ -158,8 +173,9 @@ export default {
158
173
  * @type {Function}
159
174
  * @default undefined
160
175
  * @example
161
- * onover: function() {
176
+ * onover: function(event) {
162
177
  * this; // chart instance itself
178
+ * event; // native event object
163
179
  * ...
164
180
  * }
165
181
  */
@@ -172,8 +188,9 @@ export default {
172
188
  * @type {Function}
173
189
  * @default undefined
174
190
  * @example
175
- * onout: function() {
191
+ * onout: function(event) {
176
192
  * this; // chart instance itself
193
+ * event; // native event object
177
194
  * ...
178
195
  * }
179
196
  */
@@ -93,6 +93,7 @@ export default {
93
93
  * - gauge
94
94
  * - line
95
95
  * - pie
96
+ * - polar
96
97
  * - radar
97
98
  * - scatter
98
99
  * - spline
@@ -121,6 +122,7 @@ export default {
121
122
  * gauge,
122
123
  * line,
123
124
  * pie,
125
+ * polar,
124
126
  * radar,
125
127
  * scatter,
126
128
  * spline,
@@ -167,6 +169,7 @@ export default {
167
169
  * gauge,
168
170
  * line,
169
171
  * pie,
172
+ * polar,
170
173
  * radar,
171
174
  * scatter,
172
175
  * spline,
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ /**
6
+ * x Axis config options
7
+ */
8
+ export default {
9
+ /**
10
+ * Set polar options
11
+ * @name polar
12
+ * @memberof Options
13
+ * @type {object}
14
+ * @property {object} polar Polar object
15
+ * @property {boolean} [polar.label.show=true] Show or hide label on each polar piece.
16
+ * @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
17
+ * @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
18
+ * @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
19
+ * @property {number} [polar.level.depth=3] Set the level depth.
20
+ * @property {boolean} [polar.level.show=true] Show or hide level.
21
+ * @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
22
+ * @property {Function} [polar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
23
+ * @property {boolean} [polar.level.text.show=true] Show or hide level text.
24
+ * @property {number} [polar.padAngle=0] Set padding between data.
25
+ * @property {number} [polar.padding=0] Sets the gap between pie arcs.
26
+ * @property {number} [polar.startingAngle=0] Set starting angle where data draws.
27
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
28
+ * @example
29
+ * polar: {
30
+ * label: {
31
+ * show: false,
32
+ * format: function(value, ratio, id) {
33
+ * return d3.format("$")(value);
34
+ *
35
+ * // to multiline, return with '\n' character
36
+ * // return value +"%\nLine1\n2Line2";
37
+ * },
38
+ *
39
+ * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
40
+ * // if data value is below than 0.1, text label will be hidden.
41
+ * threshold: 0.1,
42
+ *
43
+ * // set ratio callback. Should return ratio value
44
+ * ratio: function(d, radius, h) {
45
+ * ...
46
+ * return ratio;
47
+ * },
48
+ * // or set ratio number
49
+ * ratio: 0.5
50
+ * },
51
+ * level: {
52
+ * depth: 3,
53
+ * max: 500,
54
+ * show: true,
55
+ * text: {
56
+ * format: function(x) {
57
+ * return x + "%";
58
+ * },
59
+ * show: true,
60
+ * backgroundColor: "red"
61
+ * }
62
+ * },
63
+ * padAngle: 0.1,
64
+ * padding: 0,
65
+ * startingAngle: 1
66
+ * }
67
+ */
68
+ polar_label_show: true,
69
+ polar_label_format: <(() => number|string)|undefined> undefined,
70
+ polar_label_threshold: 0.05,
71
+ polar_label_ratio: <(() => number)|undefined> undefined,
72
+ polar_level_depth: 3,
73
+ polar_level_max: <number|undefined> undefined,
74
+ polar_level_show: true,
75
+ polar_level_text_backgroundColor: "#fff",
76
+ polar_level_text_format: (x: number) => (x % 1 === 0 ? x : x.toFixed(2)),
77
+ polar_level_text_show: true,
78
+ polar_padAngle: 0,
79
+ polar_padding: 0,
80
+ polar_startingAngle: 0
81
+ };
@@ -126,13 +126,16 @@ export const $GRID = {
126
126
  ygrids: "bb-ygrids"
127
127
  };
128
128
 
129
- export const $RADAR = {
130
- chartRadar: "bb-chart-radar",
131
- chartRadars: "bb-chart-radars",
129
+ export const $LEVEL = {
132
130
  level: "bb-level",
133
131
  levels: "bb-levels"
134
132
  };
135
133
 
134
+ export const $RADAR = {
135
+ chartRadar: "bb-chart-radar",
136
+ chartRadars: "bb-chart-radars"
137
+ };
138
+
136
139
  export const $REGION = {
137
140
  region: "bb-region",
138
141
  regions: "bb-regions"
@@ -19,6 +19,7 @@ export const TYPE = {
19
19
  GAUGE: "gauge",
20
20
  LINE: "line",
21
21
  PIE: "pie",
22
+ POLAR: "polar",
22
23
  RADAR: "radar",
23
24
  SCATTER: "scatter",
24
25
  SPLINE: "spline",
@@ -42,6 +43,7 @@ export const TYPE_METHOD_NEEDED = {
42
43
  GAUGE: "initArc",
43
44
  LINE: "initLine",
44
45
  PIE: "initArc",
46
+ POLAR: "initPolar",
45
47
  RADAR: "initCircle",
46
48
  SCATTER: "initCircle",
47
49
  SPLINE: "initLine",
@@ -68,6 +70,7 @@ export const TYPE_BY_CATEGORY = {
68
70
  TYPE.PIE,
69
71
  TYPE.DONUT,
70
72
  TYPE.GAUGE,
73
+ TYPE.POLAR,
71
74
  TYPE.RADAR
72
75
  ],
73
76
  Line: [
@@ -24,6 +24,7 @@ import shapeGauge from "../../ChartInternal/shape/gauge";
24
24
  import shapeBubble from "../../ChartInternal/shape/bubble";
25
25
  import shapeLine from "../../ChartInternal/shape/line";
26
26
  import shapePoint from "../../ChartInternal/shape/point";
27
+ import shapePolar from "../../ChartInternal/shape/polar";
27
28
  import shapeRadar from "../../ChartInternal/shape/radar";
28
29
 
29
30
  // Options
@@ -40,6 +41,7 @@ import optSpline from "../Options/shape/spline";
40
41
  import optDonut from "../Options/shape/donut";
41
42
  import optGauge from "../Options/shape/gauge";
42
43
  import optPie from "../Options/shape/pie";
44
+ import optPolar from "../Options/shape/polar";
43
45
  import optRadar from "../Options/shape/radar";
44
46
 
45
47
  export {
@@ -55,6 +57,7 @@ export {
55
57
  gauge,
56
58
  line,
57
59
  pie,
60
+ polar,
58
61
  radar,
59
62
  scatter,
60
63
  spline,
@@ -121,6 +124,7 @@ let step = (): string => (extendLine(), (step = () => TYPE.STEP)());
121
124
  let donut = (): string => (extendArc(undefined, [optDonut]), (donut = () => TYPE.DONUT)());
122
125
  let gauge = (): string => (extendArc([shapeGauge], [optGauge]), (gauge = () => TYPE.GAUGE)());
123
126
  let pie = (): string => (extendArc(undefined, [optPie]), (pie = () => TYPE.PIE)());
127
+ let polar = (): string => (extendArc([shapePolar], [optPolar]), (polar = () => TYPE.POLAR)());
124
128
  let radar = (): string => (
125
129
  extendArc([shapePoint, shapeRadar], [optPoint, optRadar]), (radar = () => TYPE.RADAR)()
126
130
  );
package/src/core.ts CHANGED
@@ -70,6 +70,7 @@ const bb = {
70
70
  * gauge,
71
71
  * line,
72
72
  * pie,
73
+ * polar,
73
74
  * radar,
74
75
  * scatter,
75
76
  * spline,
package/src/index.esm.ts CHANGED
@@ -16,6 +16,7 @@ export {
16
16
  gauge,
17
17
  line,
18
18
  pie,
19
+ polar,
19
20
  radar,
20
21
  scatter,
21
22
  spline,
@@ -2,6 +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 {d3Transition} from "../../types/types";
5
6
  import {window} from "./browser";
6
7
  import {isArray} from "./util";
7
8
 
@@ -38,17 +39,24 @@ export function generateResize() {
38
39
  return callResizeFn;
39
40
  }
40
41
 
42
+ type Transition = boolean | d3Transition;
43
+
41
44
  /**
42
45
  * Generate transition queue function
43
46
  * @returns {Function}
44
47
  * @private
45
48
  */
46
49
  export function generateWait() {
47
- let transitionsToWait: any = [];
48
- const f = function(t, callback) {
50
+ let transitionsToWait: Transition[] = [];
51
+
52
+ // 'f' is called as selection.call(f, ...);
53
+ const f = function(selection: d3Transition, callback: Function) {
49
54
  let timer;
50
55
 
51
- // eslint-disable-next-line
56
+ /**
57
+ * Check if transition is complete
58
+ * @private
59
+ */
52
60
  function loop() {
53
61
  let done = 0;
54
62
 
@@ -77,7 +85,7 @@ export function generateWait() {
77
85
  loop();
78
86
  };
79
87
 
80
- f.add = function(t) {
88
+ f.add = function(t: Transition | Transition[]) {
81
89
  isArray(t) ?
82
90
  (transitionsToWait = transitionsToWait.concat(t)) :
83
91
  transitionsToWait.push(t);