billboard.js 3.12.4 → 3.13.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 (68) hide show
  1. package/README.md +10 -3
  2. package/dist/billboard.css +167 -118
  3. package/dist/billboard.js +213 -90
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +10 -10
  6. package/dist/billboard.pkgd.js +1212 -1504
  7. package/dist/billboard.pkgd.min.js +15 -15
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +5 -12
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +7 -13
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +9 -21
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +7 -13
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +7 -13
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +597 -628
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -5
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +759 -953
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +6 -6
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +840 -1105
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -12
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +759 -953
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +7 -7
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +832 -1092
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -7
  28. package/dist/theme/dark.css +220 -154
  29. package/dist/theme/dark.min.css +1 -1
  30. package/dist/theme/datalab.css +221 -157
  31. package/dist/theme/datalab.min.css +1 -1
  32. package/dist/theme/graph.css +223 -158
  33. package/dist/theme/graph.min.css +1 -1
  34. package/dist/theme/insight.css +212 -149
  35. package/dist/theme/insight.min.css +1 -1
  36. package/dist/theme/modern.css +223 -159
  37. package/dist/theme/modern.min.css +1 -1
  38. package/dist-esm/billboard.js +249 -73
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  44. package/package.json +28 -42
  45. package/src/Chart/api/show.ts +1 -1
  46. package/src/ChartInternal/ChartInternal.ts +1 -1
  47. package/src/ChartInternal/data/data.ts +11 -0
  48. package/src/ChartInternal/interactions/zoom.ts +12 -1
  49. package/src/ChartInternal/internals/legend.ts +1 -1
  50. package/src/ChartInternal/internals/scale.ts +13 -5
  51. package/src/ChartInternal/shape/line.ts +170 -41
  52. package/src/ChartInternal/shape/shape.ts +8 -5
  53. package/src/config/Options/axis/y2.ts +13 -0
  54. package/src/config/Options/common/legend.ts +3 -2
  55. package/src/config/Options/data/axis.ts +6 -2
  56. package/src/config/Options/data/data.ts +7 -4
  57. package/src/config/Options/shape/bar.ts +22 -6
  58. package/src/config/const.ts +10 -4
  59. package/src/config/resolver/shape.ts +4 -0
  60. package/src/index.esm.ts +1 -0
  61. package/src/module/browser.ts +1 -1
  62. package/src/module/util.ts +2 -2
  63. package/src/module/worker.ts +1 -1
  64. package/types/bb.d.ts +1 -0
  65. package/types/index.d.ts +1 -0
  66. package/types/options.d.ts +6 -6
  67. package/types/options.shape.d.ts +10 -1
  68. package/types/types.d.ts +1 -0
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.12.4
8
+ * @version 3.13.0-next.2
9
9
  */
10
10
  import { pointer, select, namespaces, selectAll } from 'd3-selection';
11
11
  import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
@@ -426,7 +426,8 @@ var legend$2 = {
426
426
  * - rectangle
427
427
  * @property {boolean} [legend.format] Set formatter function for legend text.
428
428
  * The argument:<br>
429
- * - `id`: legend text value. When `data.names` is specified, will pass from it, otherwise will pass data id.
429
+ * - `id`: Legend text value. When `data.names` is specified, will pass from it, otherwise will pass data id.
430
+ * - `dataId`: When `data.names` specified, will pass the original data id. Otherwise will be undefined.
430
431
  * @property {boolean} [legend.tooltip=false] Show full legend text value using system tooltip(via `<title>` element).
431
432
  * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
432
433
  * @see [Demo: format](https://naver.github.io/billboard.js/demo/#Legend.LegendFormat)
@@ -492,7 +493,7 @@ var legend$2 = {
492
493
  * r: 10
493
494
  * }
494
495
  * },
495
- * format: function(id) {
496
+ * format: function(id, dataId) {
496
497
  * // set ellipsis string when length is > 5
497
498
  * // to get full legend value, combine with 'legend.tooltip=true'
498
499
  * if (id.length > 5) {
@@ -1302,6 +1303,7 @@ var data$2 = {
1302
1303
  * - area-spline
1303
1304
  * - area-spline-range
1304
1305
  * - area-step
1306
+ * - area-step-range
1305
1307
  * - bar
1306
1308
  * - bubble
1307
1309
  * - candlestick
@@ -1333,6 +1335,7 @@ var data$2 = {
1333
1335
  * areaSpline,
1334
1336
  * areaSplineRange,
1335
1337
  * areaStep,
1338
+ * areaStepRange,
1336
1339
  * bar,
1337
1340
  * bubble,
1338
1341
  * candlestick,
@@ -1381,6 +1384,7 @@ var data$2 = {
1381
1384
  * areaSpline,
1382
1385
  * areaSplineRange,
1383
1386
  * areaStep,
1387
+ * areaStepRange,
1384
1388
  * bar,
1385
1389
  * bubble,
1386
1390
  * candlestick,
@@ -1769,7 +1773,7 @@ var data$2 = {
1769
1773
  data_onhidden: undefined,
1770
1774
  /**
1771
1775
  * Set a callback for minimum data
1772
- * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
1776
+ * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
1773
1777
  * @name data․onmin
1774
1778
  * @memberof Options
1775
1779
  * @type {Function}
@@ -1784,7 +1788,7 @@ var data$2 = {
1784
1788
  data_onmin: undefined,
1785
1789
  /**
1786
1790
  * Set a callback for maximum data
1787
- * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
1791
+ * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
1788
1792
  * @name data․onmax
1789
1793
  * @memberof Options
1790
1794
  * @type {Function}
@@ -1887,7 +1891,7 @@ var data$2 = {
1887
1891
  * type: "bar"
1888
1892
  * }
1889
1893
  *
1890
- * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
1894
+ * // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
1891
1895
  * // - an array of [high, mid, low] data following the order
1892
1896
  * // - or an object with 'high', 'mid' and 'low' key value
1893
1897
  * data: {
@@ -1972,7 +1976,7 @@ var data$2 = {
1972
1976
  * type: "bar"
1973
1977
  * }
1974
1978
  *
1975
- * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
1979
+ * // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
1976
1980
  * // - an array of [high, mid, low] data following the order
1977
1981
  * // - or an object with 'high', 'mid' and 'low' key value
1978
1982
  * data: {
@@ -2579,8 +2583,8 @@ function getCssRules(styleSheets) {
2579
2583
  function getScrollPosition(node) {
2580
2584
  var _a, _b, _c, _d, _e, _f;
2581
2585
  return {
2582
- x: (_c = ((_b = (_a = win.pageXOffset) !== null && _a !== void 0 ? _a : win.scrollX) !== null && _b !== void 0 ? _b : 0) + node.scrollLeft) !== null && _c !== void 0 ? _c : 0,
2583
- y: (_f = ((_e = (_d = win.pageYOffset) !== null && _d !== void 0 ? _d : win.scrollY) !== null && _e !== void 0 ? _e : 0) + node.scrollTop) !== null && _f !== void 0 ? _f : 0
2586
+ x: ((_b = (_a = win.pageXOffset) !== null && _a !== void 0 ? _a : win.scrollX) !== null && _b !== void 0 ? _b : 0) + ((_c = node.scrollLeft) !== null && _c !== void 0 ? _c : 0),
2587
+ y: ((_e = (_d = win.pageYOffset) !== null && _d !== void 0 ? _d : win.scrollY) !== null && _e !== void 0 ? _e : 0) + ((_f = node.scrollTop) !== null && _f !== void 0 ? _f : 0)
2584
2588
  };
2585
2589
  }
2586
2590
  /**
@@ -3238,6 +3242,7 @@ var TYPE = {
3238
3242
  AREA_SPLINE: "area-spline",
3239
3243
  AREA_SPLINE_RANGE: "area-spline-range",
3240
3244
  AREA_STEP: "area-step",
3245
+ AREA_STEP_RANGE: "area-step-range",
3241
3246
  BAR: "bar",
3242
3247
  BUBBLE: "bubble",
3243
3248
  CANDLESTICK: "candlestick",
@@ -3263,6 +3268,7 @@ var TYPE_METHOD_NEEDED = {
3263
3268
  AREA_SPLINE: "initArea",
3264
3269
  AREA_SPLINE_RANGE: "initArea",
3265
3270
  AREA_STEP: "initArea",
3271
+ AREA_STEP_RANGE: "initArea",
3266
3272
  BAR: "initBar",
3267
3273
  BUBBLE: "initCircle",
3268
3274
  CANDLESTICK: "initCandlestick",
@@ -3288,11 +3294,13 @@ var TYPE_BY_CATEGORY = {
3288
3294
  TYPE.AREA_SPLINE,
3289
3295
  TYPE.AREA_SPLINE_RANGE,
3290
3296
  TYPE.AREA_LINE_RANGE,
3291
- TYPE.AREA_STEP
3297
+ TYPE.AREA_STEP,
3298
+ TYPE.AREA_STEP_RANGE
3292
3299
  ],
3293
3300
  AreaRange: [
3294
3301
  TYPE.AREA_SPLINE_RANGE,
3295
- TYPE.AREA_LINE_RANGE
3302
+ TYPE.AREA_LINE_RANGE,
3303
+ TYPE.AREA_STEP_RANGE
3296
3304
  ],
3297
3305
  Arc: [
3298
3306
  TYPE.PIE,
@@ -3309,11 +3317,13 @@ var TYPE_BY_CATEGORY = {
3309
3317
  TYPE.AREA_SPLINE_RANGE,
3310
3318
  TYPE.AREA_LINE_RANGE,
3311
3319
  TYPE.STEP,
3312
- TYPE.AREA_STEP
3320
+ TYPE.AREA_STEP,
3321
+ TYPE.AREA_STEP_RANGE
3313
3322
  ],
3314
3323
  Step: [
3315
3324
  TYPE.STEP,
3316
- TYPE.AREA_STEP
3325
+ TYPE.AREA_STEP,
3326
+ TYPE.AREA_STEP_RANGE
3317
3327
  ],
3318
3328
  Spline: [
3319
3329
  TYPE.SPLINE,
@@ -4446,10 +4456,23 @@ var data$1 = {
4446
4456
  return (isBoolean(dataLabels) && dataLabels) ||
4447
4457
  (isObjectType(dataLabels) && notEmpty(dataLabels));
4448
4458
  },
4459
+ /**
4460
+ * Determine if has null value
4461
+ * @param {Array} targets Data array to be evaluated
4462
+ * @returns {boolean}
4463
+ * @private
4464
+ */
4465
+ hasNullDataValue: function (targets) {
4466
+ return targets.some(function (_a) {
4467
+ var value = _a.value;
4468
+ return value === null;
4469
+ });
4470
+ },
4449
4471
  /**
4450
4472
  * Get data index from the event coodinates
4451
4473
  * @param {Event} event Event object
4452
4474
  * @returns {number}
4475
+ * @private
4453
4476
  */
4454
4477
  getDataIndexFromEvent: function (event) {
4455
4478
  var $$ = this;
@@ -6057,7 +6080,7 @@ function getFormattedText(id, formatted) {
6057
6080
  var config = this.config;
6058
6081
  var text = (_a = config.data_names[id]) !== null && _a !== void 0 ? _a : id;
6059
6082
  if (formatted && isFunction(config.legend_format)) {
6060
- text = config.legend_format(text);
6083
+ text = config.legend_format(text, id !== text ? id : undefined);
6061
6084
  }
6062
6085
  return text;
6063
6086
  }
@@ -7011,15 +7034,13 @@ var redraw = {
7011
7034
  /**
7012
7035
  * Get scale
7013
7036
  * @param {string} [type='linear'] Scale type
7014
- * @param {number} [min] Min range
7015
- * @param {number} [max] Max range
7037
+ * @param {number|Date} [min] Min range
7038
+ * @param {number|Date} [max] Max range
7016
7039
  * @returns {d3.scaleLinear|d3.scaleTime} scale
7017
7040
  * @private
7018
7041
  */
7019
7042
  function getScale(type, min, max) {
7020
7043
  if (type === void 0) { type = "linear"; }
7021
- if (min === void 0) { min = 0; }
7022
- if (max === void 0) { max = 1; }
7023
7044
  var scale = ({
7024
7045
  linear: scaleLinear,
7025
7046
  log: scaleSymlog,
@@ -7029,7 +7050,7 @@ function getScale(type, min, max) {
7029
7050
  })[type]();
7030
7051
  scale.type = type;
7031
7052
  /_?log/.test(type) && scale.clamp(true);
7032
- return scale.range([min, max]);
7053
+ return scale.range([min !== null && min !== void 0 ? min : 0, max !== null && max !== void 0 ? max : 1]);
7033
7054
  }
7034
7055
  var scale = {
7035
7056
  /**
@@ -7087,6 +7108,13 @@ var scale = {
7087
7108
  var $$ = this;
7088
7109
  var offset = offsetValue || (function () { return $$.axis.x.tickOffset(); });
7089
7110
  var isInverted = $$.config.axis_x_inverted;
7111
+ /**
7112
+ * Get scaled value
7113
+ * @param {object} d Data object
7114
+ * @param {boolean} raw Get the raw value
7115
+ * @returns {number}
7116
+ * @private
7117
+ */
7090
7118
  var scale = function (d, raw) {
7091
7119
  var v = scaleValue(d) + offset();
7092
7120
  return raw ? v : Math.ceil(v);
@@ -9434,7 +9462,7 @@ var shape = {
9434
9462
  getBarW: function (type, axis, targetsNum) {
9435
9463
  var _a, _b, _c, _d, _e;
9436
9464
  var $$ = this;
9437
- var config = $$.config, org = $$.org, scale = $$.scale;
9465
+ var config = $$.config, org = $$.org, scale = $$.scale, state = $$.state;
9438
9466
  var maxDataCount = $$.getMaxDataCount();
9439
9467
  var isGrouped = type === "bar" && ((_a = config.data_groups) === null || _a === void 0 ? void 0 : _a.length);
9440
9468
  var configName = "".concat(type, "_width");
@@ -9455,9 +9483,9 @@ var shape = {
9455
9483
  var width = id ? config[configName][id] : config[configName];
9456
9484
  var ratio = id ? width.ratio : config["".concat(configName, "_ratio")];
9457
9485
  var max = id ? width.max : config["".concat(configName, "_max")];
9458
- var w = isNumber(width) ?
9459
- width :
9460
- (targetsNum ? (tickInterval * ratio) / targetsNum : 0);
9486
+ var w = isNumber(width) ? width : (isFunction(width) ?
9487
+ width.call($$, state.width, targetsNum, maxDataCount) :
9488
+ (targetsNum ? (tickInterval * ratio) / targetsNum : 0));
9461
9489
  return max && w > max ? max : w;
9462
9490
  };
9463
9491
  var result = getWidth();
@@ -9510,7 +9538,7 @@ var shape = {
9510
9538
  }
9511
9539
  else if ((_a = $$.hasValidPointType) === null || _a === void 0 ? void 0 : _a.call($$, that.nodeName)) {
9512
9540
  isWithin = $$.isStepType(d) ?
9513
- $$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) :
9541
+ $$.isWithinStep(that, $$.getYScaleById(d.id)($$.getBaseValue(d))) :
9514
9542
  $$.isWithinCircle(that, $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0);
9515
9543
  }
9516
9544
  else if (that.nodeName === "path") {
@@ -9858,7 +9886,7 @@ var ChartInternal = /** @class */ (function () {
9858
9886
  labelsBGColor || ((_a = $$.hasLegendDefsPoint) === null || _a === void 0 ? void 0 : _a.call($$))) {
9859
9887
  $el.defs = $el.svg.append("defs");
9860
9888
  if (hasAxis) {
9861
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
9889
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(function (v) {
9862
9890
  $$.appendClip($el.defs, state.clip[v]);
9863
9891
  });
9864
9892
  }
@@ -11275,10 +11303,11 @@ function showHide(show, targetIdsValue, options) {
11275
11303
  $$.$T(targets)
11276
11304
  .style("opacity", opacity, "important")
11277
11305
  .call(endall, function () {
11306
+ var _a;
11278
11307
  // https://github.com/naver/billboard.js/issues/1758
11279
11308
  if (!show && hiddenIds.length === 0) {
11280
11309
  targets.style("display", "none");
11281
- callFn($$.config.data_onhidden, _this, targetIds);
11310
+ callFn((_a = $$.config) === null || _a === void 0 ? void 0 : _a.data_onhidden, _this, targetIds);
11282
11311
  }
11283
11312
  targets.style("opacity", opacity);
11284
11313
  });
@@ -16818,6 +16847,18 @@ var y = {
16818
16847
  * y2 Axis config options
16819
16848
  */
16820
16849
  var y2 = {
16850
+ /**
16851
+ * Set clip-path attribute for y2 axis element
16852
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
16853
+ * @name axis․y2․clipPath
16854
+ * @memberof Options
16855
+ * @type {boolean}
16856
+ * @default true
16857
+ * @example
16858
+ * // don't set 'clip-path' attribute
16859
+ * clipPath: false
16860
+ */
16861
+ axis_y2_clipPath: true,
16821
16862
  /**
16822
16863
  * Show or hide y2 axis.
16823
16864
  * - **NOTE**:
@@ -17481,8 +17522,12 @@ var optDataAxis = {
17481
17522
  * - The object type should be as:
17482
17523
  * - start {number}: Start data point number. If not set, the start will be the first data point.
17483
17524
  * - [end] {number}: End data point number. If not set, the end will be the last data point.
17484
- * - [style.dasharray="2 2"] {object}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
17485
- * - **NOTE:** Currently this option supports only line chart and dashed style. If this option specified, the line will be dashed only in the regions.
17525
+ * - [style.dasharray="2 2"] {string}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
17526
+ * - **NOTE:**
17527
+ * - Supports only line type.
17528
+ * - `start` and `end` values should be in the exact x value range.
17529
+ * - Dashes will be applied using `stroke-dasharray` css property when data doesn't contain nullish value(or nullish value with `line.connectNull=true` set).
17530
+ * - Dashes will be applied via path command when data contains nullish value.
17486
17531
  * @name data․regions
17487
17532
  * @memberof Options
17488
17533
  * @type {object}
@@ -19606,6 +19651,63 @@ var shapeGauge = {
19606
19651
  * Copyright (c) 2017 ~ present NAVER Corp.
19607
19652
  * billboard.js project is licensed under the MIT license
19608
19653
  */
19654
+ /**
19655
+ * Get stroke dasharray style value
19656
+ * @param {number} start Start position in path length
19657
+ * @param {number} end End position in path length
19658
+ * @param {Array} pattern Dash array pattern
19659
+ * @param {boolean} isLastX Weather is last x tick
19660
+ * @returns {object} Stroke dasharray style value and its length
19661
+ * @private
19662
+ */
19663
+ function getStrokeDashArray(start, end, pattern, isLastX) {
19664
+ if (isLastX === void 0) { isLastX = false; }
19665
+ var dash = start ? [start, 0] : pattern;
19666
+ var _loop_1 = function (i) {
19667
+ pattern.forEach(function (v) {
19668
+ if (i + v <= end) {
19669
+ dash.push(v);
19670
+ }
19671
+ i += v;
19672
+ });
19673
+ out_i_1 = i;
19674
+ };
19675
+ var out_i_1;
19676
+ for (var i = start ? start : pattern.reduce(function (a, c) { return a + c; }); i <= end;) {
19677
+ _loop_1(i);
19678
+ i = out_i_1;
19679
+ }
19680
+ // make sure to have even length
19681
+ dash.length % 2 !== 0 && dash.push(isLastX ? pattern[1] : 0);
19682
+ return {
19683
+ dash: dash.join(" "),
19684
+ length: dash.reduce(function (a, b) { return a + b; }, 0)
19685
+ };
19686
+ }
19687
+ /**
19688
+ * Get regions data
19689
+ * @param {Array} d Data object
19690
+ * @param {object} _regions regions to be set
19691
+ * @param {boolean} isTimeSeries whether is time series
19692
+ * @returns {object} Regions data
19693
+ * @private
19694
+ */
19695
+ function getRegions(d, _regions, isTimeSeries) {
19696
+ var $$ = this;
19697
+ var regions = [];
19698
+ var dasharray = "2 2"; // default value
19699
+ // Check start/end of regions
19700
+ if (isDefined(_regions)) {
19701
+ var getValue = function (v, def) { return (isUndefined(v) ? def : (isTimeSeries ? parseDate.call($$, v) : v)); };
19702
+ for (var i = 0, reg = void 0; (reg = _regions[i]); i++) {
19703
+ var start = getValue(reg.start, d[0].x);
19704
+ var end = getValue(reg.end, d[d.length - 1].x);
19705
+ var style = reg.style || { dasharray: dasharray };
19706
+ regions[i] = { start: start, end: end, style: style };
19707
+ }
19708
+ }
19709
+ return regions;
19710
+ }
19609
19711
  var shapeLine = {
19610
19712
  initLine: function () {
19611
19713
  var $el = this.$el;
@@ -19673,6 +19775,7 @@ var shapeLine = {
19673
19775
  * @param {boolean} withTransition With or without transition
19674
19776
  * @param {boolean} isSub Subchart draw
19675
19777
  * @returns {Array}
19778
+ * @private
19676
19779
  */
19677
19780
  redrawLine: function (drawFn, withTransition, isSub) {
19678
19781
  if (isSub === void 0) { isSub = false; }
@@ -19761,27 +19864,28 @@ var shapeLine = {
19761
19864
  return path || "M 0 0";
19762
19865
  };
19763
19866
  },
19867
+ /**
19868
+ * Set regions dasharray and get path
19869
+ * @param {Array} d Data object
19870
+ * @param {Function} x x scale function
19871
+ * @param {Function} y y scale function
19872
+ * @param {object} _regions regions to be set
19873
+ * @returns {stirng} Path string
19874
+ * @private
19875
+ */
19764
19876
  lineWithRegions: function (d, x, y, _regions) {
19765
19877
  var $$ = this;
19766
19878
  var config = $$.config;
19767
19879
  var isRotated = config.axis_rotated;
19768
19880
  var isTimeSeries = $$.axis.isTimeSeries();
19769
- var regions = [];
19770
19881
  var dasharray = "2 2"; // default value
19882
+ var regions = getRegions.bind($$)(d, _regions, isTimeSeries);
19883
+ // when contains null data, can't apply style dashed
19884
+ var hasNullDataValue = $$.hasNullDataValue(d);
19771
19885
  var xp;
19772
19886
  var yp;
19773
19887
  var diff;
19774
19888
  var diffx2;
19775
- // Check start/end of regions
19776
- if (isDefined(_regions)) {
19777
- var getValue = function (v, def) { return (isUndefined(v) ? def : (isTimeSeries ? parseDate.call($$, v) : v)); };
19778
- for (var i = 0, reg = void 0; (reg = _regions[i]); i++) {
19779
- var start = getValue(reg.start, d[0].x);
19780
- var end = getValue(reg.end, d[d.length - 1].x);
19781
- var style = reg.style || { dasharray: dasharray };
19782
- regions[i] = { start: start, end: end, style: style };
19783
- }
19784
- }
19785
19889
  // Set scales
19786
19890
  var xValue = isRotated ? function (dt) { return y(dt.value); } : function (dt) { return x(dt.x); };
19787
19891
  var yValue = isRotated ? function (dt) { return x(dt.x); } : function (dt) { return y(dt.value); };
@@ -19801,20 +19905,42 @@ var shapeLine = {
19801
19905
  return generateM(points);
19802
19906
  } :
19803
19907
  function (d0, d1, k, otherDiff) {
19804
- var points = isRotated ?
19805
- [[y(yp(k), true), x(xp(k))], [
19806
- y(yp(k + otherDiff), true),
19807
- x(xp(k + otherDiff))
19808
- ]] :
19809
- [[x(xp(k), true), y(yp(k))], [
19810
- x(xp(k + otherDiff), true),
19811
- y(yp(k + otherDiff))
19812
- ]];
19908
+ var x0 = x(d1.x, !isRotated);
19909
+ var y0 = y(d1.value, isRotated);
19910
+ var gap = k + otherDiff;
19911
+ var xValue = x(xp(k), !isRotated);
19912
+ var yValue = y(yp(k), isRotated);
19913
+ var xDiff = x(xp(gap), !isRotated);
19914
+ var yDiff = y(yp(gap), isRotated);
19915
+ // fix diff values not to overflow
19916
+ if (xDiff > x0) {
19917
+ xDiff = x0;
19918
+ }
19919
+ if (d0.value > d1.value && (isRotated ? yDiff < y0 : yDiff > y0)) {
19920
+ yDiff = y0;
19921
+ }
19922
+ var points = [
19923
+ [xValue, yValue],
19924
+ [xDiff, yDiff]
19925
+ ];
19926
+ isRotated && points.forEach(function (v) { return v.reverse(); });
19813
19927
  return generateM(points);
19814
19928
  };
19815
19929
  // Generate
19816
19930
  var axisType = { x: $$.axis.getAxisType("x"), y: $$.axis.getAxisType("y") };
19817
19931
  var path = "";
19932
+ // clone the line path to be used to get length value
19933
+ var target = $$.$el.line.filter(function (_a) {
19934
+ var id = _a.id;
19935
+ return id === d[0].id;
19936
+ });
19937
+ var tempNode = target.clone().style("display", "none");
19938
+ var getLength = function (node, path) { return node.attr("d", path).node().getTotalLength(); };
19939
+ var dashArray = {
19940
+ dash: [],
19941
+ lastLength: 0
19942
+ };
19943
+ var isLastX = false;
19818
19944
  for (var i = 0, data = void 0; (data = d[i]); i++) {
19819
19945
  var prevData = d[i - 1];
19820
19946
  var hasPrevData = prevData && isValue(prevData.value);
@@ -19828,29 +19954,58 @@ var shapeLine = {
19828
19954
  path += "".concat(i && hasPrevData ? "L" : "M").concat(xValue(data), ",").concat(yValue(data));
19829
19955
  }
19830
19956
  else if (hasPrevData) {
19831
- try {
19832
- style = style.dasharray.split(" ");
19833
- }
19834
- catch (e) {
19835
- style = dasharray.split(" ");
19836
- }
19957
+ style = ((style === null || style === void 0 ? void 0 : style.dasharray) || dasharray).split(" ").map(Number);
19837
19958
  // Draw with region // TODO: Fix for horizotal charts
19838
19959
  xp = getScale(axisType.x, prevData.x, data.x);
19839
19960
  yp = getScale(axisType.y, prevData.value, data.value);
19840
- var dx = x(data.x) - x(prevData.x);
19841
- var dy = y(data.value) - y(prevData.value);
19842
- var dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
19843
- diff = style[0] / dd;
19844
- diffx2 = diff * style[1];
19845
- for (var j = diff; j <= 1; j += diffx2) {
19846
- path += sWithRegion(prevData, data, j, diff);
19847
- // to make sure correct line drawing
19848
- if (j + diffx2 >= 1) {
19849
- path += sWithRegion(prevData, data, 1, 0);
19961
+ // when it contains null data, dash can't be applied with style
19962
+ if (hasNullDataValue) {
19963
+ var dx = x(data.x) - x(prevData.x);
19964
+ var dy = y(data.value) - y(prevData.value);
19965
+ var dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
19966
+ diff = style[0] / dd; // dash
19967
+ diffx2 = diff * style[1]; // gap
19968
+ for (var j = diff; j <= 1; j += diffx2) {
19969
+ path += sWithRegion(prevData, data, j, diff);
19970
+ // to make sure correct line drawing
19971
+ if (j + diffx2 >= 1) {
19972
+ path += sWithRegion(prevData, data, 1, 0);
19973
+ }
19974
+ }
19975
+ }
19976
+ else {
19977
+ var points = [];
19978
+ isLastX = data.x === d[d.length - 1].x;
19979
+ if (isTimeSeries) {
19980
+ var x0 = +prevData.x;
19981
+ var xv0 = new Date(x0);
19982
+ var xv1 = new Date(x0 + (+data.x - x0));
19983
+ points = [
19984
+ [x(xv0), y(yp(0))], // M
19985
+ [x(xv1), y(yp(1))] // L
19986
+ ];
19987
+ }
19988
+ else {
19989
+ points = [
19990
+ [x(xp(0)), y(yp(0))], // M
19991
+ [x(xp(1)), y(yp(1))] // L
19992
+ ];
19850
19993
  }
19994
+ isRotated && points.forEach(function (v) { return v.reverse(); });
19995
+ var startLength = getLength(tempNode, path);
19996
+ var endLength = getLength(tempNode, path += "L".concat(points[1].join(",")));
19997
+ var strokeDashArray = getStrokeDashArray(startLength - dashArray.lastLength, endLength - dashArray.lastLength, style, isLastX);
19998
+ dashArray.lastLength += strokeDashArray.length;
19999
+ dashArray.dash.push(strokeDashArray.dash);
19851
20000
  }
19852
20001
  }
19853
20002
  }
20003
+ if (dashArray.dash.length) {
20004
+ // if not last x tick, then should draw rest of path that is not drawed yet
20005
+ !isLastX && dashArray.dash.push(getLength(tempNode, path));
20006
+ tempNode.remove();
20007
+ target.attr("stroke-dasharray", dashArray.dash.join(" "));
20008
+ }
19854
20009
  return path;
19855
20010
  },
19856
20011
  isWithinRegions: function (withinX, withinRegions) {
@@ -21366,14 +21521,19 @@ var optBar = {
21366
21521
  * @property {number} [bar.radius] Set the radius of bar edge in pixel.
21367
21522
  * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
21368
21523
  * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
21369
- * @property {number} [bar.width] Change the width of bar chart.
21524
+ * @property {number|Function|object} [bar.width] Change the width of bar chart.
21370
21525
  * @property {number} [bar.width.ratio=0.6] Change the width of bar chart by ratio.
21526
+ * - **NOTE:** Criteria for ratio.
21527
+ * - When x ticks count is same with the data count, the baseline for ratio is the minimum interval value of x ticks.
21528
+ * - ex. when timeseries x values are: [2024-01-01, 2024-02-01, 2024-03-01], the minimum interval will be `2024-02-01 ~ 2024-03-01`
21529
+ * - if the minimum interval is 30px, then ratio=1 means 30px.
21530
+ * - When x ticks count is lower than the data count, the baseline will be calculated as `chart width / data count`.
21531
+ * - ex. when chart width is 500, data count is 5, then ratio=1 means 100px.
21371
21532
  * @property {number} [bar.width.max] The maximum width value for ratio.
21372
21533
  * @property {number} [bar.width.dataname] Change the width of bar for indicated dataset only.
21373
- * - **NOTE:**
21374
- * - Works only for non-stacked bar
21375
- * - Bars are centered accoding its total width value
21376
21534
  * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
21535
+ * - **NOTE:**
21536
+ * - Works only for non-stacked bar
21377
21537
  * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
21378
21538
  * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
21379
21539
  * @see [Demo: bar front](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarFront)
@@ -21441,7 +21601,15 @@ var optBar = {
21441
21601
  *
21442
21602
  * width: 10,
21443
21603
  *
21444
- * // or
21604
+ * // or specify width callback. The callback will receive width, targetsNum, maxDataCount as arguments.
21605
+ * // - width: chart area width
21606
+ * // - targetsNum: number of targets
21607
+ * // - maxDataCount: maximum data count among targets
21608
+ * width: function(width, targetsNum, maxDataCount) {
21609
+ * return width / (targetsNum * maxDataCount);
21610
+ * }
21611
+ *
21612
+ * // or specify ratio & max
21445
21613
  * width: {
21446
21614
  * ratio: 0.2,
21447
21615
  * max: 20
@@ -22486,6 +22654,7 @@ function extendArc(module, option) {
22486
22654
  // Area types
22487
22655
  var area = function () { return (extendLine(shapeArea, [optArea]), (area = function () { return TYPE.AREA; })()); };
22488
22656
  var areaLineRange = function () { return (extendLine(shapeArea, [optArea]), (areaLineRange = function () { return TYPE.AREA_LINE_RANGE; })()); };
22657
+ var areaStepRange = function () { return (extendLine(shapeArea, [optArea]), (areaStepRange = function () { return TYPE.AREA_STEP_RANGE; })()); };
22489
22658
  var areaSpline = function () { return (extendLine(shapeArea, [optArea, optSpline]), (areaSpline = function () { return TYPE.AREA_SPLINE; })()); };
22490
22659
  var areaSplineRange = function () { return (extendLine(shapeArea, [optArea, optSpline]), (areaSplineRange = function () { return TYPE.AREA_SPLINE_RANGE; })()); };
22491
22660
  var areaStep = function () { return (extendLine(shapeArea, [optArea]), (areaStep = function () { return TYPE.AREA_STEP; })()); };
@@ -23549,8 +23718,15 @@ var zoom = {
23549
23718
  */
23550
23719
  bindZoomOnEventRect: function () {
23551
23720
  var $$ = this;
23552
- var config = $$.config, eventRect = $$.$el.eventRect;
23721
+ var config = $$.config, _a = $$.$el, eventRect = _a.eventRect, svg = _a.svg;
23553
23722
  var behaviour = config.zoom_type === "drag" ? $$.zoomBehaviour : $$.zoom;
23723
+ // On Safari, event can't be built inside the svg content
23724
+ // for workaround, register wheel event on <svg> element first
23725
+ // https://bugs.webkit.org/show_bug.cgi?id=226683#c3
23726
+ // https://stackoverflow.com/questions/67836886/wheel-event-is-not-fired-on-a-svg-group-element-in-safari
23727
+ if (win.GestureEvent && /^((?!chrome|android|mobile).)*safari/i.test(navigator.userAgent)) {
23728
+ svg.on("wheel", function () { });
23729
+ }
23554
23730
  eventRect === null || eventRect === void 0 ? void 0 : eventRect.call(behaviour).on("dblclick.zoom", null);
23555
23731
  },
23556
23732
  /**
@@ -24223,7 +24399,7 @@ var zoomModule = function () {
24223
24399
  var defaults = {};
24224
24400
  /**
24225
24401
  * @namespace bb
24226
- * @version 3.12.4
24402
+ * @version 3.13.0-next.2
24227
24403
  */
24228
24404
  var bb = {
24229
24405
  /**
@@ -24233,7 +24409,7 @@ var bb = {
24233
24409
  * bb.version; // "1.0.0"
24234
24410
  * @memberof bb
24235
24411
  */
24236
- version: "3.12.4",
24412
+ version: "3.13.0-next.2",
24237
24413
  /**
24238
24414
  * Generate chart
24239
24415
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
@@ -24362,4 +24538,4 @@ var bb = {
24362
24538
  plugin: {}
24363
24539
  };
24364
24540
 
24365
- export { area, areaLineRange, areaSpline, areaSplineRange, areaStep, bar, bb, bubble, candlestick, bb as default, donut, funnel, gauge, line, pie, polar, radar, scatter, selectionModule as selection, spline, step, subchartModule as subchart, treemap, zoomModule as zoom };
24541
+ export { area, areaLineRange, areaSpline, areaSplineRange, areaStep, areaStepRange, bar, bb, bubble, candlestick, bb as default, donut, funnel, gauge, line, pie, polar, radar, scatter, selectionModule as selection, spline, step, subchartModule as subchart, treemap, zoomModule as zoom };
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.12.4
8
+ * @version 3.13.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -100,7 +100,7 @@ var Plugin = /** @class */ (function () {
100
100
  delete _this[key];
101
101
  });
102
102
  };
103
- Plugin.version = "3.12.4";
103
+ Plugin.version = "3.13.0-next.2";
104
104
  return Plugin;
105
105
  }());
106
106
 
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.12.4
8
+ * @version 3.13.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -443,7 +443,7 @@ var Plugin = /** @class */ (function () {
443
443
  delete _this[key];
444
444
  });
445
445
  };
446
- Plugin.version = "3.12.4";
446
+ Plugin.version = "3.13.0-next.2";
447
447
  return Plugin;
448
448
  }());
449
449