billboard.js 3.4.1 → 3.5.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 (53) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +3283 -1110
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +7416 -4949
  6. package/dist/billboard.pkgd.min.js +3 -2
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +29 -13
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +259 -89
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +329 -106
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +223 -71
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +219 -72
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +3940 -3793
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +4219 -3882
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +4392 -3930
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +4187 -3868
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +4195 -3872
  22. package/dist/theme/datalab.css +1 -1
  23. package/dist/theme/datalab.min.css +1 -1
  24. package/dist/theme/graph.css +1 -1
  25. package/dist/theme/graph.min.css +1 -1
  26. package/dist/theme/insight.css +1 -1
  27. package/dist/theme/insight.min.css +1 -1
  28. package/dist-esm/billboard.js +206 -41
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +47 -75
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +66 -85
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +50 -76
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +47 -75
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +47 -75
  34. package/package.json +34 -34
  35. package/src/Chart/api/data.ts +2 -2
  36. package/src/ChartInternal/Axis/AxisRenderer.ts +29 -3
  37. package/src/ChartInternal/ChartInternal.ts +8 -1
  38. package/src/ChartInternal/interactions/zoom.ts +17 -4
  39. package/src/ChartInternal/internals/color.ts +3 -2
  40. package/src/ChartInternal/internals/grid.ts +5 -3
  41. package/src/ChartInternal/internals/redraw.ts +5 -2
  42. package/src/ChartInternal/internals/scale.ts +3 -1
  43. package/src/ChartInternal/internals/size.axis.ts +5 -2
  44. package/src/ChartInternal/internals/text.ts +115 -15
  45. package/src/ChartInternal/shape/bar.ts +12 -5
  46. package/src/Plugin/sparkline/index.ts +22 -11
  47. package/src/Plugin/stanford/index.ts +10 -7
  48. package/src/config/Options/common/main.ts +15 -1
  49. package/src/config/Options/common/tooltip.ts +1 -1
  50. package/src/config/Options/data/data.ts +11 -3
  51. package/src/module/generator.ts +12 -5
  52. package/types/chart.d.ts +2 -2
  53. package/types/options.d.ts +21 -8
@@ -26,7 +26,6 @@ export default {
26
26
  $$.updateSizes(initializing);
27
27
 
28
28
  // update legend and transform each g
29
-
30
29
  if (wth.Legend && config.legend_show) {
31
30
  options.withTransition = !!duration;
32
31
  $$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
@@ -246,7 +245,11 @@ export default {
246
245
  $$.redraw(options, transitions);
247
246
  },
248
247
 
249
- redrawWithoutRescale() {
248
+ /**
249
+ * Redraw without rescale
250
+ * @private
251
+ */
252
+ redrawWithoutRescale(): void {
250
253
  this.redraw({
251
254
  withY: false,
252
255
  withDimension: false,
@@ -169,7 +169,9 @@ export default {
169
169
  const xSubDomain = updateXDomain && org.xDomain;
170
170
 
171
171
  scale.x = $$.getXScale(min.x, max.x, xDomain, () => axis.x.tickOffset());
172
- scale.subX = $$.getXScale(min.x, max.x, xSubDomain, d => (d % 1 ? 0 : axis.subX.tickOffset()));
172
+ scale.subX = $$.getXScale(min.x, max.x, xSubDomain, d => (
173
+ d % 1 ? 0 : (axis.subX ?? axis.x).tickOffset())
174
+ );
173
175
 
174
176
  format.xAxisTick = axis.getXAxisTickFormat();
175
177
  format.subXAxisTick = axis.getXAxisTickFormat(true);
@@ -25,9 +25,12 @@ export default {
25
25
 
26
26
  if ($$.axis) {
27
27
  const position = $$.axis?.getLabelPositionById(id);
28
+ const width = $$.axis.getMaxTickWidth(id, withoutRecompute);
29
+ const gap = width === 0 ? 0.5 : 0;
28
30
 
29
- return $$.axis.getMaxTickWidth(id, withoutRecompute) +
30
- (position.isInner ? 20 : 40);
31
+ return width + (
32
+ position.isInner ? (20 + gap) : 40
33
+ );
31
34
  } else {
32
35
  return 40;
33
36
  }
@@ -12,6 +12,83 @@ import {capitalize, getBoundingRect, getRandom, isFunction, isNumber, isObject,
12
12
  import {IDataRow, IArcData} from "../data/IData";
13
13
  import {AxisType} from "../../../types/types";
14
14
 
15
+ type Coord = {x: number, y: number};
16
+ type Anchor = "start" | "middle" | "end";
17
+
18
+ /**
19
+ * Get text-anchor according text.labels.rotate angle
20
+ * @param {number} angle Angle value
21
+ * @returns {string} Anchor string value
22
+ * @private
23
+ */
24
+ function getRotateAnchor(angle: number): Anchor {
25
+ let anchor: Anchor = "middle";
26
+
27
+ if (angle > 0 && angle <= 170) {
28
+ anchor = "end";
29
+ } else if (angle > 190 && angle <= 360) {
30
+ anchor = "start";
31
+ }
32
+
33
+ return anchor;
34
+ }
35
+
36
+ /**
37
+ * Set rotated position coordinate according text.labels.rotate angle
38
+ * @param {object} d Data object
39
+ * @param {object} pos Position object
40
+ * @param {object} pos.x x coordinate
41
+ * @param {object} pos.y y coordinate
42
+ * @param {string} anchor string value
43
+ * @param {boolean} isRotated If axis is rotated
44
+ * @param {boolean} isInverted If axis is inverted
45
+ * @returns {object} x, y coordinate
46
+ * @private
47
+ */
48
+ function setRotatePos(
49
+ d: IDataRow, pos: Coord, anchor: Anchor, isRotated: boolean, isInverted: boolean
50
+ ): Coord {
51
+ const $$ = this;
52
+ const {value} = d;
53
+ const isCandlestickType = $$.isCandlestickType(d);
54
+ const isNegative = value < 0 || (
55
+ isCandlestickType && !$$.getCandlestickData(d)?._isUp
56
+ );
57
+
58
+ let {x, y} = pos;
59
+ const gap = 4;
60
+ const doubleGap = gap * 2;
61
+
62
+ if (isRotated) {
63
+ if (anchor === "start") {
64
+ x += isNegative ? 0 : doubleGap;
65
+ y += gap;
66
+ } else if (anchor === "middle") {
67
+ x += doubleGap;
68
+ y -= doubleGap;
69
+ } else if (anchor === "end") {
70
+ isNegative && (x -= doubleGap);
71
+ y += gap;
72
+ }
73
+ } else {
74
+ if (anchor === "start") {
75
+ x += gap;
76
+ isNegative && (y += doubleGap * 2);
77
+ } else if (anchor === "middle") {
78
+ y -= doubleGap;
79
+ } else if (anchor === "end") {
80
+ x -= gap;
81
+ isNegative && (y += doubleGap * 2);
82
+ }
83
+
84
+ if (isInverted) {
85
+ y += isNegative ? -17 : (isCandlestickType ? 13 : 7);
86
+ }
87
+ }
88
+
89
+ return {x, y};
90
+ }
91
+
15
92
  export default {
16
93
  opacityForText(d): null | "0" {
17
94
  const $$ = this;
@@ -171,34 +248,46 @@ export default {
171
248
 
172
249
  /**
173
250
  * Redraw chartText
174
- * @param {Function} x Positioning function for x
175
- * @param {Function} y Positioning function for y
251
+ * @param {Function} getX Positioning function for x
252
+ * @param {Function} getY Positioning function for y
176
253
  * @param {boolean} forFlow Weather is flow
177
254
  * @param {boolean} withTransition transition is enabled
178
255
  * @returns {Array}
179
256
  * @private
180
257
  */
181
- redrawText(x, y, forFlow?: boolean, withTransition?: boolean): true {
258
+ redrawText(getX, getY, forFlow?: boolean, withTransition?: boolean): true {
182
259
  const $$ = this;
183
- const {$T} = $$;
260
+ const {$T, axis, config} = $$;
184
261
  const t = <string>getRandom(true);
262
+ const isRotated = config.axis_rotated;
263
+ const angle = config.data_labels.rotate;
264
+
265
+ const anchorString = getRotateAnchor(angle);
266
+ const rotateString = angle ? `rotate(${angle})` : "";
185
267
 
186
268
  $$.$el.text
187
269
  .style("fill", $$.updateTextColor.bind($$))
188
270
  .attr("filter", $$.updateTextBacgroundColor.bind($$))
189
271
  .style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$))
190
- .each(function(d, i) {
272
+ .each(function(d: IDataRow, i: number) {
191
273
  // do not apply transition for newly added text elements
192
274
  const node = $T(this, !!(withTransition && this.getAttribute("x")), t);
193
-
194
- const posX = x.bind(this)(d, i);
195
- const posY = y.bind(this)(d, i);
275
+ const isInverted = config[`axis_${axis?.getId(d.id)}_inverted`];
276
+ let pos = {
277
+ x: getX.bind(this)(d, i),
278
+ y: getY.bind(this)(d, i)
279
+ };
280
+
281
+ if (angle) {
282
+ pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
283
+ node.attr("text-anchor", anchorString);
284
+ }
196
285
 
197
286
  // when is multiline
198
- if (this.childElementCount) {
199
- node.attr("transform", `translate(${posX} ${posY})`);
287
+ if (this.childElementCount || angle) {
288
+ node.attr("transform", `translate(${pos.x} ${pos.y}) ${rotateString}`);
200
289
  } else {
201
- node.attr("x", posX).attr("y", posY);
290
+ node.attr("x", pos.x).attr("y", pos.y);
202
291
  }
203
292
  });
204
293
 
@@ -338,7 +427,6 @@ export default {
338
427
  const isRotated = config.axis_rotated;
339
428
  let xPos = points[0][0];
340
429
 
341
-
342
430
  if ($$.isCandlestickType(d)) {
343
431
  if (isRotated) {
344
432
  xPos = $$.getCandlestickData(d)?._isUp ?
@@ -384,8 +472,10 @@ export default {
384
472
  */
385
473
  getYForText(points, d, textElement): number {
386
474
  const $$ = this;
387
- const {config, state} = $$;
475
+ const {axis, config, state} = $$;
388
476
  const isRotated = config.axis_rotated;
477
+ const isInverted = config[`axis_${axis?.getId(d.id)}_inverted`];
478
+ const isBarType = $$.isBarType(d);
389
479
  const r = config.point_r;
390
480
  const rect = getBoundingRect(textElement);
391
481
  let {value} = d;
@@ -402,6 +492,10 @@ export default {
402
492
  yPos = value && value._isUp ?
403
493
  points[2][2] - baseY :
404
494
  points[2][1] + (baseY * 4);
495
+
496
+ if (isInverted) {
497
+ yPos += 15 * (value._isUp ? 1 : -1);
498
+ }
405
499
  }
406
500
  } else {
407
501
  if (isRotated) {
@@ -414,16 +508,22 @@ export default {
414
508
  }
415
509
 
416
510
  if (value < 0 || (value === 0 && !state.hasPositiveValue && state.hasNegativeValue)) {
417
- yPos += rect.height + ($$.isBarType(d) ? -baseY : baseY);
511
+ yPos += isInverted ? (isBarType ? -3 : -5) : (
512
+ rect.height + (isBarType ? -baseY : baseY)
513
+ );
418
514
  } else {
419
515
  let diff = -baseY * 2;
420
516
 
421
- if ($$.isBarType(d)) {
517
+ if (isBarType) {
422
518
  diff = -baseY;
423
519
  } else if ($$.isBubbleType(d)) {
424
520
  diff = baseY;
425
521
  }
426
522
 
523
+ if (isInverted) {
524
+ diff = isBarType ? 10 : 15;
525
+ }
526
+
427
527
  yPos += diff;
428
528
  }
429
529
  }
@@ -102,7 +102,7 @@ export default {
102
102
  return [
103
103
  $$.$T(bar, withTransition, getRandom())
104
104
  .attr("d", d => (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d))
105
- .style("fill", this.color)
105
+ .style("fill", $$.color)
106
106
  .style("opacity", null)
107
107
  ];
108
108
  },
@@ -154,10 +154,10 @@ export default {
154
154
  let radius = 0;
155
155
 
156
156
  const isGrouped = $$.isGrouped(d.id);
157
- const hasRadius = d.value !== 0 && getRadius;
158
- const isRadiusData = hasRadius && isGrouped ? $$.isStackingRadiusData(d) : false;
157
+ // const hasRadius = d.value !== 0 && getRadius;
158
+ const isRadiusData = getRadius && isGrouped ? $$.isStackingRadiusData(d) : false;
159
159
 
160
- if (hasRadius && (!isGrouped || isRadiusData)) {
160
+ if (getRadius && (!isGrouped || isRadiusData)) {
161
161
  const index = isRotated ? indexY : indexX;
162
162
  const barW = points[2][index] - points[0][index];
163
163
 
@@ -188,9 +188,16 @@ export default {
188
188
  */
189
189
  isStackingRadiusData(d: IDataRow): boolean {
190
190
  const $$ = this;
191
- const {config, data} = $$;
191
+ const {$el, config, data, state} = $$;
192
192
  const {id, index, value} = d;
193
193
 
194
+ // when the data is hidden, check if has rounded edges
195
+ if (state.hiddenTargetIds.indexOf(id) > -1) {
196
+ const target = $el.bar.filter(d => d.id === id && d.value === value);
197
+
198
+ return !target.empty() && /a\d+/i.test(target.attr("d"));
199
+ }
200
+
194
201
  // Find same grouped ids
195
202
  const keys = config.data_groups.find(v => v.indexOf(id) > -1);
196
203
 
@@ -119,16 +119,26 @@ export default class Sparkline extends Plugin {
119
119
 
120
120
  config.legend_show = false;
121
121
  config.resize_auto = false;
122
-
123
122
  config.axis_x_show = false;
124
- config.axis_x_padding = {
125
- left: 15,
126
- right: 15,
127
- unit: "px"
128
- };
123
+
124
+ // set default axes padding
125
+ if (config.padding !== false) {
126
+ const hasOption = o => Object.keys(o || {}).length > 0;
127
+
128
+ if (hasOption(config.axis_x_padding)) {
129
+ config.axis_x_padding = {
130
+ left: 15,
131
+ right: 15,
132
+ unit: "px"
133
+ };
134
+ }
135
+
136
+ if (hasOption(config.axis_y_padding)) {
137
+ config.axis_y_padding = 5;
138
+ }
139
+ }
129
140
 
130
141
  config.axis_y_show = false;
131
- config.axis_y_padding = 5;
132
142
 
133
143
  if (!config.tooltip_position) {
134
144
  config.tooltip_position = function(data, width, height) {
@@ -150,8 +160,7 @@ export default class Sparkline extends Plugin {
150
160
  }
151
161
 
152
162
  $init(): void {
153
- const {$$} = this;
154
- const {$el} = $$;
163
+ const {$$: {$el}} = this;
155
164
 
156
165
  // make disable-ish main chart element
157
166
  $el.chart
@@ -159,7 +168,7 @@ export default class Sparkline extends Plugin {
159
168
  .style("height", "0")
160
169
  .style("pointer-events", "none");
161
170
 
162
- document.body.appendChild($el.tooltip.node());
171
+ $el.tooltip?.node() && document.body.appendChild($el.tooltip.node());
163
172
  }
164
173
 
165
174
  $afterInit(): void {
@@ -178,7 +187,9 @@ export default class Sparkline extends Plugin {
178
187
  * @private
179
188
  */
180
189
  bindEvents(bind = true): void {
181
- if (this.$$.config.interaction_enabled) {
190
+ const {$$: {config}} = this;
191
+
192
+ if (config.interaction_enabled && config.tooltip_show) {
182
193
  const method = `${bind ? "add" : "remove"}EventListener`;
183
194
 
184
195
  this.element
@@ -228,20 +228,23 @@ export default class Stanford extends Plugin {
228
228
 
229
229
  if (isEmpty(config.tooltip_contents)) {
230
230
  config.tooltip_contents = function(d, defaultTitleFormat, defaultValueFormat, color) {
231
+ const {data_x} = config;
231
232
  let html = `<table class="${$TOOLTIP.tooltip}"><tbody>`;
232
233
 
233
234
  d.forEach(v => {
235
+ const {id = "", value = 0, epochs = 0, x = ""} = v;
236
+
234
237
  html += `<tr>
235
- <th>${defaultTitleFormat(config.data_x)}</th>
236
- <th class="value">${defaultValueFormat(v.x)}</th>
238
+ <th>${data_x || ""}</th>
239
+ <th class="value">${defaultTitleFormat(x)}</th>
237
240
  </tr>
238
241
  <tr>
239
- <th>${defaultTitleFormat(v.id)}</th>
240
- <th class="value">${defaultValueFormat(v.value)}</th>
242
+ <th>${v.id}</th>
243
+ <th class="value">${defaultValueFormat(value)}</th>
241
244
  </tr>
242
- <tr class="${$TOOLTIP.tooltipName}-${v.id}">
243
- <td class="name"><span style="background-color:${color(v)}"></span>${defaultTitleFormat("Epochs")}</td>
244
- <td class="value">${defaultValueFormat(v.epochs)}</td>
245
+ <tr class="${$TOOLTIP.tooltipName}-${id}">
246
+ <td class="name"><span style="background-color:${color(v)}"></span>Epochs</td>
247
+ <td class="value">${defaultValueFormat(epochs)}</td>
245
248
  </tr>`;
246
249
  });
247
250
 
@@ -144,12 +144,26 @@ export default {
144
144
  * @type {object}
145
145
  * @property {object} [resize] resize object
146
146
  * @property {boolean} [resize.auto=true] Set chart resize automatically on viewport changes.
147
+ * @property {boolean|number} [resize.timer=true] Set resize timer option.
148
+ * - **NOTE:**
149
+ * - The resize function will be called using: true - `setTimeout()`, false - `requestIdleCallback()`.
150
+ * - Given number(delay in ms) value, resize function will be triggered using `setTimer()` with given delay.
147
151
  * @example
148
152
  * resize: {
149
- * auto: false
153
+ * auto: false,
154
+ *
155
+ * // set resize function will be triggered using `setTimer()`
156
+ * timer: true,
157
+ *
158
+ * // set resize function will be triggered using `requestIdleCallback()`
159
+ * timer: false,
160
+ *
161
+ * // set resize function will be triggered using `setTimer()` with a delay of `100ms`.
162
+ * timer: 100
150
163
  * }
151
164
  */
152
165
  resize_auto: true,
166
+ resize_timer: true,
153
167
 
154
168
  /**
155
169
  * Set a callback to execute when the chart is clicked.
@@ -39,7 +39,7 @@ export default {
39
39
  * - **Note:**
40
40
  * - defaultTitleFormat:
41
41
  * - if `axis.x.tick.format` option will be used if set.
42
- * - otherwise, will return funciton based on tick format type(category, timeseries).
42
+ * - otherwise, will return function based on tick format type(category, timeseries).
43
43
  * - defaultValueFormat:
44
44
  * - for Arc type (except gauge, radar), the function will return value from `(ratio * 100).toFixed(1)`.
45
45
  * - for Axis based types, will be used `axis.[y|y2].tick.format` option value if is set.
@@ -45,6 +45,7 @@ export default {
45
45
 
46
46
  /**
47
47
  * Set custom data name.
48
+ * If a name is set to `null`, the series is omitted from the legend.
48
49
  * @name data․names
49
50
  * @memberof Options
50
51
  * @type {object}
@@ -58,7 +59,7 @@ export default {
58
59
  * }
59
60
  * }
60
61
  */
61
- data_names: <{[key: string]: string}> {},
62
+ data_names: <{[key: string]: string|null}> {},
62
63
 
63
64
  /**
64
65
  * Set custom data class.<br><br>
@@ -311,6 +312,8 @@ export default {
311
312
  * @property {object} [data.labels.position] Set each dataset position, relative the original.
312
313
  * @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
313
314
  * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
315
+ * @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
316
+ * - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
314
317
  * @memberof Options
315
318
  * @type {object}
316
319
  * @default {}
@@ -320,6 +323,7 @@ export default {
320
323
  * @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
321
324
  * @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
322
325
  * @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
326
+ * @see [Demo: label rotate](https://naver.github.io/billboard.js/demo/#Data.DataLabelRotate)
323
327
  * @example
324
328
  * data: {
325
329
  * labels: true,
@@ -378,7 +382,10 @@ export default {
378
382
  * position: {
379
383
  * data1: {x: 5, y: 5},
380
384
  * data2: {x: 10, y: -20}
381
- * }
385
+ * },
386
+ *
387
+ * // rotate degree for label text
388
+ * rotate: 90
382
389
  * }
383
390
  * }
384
391
  */
@@ -387,7 +394,8 @@ export default {
387
394
  centered?: boolean;
388
395
  format?: Function;
389
396
  colors?: string|{[key: string]: string};
390
- position?: {[key: string]: number}|{[key: string]: {x?: number; y?: number;}}
397
+ position?: {[key: string]: number}|{[key: string]: {x?: number; y?: number;}};
398
+ rotate?: number;
391
399
  }> {},
392
400
  data_labels_backgroundColors: <string|{[key: string]: string}|undefined> undefined,
393
401
  data_labels_colors: <string|object|Function|undefined> undefined,
@@ -4,16 +4,17 @@
4
4
  */
5
5
  import {d3Transition} from "../../types/types";
6
6
  import {window} from "./browser";
7
- import {isArray, isTabVisible} from "./util";
7
+ import {isArray, isNumber, isTabVisible} from "./util";
8
8
 
9
9
  const {setTimeout, clearTimeout} = window;
10
10
 
11
11
  /**
12
12
  * Generate resize queue function
13
+ * @param {boolean|number} option Resize option
13
14
  * @returns {Fucntion}
14
15
  * @private
15
16
  */
16
- export function generateResize() {
17
+ export function generateResize(option: boolean|number) {
17
18
  const fn: any[] = [];
18
19
  let timeout;
19
20
 
@@ -21,9 +22,15 @@ export function generateResize() {
21
22
  // Delay all resize functions call, to prevent unintended excessive call from resize event
22
23
  callResizeFn.clear();
23
24
 
24
- timeout = setTimeout(() => {
25
- fn.forEach((f: Function) => f());
26
- }, 200);
25
+ if (option === false && window.requestIdleCallback) {
26
+ requestIdleCallback(() => {
27
+ fn.forEach((f: Function) => f());
28
+ }, {timeout: 200});
29
+ } else {
30
+ timeout = setTimeout(() => {
31
+ fn.forEach((f: Function) => f());
32
+ }, isNumber(option) ? option : 200);
33
+ }
27
34
  };
28
35
 
29
36
  callResizeFn.clear = () => {
package/types/chart.d.ts CHANGED
@@ -347,7 +347,7 @@ export interface Chart {
347
347
  load(this: Chart, args: {
348
348
  append?: boolean;
349
349
  url?: string;
350
- json?: [{ [key: string]: string | number }] | {[key: string]: Array<string|number>};
350
+ json?: Array<{[key: string]: string | number }> | {[key: string]: Array<string | number>};
351
351
  rows?: PrimitiveArray[];
352
352
  columns?: PrimitiveArray[];
353
353
  data?: Array<{ [key: string]: number }>;
@@ -358,7 +358,7 @@ export interface Chart {
358
358
  axes?: { [key: string]: string | string[] };
359
359
  colors?: { [key: string]: string };
360
360
  headers?: { [key: string]: string };
361
- keys?: { [key: string]: string };
361
+ keys?: { [key: string]: string | string[] };
362
362
  mimeType?: string;
363
363
  type?: string;
364
364
  types?: { [key: string]: string };
@@ -8,7 +8,7 @@ import Bubblecompare from "./plugin/bubblecompare/index";
8
8
  import Stanford from "./plugin/stanford/index";
9
9
  import TextOverlap from "./plugin/textoverlap/index";
10
10
  import {Chart} from "./chart";
11
- import {IData} from "../src/ChartInternal/data/IData";
11
+ import {IArcData, IData, IDataRow} from "../src/ChartInternal/data/IData";
12
12
 
13
13
  export interface ChartOptions {
14
14
  /**
@@ -99,6 +99,14 @@ export interface ChartOptions {
99
99
  * Indicate if the chart should automatically get resized when the window gets resized.
100
100
  */
101
101
  auto?: boolean;
102
+
103
+ /**
104
+ * Set resize timer option.
105
+ * - **NOTE:**
106
+ * - The resize function will be called using: true - `setTimeout()`, false - `requestIdleCallback()`.
107
+ * - Given number(delay in ms) value, resize function will be triggered using `setTimer()` with given delay.
108
+ */
109
+ timer?: boolean | number;
102
110
  };
103
111
 
104
112
  color?: {
@@ -1082,10 +1090,10 @@ export interface TooltipOptions {
1082
1090
  */
1083
1091
  contents?: ((
1084
1092
  this: Chart,
1085
- data: any,
1086
- defaultTitleFormat: string,
1087
- defaultValueFormat: string,
1088
- color: any
1093
+ data: IDataRow[],
1094
+ defaultTitleFormat: (x: Date|number|string) => number|string,
1095
+ defaultValueFormat: (value: number, ratio: number|undefined, id: string) => number|string,
1096
+ color: (d: IDataRow|IArcData|string) => string
1089
1097
  ) => string) | {
1090
1098
  /**
1091
1099
  * Set CSS selector or element reference to bind tooltip.
@@ -1193,7 +1201,7 @@ export interface SubchartOptions {
1193
1201
  * Use custom format for x axis ticks - see 'axis.x.tick.format' option for details.
1194
1202
  */
1195
1203
  format?: string
1196
- | ((this: Chart, x: number | Date) => string | number)
1204
+ | ((this: Chart, x: Date) => string | number)
1197
1205
  | ((this: Chart, index: number, categoryName: string) => string);
1198
1206
  /**
1199
1207
  * Show or hide x axis tick line.
@@ -1520,7 +1528,7 @@ export interface Data {
1520
1528
  /**
1521
1529
  * Set custom data name.
1522
1530
  */
1523
- names?: { [key: string]: string };
1531
+ names?: { [key: string]: string|null };
1524
1532
  /**
1525
1533
  * Set custom data class.
1526
1534
  * If this option is specified, the element g for the data has an additional class that has the prefix billboard-target- (e.g. billboard-target-additional-data1-class).
@@ -1613,7 +1621,12 @@ export interface Data {
1613
1621
  */
1614
1622
  y?: number;
1615
1623
  };
1616
- }
1624
+ };
1625
+
1626
+ /**
1627
+ * Rotate label text. Specify degree value in a range of `0 ~ 360`.
1628
+ */
1629
+ rotate?: number;
1617
1630
  };
1618
1631
 
1619
1632
  /**