billboard.js 3.10.3 → 3.11.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 (82) hide show
  1. package/README.md +0 -1
  2. package/dist/billboard.css +5 -4
  3. package/dist/billboard.js +598 -220
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +2 -2
  6. package/dist/billboard.pkgd.js +2828 -2456
  7. package/dist/billboard.pkgd.min.js +2 -4
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +31 -15
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +31 -15
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +30 -15
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +30 -15
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2222 -2214
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2252 -2228
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2253 -2229
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2253 -2230
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2259 -2238
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
  28. package/dist/theme/dark.css +7 -7
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +7 -7
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +7 -7
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +7 -7
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +7 -7
  37. package/dist/theme/modern.min.css +2 -2
  38. package/dist-esm/billboard.js +517 -180
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -4
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +7 -9
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +3 -4
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +3 -4
  44. package/package.json +42 -46
  45. package/src/Chart/api/zoom.ts +5 -20
  46. package/src/ChartInternal/Axis/Axis.ts +5 -3
  47. package/src/ChartInternal/Axis/AxisRenderer.ts +14 -0
  48. package/src/ChartInternal/ChartInternal.ts +1 -1
  49. package/src/ChartInternal/data/data.ts +12 -5
  50. package/src/ChartInternal/data/load.ts +37 -1
  51. package/src/ChartInternal/interactions/eventrect.ts +11 -4
  52. package/src/ChartInternal/interactions/interaction.ts +2 -1
  53. package/src/ChartInternal/interactions/zoom.ts +28 -0
  54. package/src/ChartInternal/internals/domain.ts +24 -1
  55. package/src/ChartInternal/internals/legend.ts +28 -2
  56. package/src/ChartInternal/internals/scale.ts +3 -3
  57. package/src/ChartInternal/internals/size.axis.ts +8 -3
  58. package/src/ChartInternal/internals/size.ts +14 -1
  59. package/src/ChartInternal/internals/tooltip.ts +12 -6
  60. package/src/ChartInternal/internals/transform.ts +6 -2
  61. package/src/ChartInternal/internals/type.ts +1 -1
  62. package/src/ChartInternal/shape/arc.ts +110 -34
  63. package/src/ChartInternal/shape/gauge.ts +8 -4
  64. package/src/ChartInternal/shape/radar.ts +58 -45
  65. package/src/config/Options/axis/x.ts +27 -1
  66. package/src/config/Options/axis/y2.ts +13 -0
  67. package/src/config/Options/common/legend.ts +17 -0
  68. package/src/config/Options/common/tooltip.ts +1 -0
  69. package/src/config/Options/shape/arc.ts +40 -3
  70. package/src/config/Options/shape/gauge.ts +23 -2
  71. package/src/config/Options/shape/pie.ts +2 -2
  72. package/src/config/classes.ts +1 -0
  73. package/src/module/Cache.ts +1 -0
  74. package/src/module/util.ts +16 -2
  75. package/src/scss/billboard.scss +2 -1
  76. package/src/scss/theme/dark.scss +2 -1
  77. package/src/scss/theme/datalab.scss +2 -1
  78. package/src/scss/theme/graph.scss +2 -1
  79. package/src/scss/theme/insight.scss +2 -1
  80. package/src/scss/theme/modern.scss +2 -1
  81. package/types/options.d.ts +28 -4
  82. package/types/options.shape.d.ts +44 -0
@@ -5,7 +5,7 @@
5
5
  import {select as d3Select} from "d3-selection";
6
6
  import {KEY} from "../../module/Cache";
7
7
  import {$AXIS, $COMMON, $LEVEL, $RADAR, $SHAPE, $TEXT} from "../../config/classes";
8
- import {getMinMax, getRange, isDefined, isEmpty, isNumber, isUndefined, setTextValue, toArray} from "../../module/util";
8
+ import {getMinMax, getPathBox, getRange, isDefined, isEmpty, isNumber, isUndefined, setTextValue, toArray} from "../../module/util";
9
9
 
10
10
  /**
11
11
  * Get the position value
@@ -27,7 +27,8 @@ function getPosition(isClockwise: boolean, type: "x" | "y", edge: number, pos: n
27
27
  }
28
28
 
29
29
  // cache key
30
- const cacheKey = KEY.radarPoints;
30
+ const cacheKeyPoints = KEY.radarPoints;
31
+ const cacheKeyTextWidth = KEY.radarTextWidth;
31
32
 
32
33
  export default {
33
34
  initRadar(): void {
@@ -51,6 +52,14 @@ export default {
51
52
  .attr("class", $SHAPE.shapes);
52
53
 
53
54
  current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
55
+
56
+ if (config.radar_axis_text_show) {
57
+ config.interaction_enabled && $$.bindRadarEvent();
58
+
59
+ // it needs to calculate dimension at the initialization
60
+ $$.updateRadarLevel();
61
+ $$.updateRadarAxes();
62
+ }
54
63
  }
55
64
  },
56
65
 
@@ -58,7 +67,7 @@ export default {
58
67
  const $$ = this;
59
68
  const {config, state: {arcWidth, arcHeight}} = $$;
60
69
  const padding = config.axis_x_categories.length < 4 ? -20 : 10;
61
- const size = (Math.min(arcWidth, arcHeight) - padding) / 2;
70
+ const size = ((Math.min(arcWidth, arcHeight) - padding) / 2);
62
71
 
63
72
  return [size, size];
64
73
  },
@@ -102,7 +111,7 @@ export default {
102
111
  const targets = $$.data.targets;
103
112
 
104
113
  const [width, height] = $$.getRadarSize();
105
- const points = $$.cache.get(cacheKey) || {};
114
+ const points = $$.cache.get(cacheKeyPoints) || {};
106
115
  const size = points._size;
107
116
 
108
117
  // recalculate position only when the previous dimension has been changed
@@ -114,7 +123,7 @@ export default {
114
123
  });
115
124
 
116
125
  points._size = {width, height};
117
- $$.cache.add(cacheKey, points);
126
+ $$.cache.add(cacheKeyPoints, points);
118
127
  }
119
128
  },
120
129
 
@@ -136,7 +145,7 @@ export default {
136
145
  },
137
146
 
138
147
  generateGetRadarPoints(): Function {
139
- const points = this.cache.get(cacheKey);
148
+ const points = this.cache.get(cacheKeyPoints);
140
149
 
141
150
  return (d, i) => {
142
151
  const point = points[d.id][i];
@@ -250,6 +259,7 @@ export default {
250
259
  // axis text
251
260
  if (config.radar_axis_text_show) {
252
261
  const {x = 0, y = 0} = config.radar_axis_text_position;
262
+ const textWidth = $$.cache.get(cacheKeyTextWidth) || 0;
253
263
 
254
264
  axis.select("text")
255
265
  .style("text-anchor", "middle")
@@ -288,67 +298,70 @@ export default {
288
298
 
289
299
  return `translate(${posX} ${posY})`;
290
300
  });
291
- }
292
301
 
293
- $$.bindRadarEvent();
302
+ if (!textWidth) {
303
+ const widths = [radar.axes, radar.levels].map(v => getPathBox(v.node()).width);
304
+
305
+ if (widths.every(v => v > 0)) {
306
+ $$.cache.add(cacheKeyTextWidth, widths[0] - widths[1]);
307
+ }
308
+ }
309
+ }
294
310
  },
295
311
 
296
312
  bindRadarEvent(): void {
297
313
  const $$ = this;
298
- const {config, state, $el: {radar, svg}} = $$;
314
+ const {state, $el: {radar, svg}} = $$;
299
315
  const focusOnly = $$.isPointFocusOnly();
300
316
  const {inputType, transiting} = state;
317
+ const isMouse = inputType === "mouse";
301
318
 
302
- if (config.interaction_enabled) {
303
- const isMouse = inputType === "mouse";
304
-
305
- const hide = event => {
306
- state.event = event;
319
+ const hide = event => {
320
+ state.event = event;
307
321
 
308
- // const index = getIndex(event);
322
+ // const index = getIndex(event);
309
323
 
310
- const index = $$.getDataIndexFromEvent(event);
311
- const noIndex = isUndefined(index);
324
+ const index = $$.getDataIndexFromEvent(event);
325
+ const noIndex = isUndefined(index);
312
326
 
313
- if (isMouse || noIndex) {
314
- $$.hideTooltip();
327
+ if (isMouse || noIndex) {
328
+ $$.hideTooltip();
315
329
 
316
- focusOnly ?
317
- $$.hideCircleFocus() :
318
- $$.unexpandCircles();
330
+ focusOnly ?
331
+ $$.hideCircleFocus() :
332
+ $$.unexpandCircles();
319
333
 
320
- if (isMouse) {
321
- $$.setOverOut(false, index);
322
- } else if (noIndex) {
323
- $$.callOverOutForTouch();
324
- }
334
+ if (isMouse) {
335
+ $$.setOverOut(false, index);
336
+ } else if (noIndex) {
337
+ $$.callOverOutForTouch();
325
338
  }
326
- };
339
+ }
340
+ };
327
341
 
328
- radar.axes.selectAll("text")
329
- .on(isMouse ? "mouseover " : "touchstart", event => {
330
- if (transiting) { // skip while transiting
331
- return;
332
- }
342
+ radar.axes
343
+ .on(isMouse ? "mouseover " : "touchstart", event => {
344
+ if (transiting) { // skip while transiting
345
+ return;
346
+ }
333
347
 
334
- state.event = event;
335
- const index = $$.getDataIndexFromEvent(event);
348
+ state.event = event;
349
+ const index = $$.getDataIndexFromEvent(event);
336
350
 
337
- $$.selectRectForSingle(svg.node(), index);
338
- isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
339
- })
340
- .on("mouseout", isMouse ? hide : null);
351
+ $$.selectRectForSingle(svg.node(), index);
352
+ isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
353
+ })
354
+ .on("mouseout", isMouse ? hide : null);
341
355
 
342
- if (!isMouse) {
343
- svg.on("touchstart", hide);
344
- }
356
+ if (!isMouse) {
357
+ svg.on("touchstart", hide);
345
358
  }
346
359
  },
347
360
 
348
361
  updateRadarShape(): void {
349
362
  const $$ = this;
350
363
  const targets = $$.data.targets.filter(d => $$.isRadarType(d));
351
- const points = $$.cache.get(cacheKey);
364
+ const points = $$.cache.get(cacheKeyPoints);
352
365
 
353
366
  const areas = $$.$el.radar.shapes
354
367
  .selectAll("polygon")
@@ -377,7 +390,7 @@ export default {
377
390
  * @private
378
391
  */
379
392
  radarCircleX(d): number {
380
- return this.cache.get(cacheKey)[d.id][d.index][0];
393
+ return this.cache.get(cacheKeyPoints)[d.id][d.index][0];
381
394
  },
382
395
 
383
396
  /**
@@ -387,6 +400,6 @@ export default {
387
400
  * @private
388
401
  */
389
402
  radarCircleY(d): number {
390
- return this.cache.get(cacheKey)[d.id][d.index][1];
403
+ return this.cache.get(cacheKeyPoints)[d.id][d.index][1];
391
404
  }
392
405
  };
@@ -259,6 +259,32 @@ export default {
259
259
  */
260
260
  axis_x_tick_text_show: true,
261
261
 
262
+ /**
263
+ * Set the first/last axis tick text to be positioned inside of the chart on non-rotated axis.
264
+ * @name axis․x․tick․text․inner
265
+ * @memberof Options
266
+ * @type {boolean|object}
267
+ * @default false
268
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickInner)
269
+ * @example
270
+ * axis: {
271
+ * x: {
272
+ * tick: {
273
+ * text: {
274
+ * inner: true,
275
+ *
276
+ * // or specify each position of the first and last tick text
277
+ * inner: {
278
+ * first: true,
279
+ * last: true
280
+ * }
281
+ * }
282
+ * }
283
+ * }
284
+ * }
285
+ */
286
+ axis_x_tick_text_inner: <{first?: boolean, last?: boolean}|boolean> false,
287
+
262
288
  /**
263
289
  * Set the x Axis tick text's position relatively its original position
264
290
  * @name axis․x․tick․text․position
@@ -444,7 +470,7 @@ export default {
444
470
  axis_x_tick_width: <number|null> null,
445
471
 
446
472
  /**
447
- * Set to display system tooltip(via 'title' attribute) for tick text
473
+ * Set to display system tooltip(via `<title>` element) for tick text
448
474
  * - **NOTE:** Only available for category axis type (`axis.x.type='category'`)
449
475
  * @name axis․x․tick․tooltip
450
476
  * @memberof Options
@@ -6,6 +6,19 @@
6
6
  * y2 Axis config options
7
7
  */
8
8
  export default {
9
+ /**
10
+ * Set clip-path attribute for y2 axis element
11
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
12
+ * @name axis․y2․clipPath
13
+ * @memberof Options
14
+ * @type {boolean}
15
+ * @default true
16
+ * @example
17
+ * // don't set 'clip-path' attribute
18
+ * clipPath: false
19
+ */
20
+ axis_y2_clipPath: true,
21
+
9
22
  /**
10
23
  * Show or hide y2 axis.
11
24
  * - **NOTE**:
@@ -66,7 +66,12 @@ export default {
66
66
  * - **Available Values:**
67
67
  * - circle
68
68
  * - rectangle
69
+ * @property {boolean} [legend.format] Set formatter function for legend text.
70
+ * The argument:<br>
71
+ * - `id`: legend text(which is data id) value
72
+ * @property {boolean} [legend.tooltip=false] Show full legend text value using system tooltip(via `<title>` element).
69
73
  * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
74
+ * @see [Demo: format](https://naver.github.io/billboard.js/demo/#Legend.LegendFormat)
70
75
  * @see [Demo: item.interaction](https://naver.github.io/billboard.js/demo/#Legend.LegendItemInteraction)
71
76
  * @see [Demo: item.tile.type](https://naver.github.io/billboard.js/demo/#Legend.LegendItemTileType)
72
77
  * @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
@@ -129,6 +134,16 @@ export default {
129
134
  * r: 10
130
135
  * }
131
136
  * },
137
+ * format: function(id) {
138
+ * // set ellipsis string when length is > 5
139
+ * // to get full legend value, combine with 'legend.tooltip=true'
140
+ * if (id.length > 5) {
141
+ * id = id.substr(0, 5) + "...";
142
+ * }
143
+ *
144
+ * return id;
145
+ * },
146
+ * tooltip: true,
132
147
  * usePoint: true
133
148
  * }
134
149
  */
@@ -151,8 +166,10 @@ export default {
151
166
  legend_item_tile_height: 10,
152
167
  legend_item_tile_r: 5,
153
168
  legend_item_tile_type: <"rectangle"|"circle"> "rectangle",
169
+ legend_format: <Function|undefined> undefined,
154
170
  legend_padding: 0,
155
171
  legend_position: <"bottom"|"right"|"inset"> "bottom",
156
172
  legend_show: true,
173
+ legend_tooltip: false,
157
174
  legend_usePoint: false
158
175
  };
@@ -56,6 +56,7 @@ export default {
56
56
  * - **{=CLASS_TOOLTIP_NAME}**: default tooltip data class name (ex. `bb-tooltip-name-data1`)
57
57
  * - **{=TITLE}**: title value.
58
58
  * - **{=COLOR}**: data color.
59
+ * - **{=NAME}**: data id value.
59
60
  * - **{=VALUE}**: data value.
60
61
  * @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
61
62
  * - **NOTE:** It should contain `{ key: Array, ... }` value
@@ -36,11 +36,23 @@ export default {
36
36
  * @property {number} [arc.needle.bottom.ry=1] Set needle bottom [ry radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
37
37
  * @property {number} [arc.needle.bottom.width=15] Set needle bottom width in pixel.
38
38
  * @property {number} [arc.needle.bottom.len=0] Set needle bottom length in pixel. Setting this value, will make bottom larger starting from center.
39
+ * @property {object} [arc.rangeText] Set rangeText options.
40
+ * @property {Array} [arc.rangeText.values] Set range text values to be shown around Arc.
41
+ * - When `unit: 'absolute'`: Given values are treated as absolute values.
42
+ * - When `unit: '%'`: Given values are treated as percentages.
43
+ * @property {string} [arc.rangeText.unit="absolute"] Specify the range text unit.
44
+ * - "absolute": Show absolute value
45
+ * - "%": Show percentage value
46
+ * @property {boolean} [arc.rangeText.fiexed=false] Set if range text shown will be fixed w/o data toggle update. Only available for gauge chart.
47
+ * @property {Function} [arc.rangeText.format] Set format function for the range text.
48
+ * @property {number} [arc.rangeText.position] Set position function or object for the range text.
39
49
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
40
- * @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
41
50
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
42
51
  * @see [Demo: Donut needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
43
- * @see [Demo: Gauge needle](https://naver.github.io/billboard.js/demo/##GaugeChartOptions.GaugeNeedle)
52
+ * @see [Demo: Donut RangeText](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
53
+ * @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
54
+ * @see [Demo: Gauge needle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeNeedle)
55
+ * @see [Demo: Gauge RangeText](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeRangeText)
44
56
  * @example
45
57
  * arc: {
46
58
  * cornerRadius: 12,
@@ -97,6 +109,21 @@ export default {
97
109
  * width: 10
98
110
  * len: 10
99
111
  * }
112
+ * },
113
+ *
114
+ * rangeText: {
115
+ * values: [15, 30, 50, 75, 95],
116
+ * unit: "%",
117
+ * fixed: false, // only available for gauge chart
118
+ * format: function(v) {
119
+ * return v === 15 ? "Fifteen" : v;
120
+ * },
121
+ *
122
+ * position: function(v) {
123
+ * return v === 15 ? {x: 20, y: 10} : null; // can return one props value also.
124
+ * },
125
+ * position: {x: 10, y: 15},
126
+ * position: {x: 10}
100
127
  * }
101
128
  * }
102
129
  */
@@ -115,5 +142,15 @@ export default {
115
142
  arc_needle_bottom_rx: 1,
116
143
  arc_needle_bottom_ry: 1,
117
144
  arc_needle_bottom_width: 15,
118
- arc_needle_bottom_len: 0
145
+ arc_needle_bottom_len: 0,
146
+ arc_rangeText_values: <number[]|undefined> undefined,
147
+ arc_rangeText_unit: <"absolute"|"%"> "absolute",
148
+ arc_rangeText_fixed: false,
149
+ arc_rangeText_format: <
150
+ ((v: number) => number)|undefined
151
+ > undefined,
152
+ arc_rangeText_position: <
153
+ ((v: number) => {x?: number; y?: number})|
154
+ {x?: number, y?: number}|undefined
155
+ > undefined
119
156
  };
@@ -15,16 +15,20 @@ export default {
15
15
  * @property {boolean} [gauge.background=""] Set background color. (The `.bb-chart-arcs-background` element)
16
16
  * @property {boolean} [gauge.fullCircle=false] Show full circle as donut. When set to 'true', the max label will not be showed due to start and end points are same location.
17
17
  * @property {boolean} [gauge.label.show=true] Show or hide label on gauge.
18
+ * @property {Function} [gauge.label.extents] Set customized min/max label text.
18
19
  * @property {Function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
19
20
  * Will pass following arguments to the given function:
20
21
  * - value {number}: absolute value
21
22
  * - ratio {number}: value's ratio
22
23
  * - id {string}: data's id value
23
- * @property {Function} [gauge.label.extents] Set customized min/max label text.
24
+ * @property {number|Function} [gauge.label.ratio=undefined] Set ratio of labels position.
24
25
  * @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
25
26
  * @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
26
27
  * @property {number} [gauge.expand.rate=0.98] Set expand rate.
27
28
  * @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
29
+ * @property {boolean} [gauge.enforceMinMax=false] Enforce to given min/max value.
30
+ * - When `gauge.min=50` and given value is `30`, gauge will render as empty value.
31
+ * - When `gauge.max=100` and given value is `120`, gauge will render till 100, not surpassing max value.
28
32
  * @property {number} [gauge.min=0] Set min value of the gauge.
29
33
  * @property {number} [gauge.max=100] Set max value of the gauge.
30
34
  * @property {number} [gauge.startingAngle=-1 * Math.PI / 2] Set starting angle where data draws.
@@ -55,8 +59,10 @@ export default {
55
59
  * - single
56
60
  * - multi
57
61
  * @property {number} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
62
+ * @see [Demo: enforceMinMax, min/max](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeMinMax)
58
63
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
59
64
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
65
+ * @see [Demo: labelRatio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
60
66
  * @example
61
67
  * gauge: {
62
68
  * background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
@@ -77,6 +83,14 @@ export default {
77
83
  * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
78
84
  * // if data value is below than 0.1, text label will be hidden.
79
85
  * threshold: 0.1,
86
+ *
87
+ * // set ratio callback. Should return ratio value
88
+ * ratio: function(d, radius, h) {
89
+ * ...
90
+ * return ratio;
91
+ * },
92
+ * // or set ratio number
93
+ * ratio: 0.5
80
94
  * },
81
95
  *
82
96
  * // disable expand transition for interaction
@@ -90,6 +104,11 @@ export default {
90
104
  * rate: 1
91
105
  * },
92
106
  *
107
+ * // enforce min/max value.
108
+ * // when given value < min, will render as empty value.
109
+ * // when value > max, will render to given max value not surpassing it.
110
+ * enforceMinMax: true,
111
+ *
93
112
  * min: -100,
94
113
  * max: 200,
95
114
  * type: "single" // or 'multi'
@@ -110,9 +129,11 @@ export default {
110
129
  gauge_background: "",
111
130
  gauge_fullCircle: false,
112
131
  gauge_label_show: true,
113
- gauge_label_format: <(() => string)|undefined> undefined,
114
132
  gauge_label_extents: <(() => string)|undefined> undefined,
133
+ gauge_label_format: <(() => string)|undefined> undefined,
134
+ gauge_label_ratio: <(() => number)|undefined> undefined,
115
135
  gauge_label_threshold: 0,
136
+ gauge_enforceMinMax: false,
116
137
  gauge_min: 0,
117
138
  gauge_max: 100,
118
139
  gauge_type: "single",
@@ -14,8 +14,8 @@ export default {
14
14
  * @property {object} pie Pie object
15
15
  * @property {boolean} [pie.label.show=true] Show or hide label on each pie piece.
16
16
  * @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
17
- * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
18
17
  * @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
18
+ * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
19
19
  * @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
20
20
  * @property {number} [pie.expand.rate=0.98] Set expand rate.
21
21
  * @property {number} [pie.expand.duration=50] Set expand transition time in ms.
@@ -86,8 +86,8 @@ export default {
86
86
  */
87
87
  pie_label_show: true,
88
88
  pie_label_format: <(() => number|string)|undefined> undefined,
89
- pie_label_threshold: 0.05,
90
89
  pie_label_ratio: <(() => number)|undefined> undefined,
90
+ pie_label_threshold: 0.05,
91
91
  pie_expand: <boolean|{rate?: number; duration?: number;}> {},
92
92
  pie_expand_rate: 0.98,
93
93
  pie_expand_duration: 50,
@@ -18,6 +18,7 @@ export const $COMMON = {
18
18
  export const $ARC = {
19
19
  arc: "bb-arc",
20
20
  arcLabelLine: "bb-arc-label-line",
21
+ arcRange: "bb-arc-range",
21
22
  arcs: "bb-arcs",
22
23
  chartArc: "bb-chart-arc",
23
24
  chartArcs: "bb-chart-arcs",
@@ -18,6 +18,7 @@ export const KEY = {
18
18
  dataTotalPerIndex: "$totalPerIndex",
19
19
  legendItemTextBox: "legendItemTextBox",
20
20
  radarPoints: "$radarPoints",
21
+ radarTextWidth: "$radarTextWidth",
21
22
  setOverOut: "setOverOut",
22
23
  callOverOutForTouch: "callOverOutForTouch",
23
24
  textRect: "textRect"
@@ -33,6 +33,7 @@ export {
33
33
  getRandom,
34
34
  getRange,
35
35
  getRectSegList,
36
+ getScrollPosition,
36
37
  getTranslation,
37
38
  getUnique,
38
39
  hasValue,
@@ -476,12 +477,12 @@ const toArray = (v: CSSStyleDeclaration | any): any => [].slice.call(v);
476
477
  * @private
477
478
  */
478
479
  function addCssRules(style, selector: string, prop: string[]): number {
479
- const {rootSelctor, sheet} = style;
480
+ const {rootSelector = "", sheet} = style;
480
481
  const getSelector = s => s
481
482
  .replace(/\s?(bb-)/g, ".$1")
482
483
  .replace(/\.+/g, ".");
483
484
 
484
- const rule = `${rootSelctor} ${getSelector(selector)} {${prop.join(";")}}`;
485
+ const rule = `${rootSelector} ${getSelector(selector)} {${prop.join(";")}}`;
485
486
 
486
487
  return sheet[sheet.insertRule ? "insertRule" : "addRule"](
487
488
  rule,
@@ -511,6 +512,19 @@ function getCssRules(styleSheets: any[]) {
511
512
  return rules;
512
513
  }
513
514
 
515
+ /**
516
+ * Get current window and container scroll position
517
+ * @param {HTMLElement} node Target element
518
+ * @returns {object} window scroll position
519
+ * @private
520
+ */
521
+ function getScrollPosition(node: HTMLElement) {
522
+ return {
523
+ x: (window.pageXOffset ?? window.scrollX ?? 0) + node.scrollLeft ?? 0,
524
+ y: (window.pageYOffset ?? window.scrollY ?? 0) + node.scrollTop ?? 0
525
+ };
526
+ }
527
+
514
528
  /**
515
529
  * Gets the SVGMatrix of an SVGGElement
516
530
  * @param {SVGElement} node Node element
@@ -136,8 +136,9 @@
136
136
  }
137
137
  /*-- Region --*/
138
138
  .bb-region {
139
+ fill: steelblue;
140
+
139
141
  rect {
140
- fill: steelblue;
141
142
  fill-opacity: .1;
142
143
  }
143
144
  }
@@ -162,8 +162,9 @@ rect.bb-circle, use.bb-circle {
162
162
 
163
163
  /*-- Region --*/
164
164
  .bb-region {
165
+ fill: steelblue;
166
+
165
167
  rect {
166
- fill: steelblue;
167
168
  fill-opacity: 0.5;
168
169
  }
169
170
 
@@ -147,8 +147,9 @@ $text-font-size: 11px;
147
147
 
148
148
  /*-- Region --*/
149
149
  .bb-region {
150
+ fill: steelblue;
151
+
150
152
  rect {
151
- fill: steelblue;
152
153
  fill-opacity: 0.1;
153
154
  }
154
155
 
@@ -158,8 +158,9 @@ rect.bb-circle, use.bb-circle {
158
158
 
159
159
  /*-- Region --*/
160
160
  .bb-region {
161
+ fill: steelblue;
162
+
161
163
  rect {
162
- fill: steelblue;
163
164
  fill-opacity: 0.1;
164
165
  }
165
166
 
@@ -154,8 +154,9 @@ rect.bb-circle, use.bb-circle {
154
154
 
155
155
  /*-- Region --*/
156
156
  .bb-region {
157
+ fill: steelblue;
158
+
157
159
  rect {
158
- fill: steelblue;
159
160
  fill-opacity: 0.1;
160
161
  }
161
162
 
@@ -156,8 +156,9 @@ rect.bb-circle, use.bb-circle {
156
156
 
157
157
  /*-- Region --*/
158
158
  .bb-region {
159
+ fill: #71808d;
160
+
159
161
  rect {
160
- fill: #71808d;
161
162
  fill-opacity: 0.1;
162
163
  }
163
164
 
@@ -422,6 +422,11 @@ export interface LegendOptions {
422
422
  */
423
423
  hide?: boolean | string[] | string;
424
424
 
425
+ /**
426
+ * Set to all items have same width size.
427
+ */
428
+ equally?: boolean;
429
+
425
430
  /**
426
431
  * Change the position of legend.
427
432
  * Currently bottom, right and inset are supported.
@@ -441,10 +446,6 @@ export interface LegendOptions {
441
446
  y?: number;
442
447
  step?: number;
443
448
  };
444
- /**
445
- * Padding between legend elements.
446
- */
447
- padding?: number;
448
449
 
449
450
  item?: {
450
451
  /**
@@ -534,6 +535,21 @@ export interface LegendOptions {
534
535
  template?: ((this: Chart, title: string, color: string, data: DataItem[]) => void) | string;
535
536
  };
536
537
 
538
+ /**
539
+ * Padding between legend elements.
540
+ */
541
+ padding?: number;
542
+
543
+ /**
544
+ * Set formatter function for legend text.
545
+ */
546
+ format?: (id: string) => string;
547
+
548
+ /**
549
+ * Show full legend text value using system tooltip(via 'title' element).
550
+ */
551
+ tooltip?: boolean;
552
+
537
553
  /**
538
554
  * Whether to use custom points in legend.
539
555
  */
@@ -731,6 +747,14 @@ export interface SubchartOptions {
731
747
  * Show or hide x axis tick text.
732
748
  */
733
749
  show?: boolean;
750
+
751
+ /**
752
+ * * Set the first/last axis tick text to be positioned inside of the chart on non-rotated axis.
753
+ */
754
+ inner?: boolean | {
755
+ first?: boolean;
756
+ last?: boolean;
757
+ }
734
758
  };
735
759
  };
736
760
  };