billboard.js 3.2.1 → 3.3.0

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/dist/billboard.css +2 -3
  2. package/dist/billboard.js +424 -114
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +5415 -3250
  6. package/dist/billboard.pkgd.min.js +4 -4
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.d.ts +7 -0
  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.d.ts +7 -0
  11. package/dist/plugin/billboardjs-plugin-sparkline.js +19 -14
  12. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-stanford.d.ts +7 -0
  14. package/dist/plugin/billboardjs-plugin-stanford.js +17 -12
  15. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-tableview.d.ts +7 -0
  17. package/dist/plugin/billboardjs-plugin-tableview.js +19 -14
  18. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  19. package/dist/plugin/billboardjs-plugin-textoverlap.d.ts +7 -0
  20. package/dist/plugin/billboardjs-plugin-textoverlap.js +17 -12
  21. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  22. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +5056 -3201
  23. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +5082 -3222
  24. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +5081 -3221
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +5075 -3215
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +5074 -3214
  27. package/dist/theme/datalab.css +2 -2
  28. package/dist/theme/datalab.min.css +2 -2
  29. package/dist/theme/graph.css +2 -2
  30. package/dist/theme/graph.min.css +2 -2
  31. package/dist/theme/insight.css +2 -2
  32. package/dist/theme/insight.min.css +2 -2
  33. package/dist-esm/billboard.js +737 -456
  34. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.d.ts +7 -0
  35. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  36. package/dist-esm/plugin/billboardjs-plugin-sparkline.d.ts +7 -0
  37. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +8 -8
  38. package/dist-esm/plugin/billboardjs-plugin-stanford.d.ts +7 -0
  39. package/dist-esm/plugin/billboardjs-plugin-stanford.js +15 -15
  40. package/dist-esm/plugin/billboardjs-plugin-tableview.d.ts +7 -0
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +6 -6
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.d.ts +7 -0
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +4 -4
  44. package/package.json +52 -52
  45. package/src/Chart/api/chart.ts +7 -1
  46. package/src/Chart/api/data.ts +3 -4
  47. package/src/ChartInternal/Axis/Axis.ts +15 -9
  48. package/src/ChartInternal/ChartInternal.ts +13 -2
  49. package/src/ChartInternal/data/IData.ts +9 -0
  50. package/src/ChartInternal/data/convert.ts +1 -1
  51. package/src/ChartInternal/data/data.ts +28 -11
  52. package/src/ChartInternal/interactions/interaction.ts +36 -4
  53. package/src/ChartInternal/internals/domain.ts +4 -2
  54. package/src/ChartInternal/internals/legend.ts +2 -1
  55. package/src/ChartInternal/internals/redraw.ts +2 -2
  56. package/src/ChartInternal/internals/scale.ts +3 -2
  57. package/src/ChartInternal/internals/size.ts +32 -1
  58. package/src/ChartInternal/internals/text.ts +2 -2
  59. package/src/ChartInternal/internals/tooltip.ts +4 -1
  60. package/src/ChartInternal/shape/arc.ts +3 -5
  61. package/src/ChartInternal/shape/bar.ts +89 -34
  62. package/src/ChartInternal/shape/radar.ts +2 -0
  63. package/src/ChartInternal/shape/shape.ts +72 -11
  64. package/src/Plugin/sparkline/index.ts +2 -2
  65. package/src/Plugin/tableview/index.ts +1 -1
  66. package/src/config/Options/axis/x.ts +27 -7
  67. package/src/config/Options/axis/y.ts +24 -3
  68. package/src/config/Options/axis/y2.ts +24 -3
  69. package/src/config/Options/common/main.ts +11 -1
  70. package/src/config/Options/data/data.ts +22 -0
  71. package/src/config/Options/shape/bar.ts +9 -2
  72. package/src/module/util.ts +19 -20
  73. package/src/scss/billboard.scss +1 -13
  74. package/src/scss/theme/datalab.scss +1 -7
  75. package/src/scss/theme/graph.scss +1 -2
  76. package/src/scss/theme/insight.scss +1 -2
  77. package/types/axis.d.ts +22 -8
  78. package/types/chart.d.ts +1 -1
  79. package/types/options.d.ts +40 -33
  80. package/types/plugin/tableview/index.d.ts +3 -3
  81. package/types/plugin/tableview/options.d.ts +1 -1
  82. package/types/types.d.ts +9 -6
@@ -23,9 +23,10 @@ import {
23
23
  curveStep as d3CurveStep
24
24
  } from "d3-shape";
25
25
  import {select as d3Select} from "d3-selection";
26
- import {d3Selection} from "types/types";
26
+ import {d3Selection} from "../../../types/types";
27
27
  import CLASS from "../../config/classes";
28
- import {capitalize, getUnique, isObjectType, isNumber, isValue, isUndefined, notEmpty} from "../../module/util";
28
+ import {capitalize, getPointer, getRectSegList, getUnique, isObjectType, isNumber, isValue, isUndefined, notEmpty} from "../../module/util";
29
+ import {IDataRow, IDataIndice, TIndices} from "../data/IData";
29
30
 
30
31
  export default {
31
32
  /**
@@ -75,12 +76,25 @@ export default {
75
76
  return shape;
76
77
  },
77
78
 
78
- getShapeIndices(typeFilter): {[key: string]: number} {
79
+ /**
80
+ * Get shape's indices according it's position
81
+ *
82
+ * From the below example, indices will be:
83
+ * ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
84
+ *
85
+ * data1 data3 data1 data3
86
+ * data2 data4 data2 data4
87
+ * -------------------------
88
+ * 0 1
89
+ * @param {Function} typeFilter Chart type filter function
90
+ * @returns {object} Indices object with its position
91
+ */
92
+ getShapeIndices(typeFilter): TIndices {
79
93
  const $$ = this;
80
94
  const {config} = $$;
81
95
  const xs = config.data_xs;
82
96
  const hasXs = notEmpty(xs);
83
- const indices = {};
97
+ const indices: TIndices = {};
84
98
  let i: any = hasXs ? {} : 0;
85
99
 
86
100
  if (hasXs) {
@@ -121,12 +135,28 @@ export default {
121
135
  /**
122
136
  * Get indices value based on data ID value
123
137
  * @param {object} indices Indices object
124
- * @param {string} id Data id value
138
+ * @param {object} d Data row
139
+ * @param {string} caller Caller function name (Used only for 'sparkline' plugin)
125
140
  * @returns {object} Indices object
126
141
  * @private
127
142
  */
128
- getIndices(indices, id: string) {
129
- const xs = this.config.data_xs;
143
+ getIndices(indices: TIndices, d: IDataRow, caller?: string): IDataIndice { // eslint-disable-line
144
+ const $$ = this;
145
+ const {data_xs: xs, bar_indices_removeNull: removeNull} = $$.config;
146
+ const {id, index} = d;
147
+
148
+ if ($$.isBarType(id) && removeNull) {
149
+ const ind = {} as IDataIndice;
150
+
151
+ // redefine bar indices order
152
+ $$.getAllValuesOnIndex(index, true)
153
+ .forEach((v, i) => {
154
+ ind[v.id] = i;
155
+ ind.__max__ = i;
156
+ });
157
+
158
+ return ind;
159
+ }
130
160
 
131
161
  return notEmpty(xs) ?
132
162
  indices[xs[id]] : indices;
@@ -138,12 +168,12 @@ export default {
138
168
  * @returns {number} Max number
139
169
  * @private
140
170
  */
141
- getIndicesMax(indices): number {
171
+ getIndicesMax(indices: TIndices | IDataIndice): number {
142
172
  return notEmpty(this.config.data_xs) ?
143
173
  // if is multiple xs, return total sum of xs' __max__ value
144
174
  Object.keys(indices)
145
175
  .map(v => indices[v].__max__ || 0)
146
- .reduce((acc, curr) => acc + curr) : indices.__max__;
176
+ .reduce((acc, curr) => acc + curr) : (indices as IDataIndice).__max__;
147
177
  },
148
178
 
149
179
  getShapeX(offset, indices, isSub?: boolean): (d) => number {
@@ -157,7 +187,7 @@ export default {
157
187
  );
158
188
 
159
189
  return d => {
160
- const ind = $$.getIndices(indices, d.id, "getShapeX");
190
+ const ind = $$.getIndices(indices, d, "getShapeX");
161
191
  const index = d.id in ind ? ind[d.id] : 0;
162
192
  const targetsNum = (ind.__max__ || 0) + 1;
163
193
  let x = 0;
@@ -204,6 +234,9 @@ export default {
204
234
  value = $$.getRatio("index", d, true);
205
235
  } else if ($$.isBubbleZType(d)) {
206
236
  value = $$.getBubbleZData(d.value, "y");
237
+ } else if ($$.isBarRangeType(d)) {
238
+ // TODO use range.getEnd() like method
239
+ value = value[1];
207
240
  }
208
241
 
209
242
  return $$.getYScaleById(d.id, isSub)(value);
@@ -273,8 +306,14 @@ export default {
273
306
 
274
307
  return (d, idx) => {
275
308
  const {id, value, x} = d;
276
- const ind = $$.getIndices(indices, id);
309
+ const ind = $$.getIndices(indices, d);
277
310
  const scale = $$.getYScaleById(id, isSub);
311
+
312
+ if ($$.isBarRangeType(d)) {
313
+ // TODO use range.getStart()
314
+ return scale(value[0]);
315
+ }
316
+
278
317
  const y0 = scale($$.getShapeYMin(id));
279
318
 
280
319
  const dataXAsNumber = Number(x);
@@ -285,6 +324,7 @@ export default {
285
324
  .forEach(t => {
286
325
  const {id: tid, rowValueMapByXValue, rowValues, values: tvalues} = t;
287
326
 
327
+ // for same stacked group (ind[tid] === ind[id])
288
328
  if (ind[tid] === ind[id] && indexMapByTargetId[tid] < indexMapByTargetId[id]) {
289
329
  let row = rowValues[idx];
290
330
 
@@ -424,5 +464,26 @@ export default {
424
464
  $$.isStepType(d) ?
425
465
  config.line_step_type : "linear"
426
466
  );
467
+ },
468
+
469
+ isWithinBar(that): boolean {
470
+ const mouse = getPointer(this.state.event, that);
471
+ const list = getRectSegList(that);
472
+ const [seg0, seg1] = list;
473
+ const x = Math.min(seg0.x, seg1.x);
474
+ const y = Math.min(seg0.y, seg1.y);
475
+ const offset = this.config.bar_sensitivity;
476
+ const {width, height} = that.getBBox();
477
+ const sx = x - offset;
478
+ const ex = x + width + offset;
479
+ const sy = y + height + offset;
480
+ const ey = y - offset;
481
+
482
+ const isWithin = sx < mouse[0] &&
483
+ mouse[0] < ex &&
484
+ ey < mouse[1] &&
485
+ mouse[1] < sy;
486
+
487
+ return isWithin;
427
488
  }
428
489
  };
@@ -105,8 +105,8 @@ export default class Sparkline extends Plugin {
105
105
  const {getBarW, getIndices} = $$;
106
106
 
107
107
  // override internal methods to positioning bars
108
- $$.getIndices = function(indices, id, caller) {
109
- return caller === "getShapeX" ? {} : getIndices.call(this, indices, id);
108
+ $$.getIndices = function(indices, d, caller) {
109
+ return caller === "getShapeX" ? {} : getIndices.call(this, indices, d);
110
110
  };
111
111
 
112
112
  $$.getBarW = function(type, axis) {
@@ -114,7 +114,7 @@ export default class TableView extends Plugin {
114
114
  title: dataToShow.length ? this.config.categoryTitle : ""
115
115
  });
116
116
  let tbody = "";
117
- const rows: number|string[][] = [];
117
+ const rows: (number|string)[][] = [];
118
118
 
119
119
  dataToShow.forEach(v => {
120
120
  thead += tplProcess(tpl.thead, {title: v.id});
@@ -143,15 +143,16 @@ export default {
143
143
  axis_x_tick_format: <Function|string|undefined> undefined,
144
144
 
145
145
  /**
146
- * Setting for culling ticks.<br><br>
147
- * If true is set, the ticks will be culled, then only limitted tick text will be shown. This option does not hide the tick lines. If false is set, all of ticks will be shown.<br><br>
148
- * We can change the number of ticks to be shown by axis.x.tick.culling.max.
146
+ * Setting for culling ticks.
147
+ * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
148
+ * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.x.tick.culling.lines=false`.
149
+ * - `false`: all of ticks will be shown.<br><br>
150
+ * The number of ticks to be shown can be chaned by `axis.x.tick.culling.max`.
149
151
  * @name axis․x․tick․culling
150
152
  * @memberof Options
151
153
  * @type {boolean}
152
154
  * @default
153
- * - true for indexed axis and timeseries axis
154
- * - false for category axis
155
+ * `true` for indexed axis and timeseries axis, `false` for category axis
155
156
  * @example
156
157
  * axis: {
157
158
  * x: {
@@ -182,6 +183,25 @@ export default {
182
183
  */
183
184
  axis_x_tick_culling_max: 10,
184
185
 
186
+ /**
187
+ * Control visibility of tick lines within culling option, along with tick text.
188
+ * @name axis․x․tick․culling․lines
189
+ * @memberof Options
190
+ * @type {boolean}
191
+ * @default true
192
+ * @example
193
+ * axis: {
194
+ * x: {
195
+ * tick: {
196
+ * culling: {
197
+ * lines: false,
198
+ * }
199
+ * }
200
+ * }
201
+ * }
202
+ */
203
+ axis_x_tick_culling_lines: true,
204
+
185
205
  /**
186
206
  * The number of x axis ticks to show.<br><br>
187
207
  * This option hides tick lines together with tick text. If this option is used on timeseries axis, the ticks position will be determined precisely and not nicely positioned (e.g. it will have rough second value).
@@ -262,8 +282,8 @@ export default {
262
282
 
263
283
  /**
264
284
  * Fit x axis ticks.
265
- * - **true**: ticks will be positioned nicely to have same intervals.
266
- * - **false**: ticks will be positioned according to x value of the data points.
285
+ * - **true**: ticks will be shown according to x value of the data points.
286
+ * - **false**: ticks will be shown as to have same intervals.
267
287
  * @name axis․x․tick․fit
268
288
  * @memberof Options
269
289
  * @type {boolean}
@@ -187,9 +187,11 @@ export default {
187
187
  axis_y_tick_format: <Function|undefined> undefined,
188
188
 
189
189
  /**
190
- * Setting for culling ticks.<br><br>
191
- * If true is set, the ticks will be culled, then only limitted tick text will be shown. This option does not hide the tick lines. If false is set, all of ticks will be shown.<br><br>
192
- * We can change the number of ticks to be shown by axis.y.tick.culling.max.
190
+ * Setting for culling ticks.
191
+ * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
192
+ * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y.tick.culling.lines=false`.
193
+ * - `false`: all of ticks will be shown.<br><br>
194
+ * The number of ticks to be shown can be chaned by `axis.y.tick.culling.max`.
193
195
  * @name axis․y․tick․culling
194
196
  * @memberof Options
195
197
  * @type {boolean}
@@ -224,6 +226,25 @@ export default {
224
226
  */
225
227
  axis_y_tick_culling_max: 5,
226
228
 
229
+ /**
230
+ * Control visibility of tick lines within culling option, along with tick text.
231
+ * @name axis․y․tick․culling․lines
232
+ * @memberof Options
233
+ * @type {boolean}
234
+ * @default true
235
+ * @example
236
+ * axis: {
237
+ * y: {
238
+ * tick: {
239
+ * culling: {
240
+ * lines: false,
241
+ * }
242
+ * }
243
+ * }
244
+ * }
245
+ */
246
+ axis_y_tick_culling_lines: true,
247
+
227
248
  /**
228
249
  * Show y axis outer tick.
229
250
  * @name axis․y․tick․outer
@@ -173,9 +173,11 @@ export default {
173
173
  axis_y2_tick_format: <Function|undefined> undefined,
174
174
 
175
175
  /**
176
- * Setting for culling ticks.<br><br>
177
- * If true is set, the ticks will be culled, then only limitted tick text will be shown. This option does not hide the tick lines. If false is set, all of ticks will be shown.<br><br>
178
- * We can change the number of ticks to be shown by axis.y.tick.culling.max.
176
+ * Setting for culling ticks.
177
+ * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
178
+ * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y2.tick.culling.lines=false`.
179
+ * - `false`: all of ticks will be shown.<br><br>
180
+ * The number of ticks to be shown can be chaned by `axis.y2.tick.culling.max`.
179
181
  * @name axis․y2․tick․culling
180
182
  * @memberof Options
181
183
  * @type {boolean}
@@ -210,6 +212,25 @@ export default {
210
212
  */
211
213
  axis_y2_tick_culling_max: 5,
212
214
 
215
+ /**
216
+ * Control visibility of tick lines within culling option, along with tick text.
217
+ * @name axis․y2․tick․culling․lines
218
+ * @memberof Options
219
+ * @type {boolean}
220
+ * @default true
221
+ * @example
222
+ * axis: {
223
+ * y2: {
224
+ * tick: {
225
+ * culling: {
226
+ * lines: false,
227
+ * }
228
+ * }
229
+ * }
230
+ * }
231
+ */
232
+ axis_y2_tick_culling_lines: true,
233
+
213
234
  /**
214
235
  * Show or hide y2 axis outer tick.
215
236
  * @name axis․y2․tick․outer
@@ -109,12 +109,21 @@ export default {
109
109
  * @name padding
110
110
  * @memberof Options
111
111
  * @type {object}
112
- * @property {object} [padding] padding object
112
+ * @property {object|boolean} [padding=true] Set padding of chart, and accepts object or boolean type.
113
+ * - `Object`: Specify each side's padding.
114
+ * - `false`: Remove padding completely and make shape to fully occupy the container element.
115
+ * - In this case, axes and subchart will be hidden.
116
+ * - To adjust some padding from this state, use `axis.[x|y].padding` option.
113
117
  * @property {number} [padding.top] padding on the top of chart
114
118
  * @property {number} [padding.right] padding on the right of chart
115
119
  * @property {number} [padding.bottom] padding on the bottom of chart
116
120
  * @property {number} [padding.left] padding on the left of chart
121
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Padding)
117
122
  * @example
123
+ * // remove padding completely.
124
+ * padding: false,
125
+ *
126
+ * // or specify padding value for each side
118
127
  * padding: {
119
128
  * top: 20,
120
129
  * right: 20,
@@ -122,6 +131,7 @@ export default {
122
131
  * left: 20
123
132
  * }
124
133
  */
134
+ padding: true,
125
135
  padding_left: <number|undefined> undefined,
126
136
  padding_right: <number|undefined> undefined,
127
137
  padding_top: <number|undefined> undefined,
@@ -634,6 +634,18 @@ export default {
634
634
  * ]
635
635
  * }
636
636
  *
637
+ * // for 'bar' type, data can contain:
638
+ * // - an array of [start, end] data following the order
639
+ * data: {
640
+ * rows: [
641
+ * ["data1", "data2"],
642
+ * [[100, 150], 120],
643
+ * [[200, 300], 55],
644
+ * [[-400, 500], 60]
645
+ * ],
646
+ * type: "bar"
647
+ * }
648
+ *
637
649
  * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
638
650
  * // - an array of [high, mid, low] data following the order
639
651
  * // - or an object with 'high', 'mid' and 'low' key value
@@ -710,6 +722,16 @@ export default {
710
722
  * ]
711
723
  * }
712
724
  *
725
+ * // for 'bar' type, data can contain:
726
+ * // - an array of [start, end] data following the order
727
+ * data: {
728
+ * columns: [
729
+ * ["data1", -100, 50, [100, 200], [200, 300]],
730
+ * ["data2", -200, 300, [-100, 100], [-50, -30]],
731
+ * ],
732
+ * type: "bar"
733
+ * }
734
+ *
713
735
  * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
714
736
  * // - an array of [high, mid, low] data following the order
715
737
  * // - or an object with 'high', 'mid' and 'low' key value
@@ -12,10 +12,10 @@ export default {
12
12
  * @memberof Options
13
13
  * @type {object}
14
14
  * @property {object} bar Bar object
15
+ * @property {number} [bar.indices.removeNull=false] Remove nullish data on bar indices positions.
15
16
  * @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
16
17
  * @property {number} [bar.padding=0] The padding pixel value between each bar.
17
18
  * @property {number} [bar.radius] Set the radius of bar edge in pixel.
18
- * - **NOTE:** Works only for non-stacked bar
19
19
  * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
20
20
  * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
21
21
  * @property {number} [bar.width] Change the width of bar chart.
@@ -28,15 +28,21 @@ export default {
28
28
  * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
29
29
  * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
30
30
  * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
31
+ * @see [Demo: bar indices](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarIndices)
31
32
  * @see [Demo: bar padding](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarPadding)
32
33
  * @see [Demo: bar radius](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarRadius)
33
34
  * @see [Demo: bar width](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidth)
34
35
  * @see [Demo: bar width variant](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidthVariant)
35
36
  * @example
36
37
  * bar: {
38
+ * // remove nullish data on bar indices postions
39
+ * indices: {
40
+ * removeNull: true
41
+ * },
42
+ *
37
43
  * padding: 1,
38
44
  *
39
- * // the 'radius' option can be used only for non-stacking bars
45
+ * // bar radius
40
46
  * radius: 10,
41
47
  * // or
42
48
  * radius: {
@@ -73,6 +79,7 @@ export default {
73
79
  * }
74
80
  */
75
81
  bar_label_threshold: 0,
82
+ bar_indices_removeNull: false,
76
83
  bar_padding: 0,
77
84
  bar_radius: <number|{ratio: number}|undefined> undefined,
78
85
  bar_radius_ratio: <number|undefined> undefined,
@@ -60,23 +60,23 @@ export {
60
60
  };
61
61
 
62
62
  const isValue = (v: any): boolean => v || v === 0;
63
- const isFunction = (v: any): boolean => typeof v === "function";
64
- const isString = (v: any): boolean => typeof v === "string";
65
- const isNumber = (v: any): boolean => typeof v === "number";
66
- const isUndefined = (v: any): boolean => typeof v === "undefined";
67
- const isDefined = (v: any): boolean => typeof v !== "undefined";
68
- const isboolean = (v: any): boolean => typeof v === "boolean";
69
- const ceil10 = (v: any): number => Math.ceil(v / 10) * 10;
70
- const asHalfPixel = (n: any): number => Math.ceil(n) + 0.5;
63
+ const isFunction = (v: unknown): v is ((...args: any[]) => any) => typeof v === "function";
64
+ const isString = (v: unknown): v is string => typeof v === "string";
65
+ const isNumber = (v: unknown): v is number => typeof v === "number";
66
+ const isUndefined = (v: unknown): v is undefined => typeof v === "undefined";
67
+ const isDefined = (v: unknown): boolean => typeof v !== "undefined";
68
+ const isboolean = (v: unknown): boolean => typeof v === "boolean";
69
+ const ceil10 = (v: number): number => Math.ceil(v / 10) * 10;
70
+ const asHalfPixel = (n: number): number => Math.ceil(n) + 0.5;
71
71
  const diffDomain = (d: number[]): number => d[1] - d[0];
72
- const isObjectType = (v: any): boolean => typeof v === "object";
73
- const isEmpty = (o: any): boolean => (
72
+ const isObjectType = (v: unknown): v is Record<string | number, any> => typeof v === "object";
73
+ const isEmpty = (o: unknown): boolean => (
74
74
  isUndefined(o) || o === null ||
75
75
  (isString(o) && o.length === 0) ||
76
76
  (isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0) ||
77
77
  (isNumber(o) && isNaN(o))
78
78
  );
79
- const notEmpty = (o: any): boolean => !isEmpty(o);
79
+ const notEmpty = (o: unknown): boolean => !isEmpty(o);
80
80
 
81
81
  /**
82
82
  * Check if is array
@@ -84,7 +84,7 @@ const notEmpty = (o: any): boolean => !isEmpty(o);
84
84
  * @returns {boolean}
85
85
  * @private
86
86
  */
87
- const isArray = (arr: any): boolean => Array.isArray(arr);
87
+ const isArray = (arr: any): arr is any[] => Array.isArray(arr);
88
88
 
89
89
  /**
90
90
  * Check if is object
@@ -125,14 +125,15 @@ function hasValue(dict: object, value: any): boolean {
125
125
  /**
126
126
  * Call function with arguments
127
127
  * @param {Function} fn Function to be called
128
- * @param {*} args Arguments
128
+ * @param {*} thisArg "this" value for fn
129
+ * @param {*} args Arguments for fn
129
130
  * @returns {boolean} true: fn is function, false: fn is not function
130
131
  * @private
131
132
  */
132
- function callFn(fn, ...args): boolean {
133
+ function callFn(fn: unknown, thisArg: any, ...args: any[]): boolean {
133
134
  const isFn = isFunction(fn);
134
135
 
135
- isFn && fn.call(...args);
136
+ isFn && fn.call(thisArg, ...args);
136
137
  return isFn;
137
138
  }
138
139
 
@@ -262,12 +263,10 @@ function getPathBox(
262
263
  * @private
263
264
  */
264
265
  function getPointer(event, element?: Element): number[] {
265
- const touches = event && (event.touches || (event.sourceEvent && event.sourceEvent.touches));
266
- const pointer = event ?
267
- d3Pointer(touches ? touches[0] : event, element) :
268
- [0, 0];
266
+ const touches = event && (event.touches || (event.sourceEvent && event.sourceEvent.touches))?.[0];
267
+ const pointer = d3Pointer(touches || event, element);
269
268
 
270
- return pointer;
269
+ return pointer.map(v => (isNaN(v) ? 0 : v));
271
270
  }
272
271
 
273
272
  /**
@@ -51,15 +51,6 @@
51
51
  shape-rendering: crispEdges;
52
52
  }
53
53
 
54
- .bb-axis-x .tick {}
55
- .bb-axis-x-label {}
56
-
57
- .bb-axis-y .tick {}
58
- .bb-axis-y-label {}
59
-
60
- .bb-axis-y2 .tick {}
61
- .bb-axis-y2-label {}
62
-
63
54
  /*-- Grid --*/
64
55
  .bb-grid {
65
56
  pointer-events: none;
@@ -155,9 +146,6 @@
155
146
  fill-opacity: .1;
156
147
  }
157
148
 
158
- /*-- Select - Drag --*/
159
- .bb-dragarea {}
160
-
161
149
  /*-- Legend --*/
162
150
  .bb-legend-item {
163
151
  font-size: 12px;
@@ -239,7 +227,7 @@
239
227
  font-size: 1.3em;
240
228
  }
241
229
 
242
- .bb-chart-arcs-gauge-title {
230
+ text.bb-chart-arcs-gauge-title {
243
231
  dominant-baseline: middle;
244
232
  font-size: 2.7em;
245
233
  }
@@ -42,7 +42,6 @@ $text-font-size: 11px;
42
42
  .bb-axis-y text, .bb-axis-y2 text {
43
43
  fill: #737373;
44
44
  }
45
- .bb-axis-y2 .tick {}
46
45
 
47
46
  .bb-event-rects {
48
47
  fill-opacity: 1 !important;
@@ -212,10 +211,6 @@ $text-font-size: 11px;
212
211
  font-size: 13px;
213
212
  padding: 2px 8px;
214
213
  text-align:left;
215
- // border-bottom: solid 2px red;
216
- // background-color: #000;
217
- // color: #fff;
218
-
219
214
  border-bottom: solid 2px #ff2d2d;
220
215
  background-color: #0b00b1;
221
216
  color: #fffdfd;
@@ -223,7 +218,6 @@ $text-font-size: 11px;
223
218
 
224
219
  td {
225
220
  padding: 4px 6px;
226
- // background-color:#fff;
227
221
 
228
222
  &:first-child {
229
223
  padding-left: 8px;
@@ -290,7 +284,7 @@ $text-font-size: 11px;
290
284
  font-size: 1.3em;
291
285
  }
292
286
 
293
- .bb-chart-arcs-gauge-title {
287
+ text.bb-chart-arcs-gauge-title {
294
288
  dominant-baseline: middle;
295
289
  font-size: 2.7em;
296
290
  }
@@ -52,7 +52,6 @@ $axis-color: #8c8c8c;
52
52
  .bb-axis-y text, .bb-axis-y2 text {
53
53
  fill: $axis-color;
54
54
  }
55
- .bb-axis-y2 .tick {}
56
55
 
57
56
  .bb-event-rects {
58
57
  fill-opacity: 1 !important;
@@ -303,7 +302,7 @@ rect.bb-circle, use.bb-circle {
303
302
  font-size: 1.3em;
304
303
  }
305
304
 
306
- .bb-chart-arcs-gauge-title {
305
+ text.bb-chart-arcs-gauge-title {
307
306
  dominant-baseline: middle;
308
307
  font-size: 2.7em;
309
308
  }
@@ -47,7 +47,6 @@ $font-family: sans-serif, Arial, "nanumgothic", "Dotum";
47
47
  .bb-axis-y text, .bb-axis-y2 text {
48
48
  fill: #737373;
49
49
  }
50
- .bb-axis-y2 .tick {}
51
50
 
52
51
  .bb-event-rects {
53
52
  fill-opacity: 1 !important;
@@ -283,7 +282,7 @@ rect.bb-circle, use.bb-circle {
283
282
  font-size: 1.3em;
284
283
  }
285
284
 
286
- .bb-chart-arcs-gauge-title {
285
+ text.bb-chart-arcs-gauge-title {
287
286
  dominant-baseline: middle;
288
287
  font-size: 2.7em;
289
288
  }