billboard.js 3.12.4 → 3.13.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 (60) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +198 -82
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +10 -10
  5. package/dist/billboard.pkgd.js +660 -981
  6. package/dist/billboard.pkgd.min.js +15 -15
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +5 -12
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +4 -10
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +6 -18
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +4 -10
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +4 -10
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +60 -113
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +218 -434
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +299 -586
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +218 -434
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +3 -3
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +291 -573
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
  27. package/dist/theme/dark.css +1 -1
  28. package/dist/theme/dark.min.css +1 -1
  29. package/dist/theme/datalab.css +1 -1
  30. package/dist/theme/datalab.min.css +1 -1
  31. package/dist/theme/graph.css +1 -1
  32. package/dist/theme/graph.min.css +1 -1
  33. package/dist/theme/insight.css +1 -1
  34. package/dist/theme/insight.min.css +1 -1
  35. package/dist/theme/modern.css +1 -1
  36. package/dist/theme/modern.min.css +1 -1
  37. package/dist-esm/billboard.js +233 -66
  38. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  39. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  43. package/package.json +18 -18
  44. package/src/ChartInternal/ChartInternal.ts +1 -1
  45. package/src/ChartInternal/data/data.ts +11 -0
  46. package/src/ChartInternal/internals/scale.ts +13 -5
  47. package/src/ChartInternal/shape/line.ts +170 -41
  48. package/src/ChartInternal/shape/shape.ts +8 -5
  49. package/src/config/Options/axis/y2.ts +13 -0
  50. package/src/config/Options/data/axis.ts +6 -2
  51. package/src/config/Options/data/data.ts +7 -4
  52. package/src/config/Options/shape/bar.ts +22 -6
  53. package/src/config/const.ts +10 -4
  54. package/src/config/resolver/shape.ts +4 -0
  55. package/src/index.esm.ts +1 -0
  56. package/types/bb.d.ts +1 -0
  57. package/types/index.d.ts +1 -0
  58. package/types/options.d.ts +3 -3
  59. package/types/options.shape.d.ts +10 -1
  60. 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.1
9
9
  */
10
10
  /*-- Chart --*/
11
11
  .bb svg {
package/dist/billboard.js CHANGED
@@ -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.1
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -191,6 +191,7 @@ __webpack_require__.d(resolver_shape_namespaceObject, {
191
191
  areaSpline: function() { return areaSpline; },
192
192
  areaSplineRange: function() { return areaSplineRange; },
193
193
  areaStep: function() { return areaStep; },
194
+ areaStepRange: function() { return areaStepRange; },
194
195
  bar: function() { return resolver_shape_bar; },
195
196
  bubble: function() { return resolver_shape_bubble; },
196
197
  candlestick: function() { return resolver_shape_candlestick; },
@@ -1428,6 +1429,7 @@ const $ZOOM = {
1428
1429
  * - area-spline
1429
1430
  * - area-spline-range
1430
1431
  * - area-step
1432
+ * - area-step-range
1431
1433
  * - bar
1432
1434
  * - bubble
1433
1435
  * - candlestick
@@ -1459,6 +1461,7 @@ const $ZOOM = {
1459
1461
  * areaSpline,
1460
1462
  * areaSplineRange,
1461
1463
  * areaStep,
1464
+ * areaStepRange,
1462
1465
  * bar,
1463
1466
  * bubble,
1464
1467
  * candlestick,
@@ -1507,6 +1510,7 @@ const $ZOOM = {
1507
1510
  * areaSpline,
1508
1511
  * areaSplineRange,
1509
1512
  * areaStep,
1513
+ * areaStepRange,
1510
1514
  * bar,
1511
1515
  * bubble,
1512
1516
  * candlestick,
@@ -1898,7 +1902,7 @@ const $ZOOM = {
1898
1902
  data_onhidden: void 0,
1899
1903
  /**
1900
1904
  * Set a callback for minimum data
1901
- * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
1905
+ * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
1902
1906
  * @name data․onmin
1903
1907
  * @memberof Options
1904
1908
  * @type {Function}
@@ -1913,7 +1917,7 @@ const $ZOOM = {
1913
1917
  data_onmin: void 0,
1914
1918
  /**
1915
1919
  * Set a callback for maximum data
1916
- * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
1920
+ * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
1917
1921
  * @name data․onmax
1918
1922
  * @memberof Options
1919
1923
  * @type {Function}
@@ -2016,7 +2020,7 @@ const $ZOOM = {
2016
2020
  * type: "bar"
2017
2021
  * }
2018
2022
  *
2019
- * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
2023
+ * // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
2020
2024
  * // - an array of [high, mid, low] data following the order
2021
2025
  * // - or an object with 'high', 'mid' and 'low' key value
2022
2026
  * data: {
@@ -2101,7 +2105,7 @@ const $ZOOM = {
2101
2105
  * type: "bar"
2102
2106
  * }
2103
2107
  *
2104
- * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
2108
+ * // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
2105
2109
  * // - an array of [high, mid, low] data following the order
2106
2110
  * // - or an object with 'high', 'mid' and 'low' key value
2107
2111
  * data: {
@@ -2688,10 +2692,7 @@ var Options_spreadValues = (a, b) => {
2688
2692
  }
2689
2693
  return a;
2690
2694
  };
2691
- var __publicField = (obj, key, value) => {
2692
- Options_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
2693
- return value;
2694
- };
2695
+ var __publicField = (obj, key, value) => Options_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
2695
2696
 
2696
2697
 
2697
2698
 
@@ -2972,10 +2973,7 @@ class Store {
2972
2973
  ;// CONCATENATED MODULE: ./src/module/Cache.ts
2973
2974
  var Cache_defProp = Object.defineProperty;
2974
2975
  var Cache_defNormalProp = (obj, key, value) => key in obj ? Cache_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2975
- var Cache_publicField = (obj, key, value) => {
2976
- Cache_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
2977
- return value;
2978
- };
2976
+ var Cache_publicField = (obj, key, value) => Cache_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
2979
2977
 
2980
2978
  const KEY = {
2981
2979
  bubbleBaseLength: "$baseLength",
@@ -3070,6 +3068,7 @@ const TYPE = {
3070
3068
  AREA_SPLINE: "area-spline",
3071
3069
  AREA_SPLINE_RANGE: "area-spline-range",
3072
3070
  AREA_STEP: "area-step",
3071
+ AREA_STEP_RANGE: "area-step-range",
3073
3072
  BAR: "bar",
3074
3073
  BUBBLE: "bubble",
3075
3074
  CANDLESTICK: "candlestick",
@@ -3091,6 +3090,7 @@ const TYPE_METHOD_NEEDED = {
3091
3090
  AREA_SPLINE: "initArea",
3092
3091
  AREA_SPLINE_RANGE: "initArea",
3093
3092
  AREA_STEP: "initArea",
3093
+ AREA_STEP_RANGE: "initArea",
3094
3094
  BAR: "initBar",
3095
3095
  BUBBLE: "initCircle",
3096
3096
  CANDLESTICK: "initCandlestick",
@@ -3112,11 +3112,13 @@ const TYPE_BY_CATEGORY = {
3112
3112
  TYPE.AREA_SPLINE,
3113
3113
  TYPE.AREA_SPLINE_RANGE,
3114
3114
  TYPE.AREA_LINE_RANGE,
3115
- TYPE.AREA_STEP
3115
+ TYPE.AREA_STEP,
3116
+ TYPE.AREA_STEP_RANGE
3116
3117
  ],
3117
3118
  AreaRange: [
3118
3119
  TYPE.AREA_SPLINE_RANGE,
3119
- TYPE.AREA_LINE_RANGE
3120
+ TYPE.AREA_LINE_RANGE,
3121
+ TYPE.AREA_STEP_RANGE
3120
3122
  ],
3121
3123
  Arc: [
3122
3124
  TYPE.PIE,
@@ -3133,11 +3135,13 @@ const TYPE_BY_CATEGORY = {
3133
3135
  TYPE.AREA_SPLINE_RANGE,
3134
3136
  TYPE.AREA_LINE_RANGE,
3135
3137
  TYPE.STEP,
3136
- TYPE.AREA_STEP
3138
+ TYPE.AREA_STEP,
3139
+ TYPE.AREA_STEP_RANGE
3137
3140
  ],
3138
3141
  Step: [
3139
3142
  TYPE.STEP,
3140
- TYPE.AREA_STEP
3143
+ TYPE.AREA_STEP,
3144
+ TYPE.AREA_STEP_RANGE
3141
3145
  ],
3142
3146
  Spline: [
3143
3147
  TYPE.SPLINE,
@@ -4079,10 +4083,20 @@ function getDataKeyForJson(keysParam, config) {
4079
4083
  const dataLabels = this.config.data_labels;
4080
4084
  return isBoolean(dataLabels) && dataLabels || isObjectType(dataLabels) && notEmpty(dataLabels);
4081
4085
  },
4086
+ /**
4087
+ * Determine if has null value
4088
+ * @param {Array} targets Data array to be evaluated
4089
+ * @returns {boolean}
4090
+ * @private
4091
+ */
4092
+ hasNullDataValue(targets) {
4093
+ return targets.some(({ value }) => value === null);
4094
+ },
4082
4095
  /**
4083
4096
  * Get data index from the event coodinates
4084
4097
  * @param {Event} event Event object
4085
4098
  * @returns {number}
4099
+ * @private
4086
4100
  */
4087
4101
  getDataIndexFromEvent(event) {
4088
4102
  const $$ = this;
@@ -6266,7 +6280,7 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
6266
6280
  ;// CONCATENATED MODULE: ./src/ChartInternal/internals/scale.ts
6267
6281
 
6268
6282
 
6269
- function getScale(type = "linear", min = 0, max = 1) {
6283
+ function getScale(type = "linear", min, max) {
6270
6284
  const scale = {
6271
6285
  linear: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear,
6272
6286
  log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSymlog,
@@ -6276,7 +6290,7 @@ function getScale(type = "linear", min = 0, max = 1) {
6276
6290
  }[type]();
6277
6291
  scale.type = type;
6278
6292
  /_?log/.test(type) && scale.clamp(true);
6279
- return scale.range([min, max]);
6293
+ return scale.range([min != null ? min : 0, max != null ? max : 1]);
6280
6294
  }
6281
6295
  /* harmony default export */ var scale = ({
6282
6296
  /**
@@ -8375,7 +8389,7 @@ function getGroupedDataPointsFn(d) {
8375
8389
  getBarW(type, axis, targetsNum) {
8376
8390
  var _a, _b, _c, _d, _e;
8377
8391
  const $$ = this;
8378
- const { config, org, scale } = $$;
8392
+ const { config, org, scale, state } = $$;
8379
8393
  const maxDataCount = $$.getMaxDataCount();
8380
8394
  const isGrouped = type === "bar" && ((_a = config.data_groups) == null ? void 0 : _a.length);
8381
8395
  const configName = `${type}_width`;
@@ -8396,7 +8410,7 @@ function getGroupedDataPointsFn(d) {
8396
8410
  const width = id ? config[configName][id] : config[configName];
8397
8411
  const ratio = id ? width.ratio : config[`${configName}_ratio`];
8398
8412
  const max = id ? width.max : config[`${configName}_max`];
8399
- const w = isNumber(width) ? width : targetsNum ? tickInterval * ratio / targetsNum : 0;
8413
+ const w = isNumber(width) ? width : isFunction(width) ? width.call($$, state.width, targetsNum, maxDataCount) : targetsNum ? tickInterval * ratio / targetsNum : 0;
8400
8414
  return max && w > max ? max : w;
8401
8415
  };
8402
8416
  let result = getWidth();
@@ -8441,7 +8455,7 @@ function getGroupedDataPointsFn(d) {
8441
8455
  if (!$$.isTargetToShow(d.id)) {
8442
8456
  isWithin = false;
8443
8457
  } else if ((_a = $$.hasValidPointType) == null ? void 0 : _a.call($$, that.nodeName)) {
8444
- isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) : $$.isWithinCircle(
8458
+ isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScaleById(d.id)($$.getBaseValue(d))) : $$.isWithinCircle(
8445
8459
  that,
8446
8460
  $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0
8447
8461
  );
@@ -8501,10 +8515,7 @@ function getGroupedDataPointsFn(d) {
8501
8515
  ;// CONCATENATED MODULE: ./src/ChartInternal/ChartInternal.ts
8502
8516
  var ChartInternal_defProp = Object.defineProperty;
8503
8517
  var ChartInternal_defNormalProp = (obj, key, value) => key in obj ? ChartInternal_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8504
- var ChartInternal_publicField = (obj, key, value) => {
8505
- ChartInternal_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8506
- return value;
8507
- };
8518
+ var ChartInternal_publicField = (obj, key, value) => ChartInternal_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8508
8519
 
8509
8520
 
8510
8521
 
@@ -8791,7 +8802,7 @@ class ChartInternal {
8791
8802
  if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
8792
8803
  $el.defs = $el.svg.append("defs");
8793
8804
  if (hasAxis) {
8794
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
8805
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach((v) => {
8795
8806
  $$.appendClip($el.defs, state.clip[v]);
8796
8807
  });
8797
8808
  }
@@ -10257,10 +10268,7 @@ const tooltip_tooltip = {
10257
10268
  ;// CONCATENATED MODULE: ./src/Chart/Chart.ts
10258
10269
  var Chart_defProp = Object.defineProperty;
10259
10270
  var Chart_defNormalProp = (obj, key, value) => key in obj ? Chart_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10260
- var Chart_publicField = (obj, key, value) => {
10261
- Chart_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
10262
- return value;
10263
- };
10271
+ var Chart_publicField = (obj, key, value) => Chart_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
10264
10272
 
10265
10273
 
10266
10274
 
@@ -12594,10 +12602,7 @@ var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack
12594
12602
  ;// CONCATENATED MODULE: ./src/ChartInternal/Axis/AxisRendererHelper.ts
12595
12603
  var AxisRendererHelper_defProp = Object.defineProperty;
12596
12604
  var AxisRendererHelper_defNormalProp = (obj, key, value) => key in obj ? AxisRendererHelper_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12597
- var AxisRendererHelper_publicField = (obj, key, value) => {
12598
- AxisRendererHelper_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
12599
- return value;
12600
- };
12605
+ var AxisRendererHelper_publicField = (obj, key, value) => AxisRendererHelper_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
12601
12606
 
12602
12607
 
12603
12608
  class AxisRendererHelper {
@@ -12721,10 +12726,7 @@ class AxisRendererHelper {
12721
12726
  ;// CONCATENATED MODULE: ./src/ChartInternal/Axis/AxisRenderer.ts
12722
12727
  var AxisRenderer_defProp = Object.defineProperty;
12723
12728
  var AxisRenderer_defNormalProp = (obj, key, value) => key in obj ? AxisRenderer_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12724
- var AxisRenderer_publicField = (obj, key, value) => {
12725
- AxisRenderer_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
12726
- return value;
12727
- };
12729
+ var AxisRenderer_publicField = (obj, key, value) => AxisRenderer_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
12728
12730
 
12729
12731
 
12730
12732
 
@@ -13094,10 +13096,7 @@ class AxisRenderer {
13094
13096
  ;// CONCATENATED MODULE: ./src/ChartInternal/Axis/Axis.ts
13095
13097
  var Axis_defProp = Object.defineProperty;
13096
13098
  var Axis_defNormalProp = (obj, key, value) => key in obj ? Axis_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13097
- var Axis_publicField = (obj, key, value) => {
13098
- Axis_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13099
- return value;
13100
- };
13099
+ var Axis_publicField = (obj, key, value) => Axis_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13101
13100
 
13102
13101
 
13103
13102
 
@@ -16406,6 +16405,18 @@ function smoothLines(el, type) {
16406
16405
 
16407
16406
  ;// CONCATENATED MODULE: ./src/config/Options/axis/y2.ts
16408
16407
  /* harmony default export */ var y2 = ({
16408
+ /**
16409
+ * Set clip-path attribute for y2 axis element
16410
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
16411
+ * @name axis․y2․clipPath
16412
+ * @memberof Options
16413
+ * @type {boolean}
16414
+ * @default true
16415
+ * @example
16416
+ * // don't set 'clip-path' attribute
16417
+ * clipPath: false
16418
+ */
16419
+ axis_y2_clipPath: true,
16409
16420
  /**
16410
16421
  * Show or hide y2 axis.
16411
16422
  * - **NOTE**:
@@ -17086,8 +17097,12 @@ var axis_spreadValues = (a, b) => {
17086
17097
  * - The object type should be as:
17087
17098
  * - start {number}: Start data point number. If not set, the start will be the first data point.
17088
17099
  * - [end] {number}: End data point number. If not set, the end will be the last data point.
17089
- * - [style.dasharray="2 2"] {object}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
17090
- * - **NOTE:** Currently this option supports only line chart and dashed style. If this option specified, the line will be dashed only in the regions.
17100
+ * - [style.dasharray="2 2"] {string}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
17101
+ * - **NOTE:**
17102
+ * - Supports only line type.
17103
+ * - `start` and `end` values should be in the exact x value range.
17104
+ * - Dashes will be applied using `stroke-dasharray` css property when data doesn't contain nullish value(or nullish value with `line.connectNull=true` set).
17105
+ * - Dashes will be applied via path command when data contains nullish value.
17091
17106
  * @name data․regions
17092
17107
  * @memberof Options
17093
17108
  * @type {object}
@@ -18936,6 +18951,37 @@ function updateRatio(data) {
18936
18951
 
18937
18952
 
18938
18953
 
18954
+ function getStrokeDashArray(start, end, pattern, isLastX = false) {
18955
+ const dash = start ? [start, 0] : pattern;
18956
+ for (let i = start ? start : pattern.reduce((a, c) => a + c); i <= end; ) {
18957
+ pattern.forEach((v) => {
18958
+ if (i + v <= end) {
18959
+ dash.push(v);
18960
+ }
18961
+ i += v;
18962
+ });
18963
+ }
18964
+ dash.length % 2 !== 0 && dash.push(isLastX ? pattern[1] : 0);
18965
+ return {
18966
+ dash: dash.join(" "),
18967
+ length: dash.reduce((a, b) => a + b, 0)
18968
+ };
18969
+ }
18970
+ function getRegions(d, _regions, isTimeSeries) {
18971
+ const $$ = this;
18972
+ const regions = [];
18973
+ const dasharray = "2 2";
18974
+ if (isDefined(_regions)) {
18975
+ const getValue = (v, def) => isUndefined(v) ? def : isTimeSeries ? parseDate.call($$, v) : v;
18976
+ for (let i = 0, reg; reg = _regions[i]; i++) {
18977
+ const start = getValue(reg.start, d[0].x);
18978
+ const end = getValue(reg.end, d[d.length - 1].x);
18979
+ const style = reg.style || { dasharray };
18980
+ regions[i] = { start, end, style };
18981
+ }
18982
+ }
18983
+ return regions;
18984
+ }
18939
18985
  /* harmony default export */ var line = ({
18940
18986
  initLine() {
18941
18987
  const { $el } = this;
@@ -18980,6 +19026,7 @@ function updateRatio(data) {
18980
19026
  * @param {boolean} withTransition With or without transition
18981
19027
  * @param {boolean} isSub Subchart draw
18982
19028
  * @returns {Array}
19029
+ * @private
18983
19030
  */
18984
19031
  redrawLine(drawFn, withTransition, isSub = false) {
18985
19032
  const $$ = this;
@@ -19056,26 +19103,27 @@ function updateRatio(data) {
19056
19103
  return path || "M 0 0";
19057
19104
  };
19058
19105
  },
19106
+ /**
19107
+ * Set regions dasharray and get path
19108
+ * @param {Array} d Data object
19109
+ * @param {Function} x x scale function
19110
+ * @param {Function} y y scale function
19111
+ * @param {object} _regions regions to be set
19112
+ * @returns {stirng} Path string
19113
+ * @private
19114
+ */
19059
19115
  lineWithRegions(d, x, y, _regions) {
19060
19116
  const $$ = this;
19061
19117
  const { config } = $$;
19062
19118
  const isRotated = config.axis_rotated;
19063
19119
  const isTimeSeries = $$.axis.isTimeSeries();
19064
- const regions = [];
19065
19120
  const dasharray = "2 2";
19121
+ const regions = getRegions.bind($$)(d, _regions, isTimeSeries);
19122
+ const hasNullDataValue = $$.hasNullDataValue(d);
19066
19123
  let xp;
19067
19124
  let yp;
19068
19125
  let diff;
19069
19126
  let diffx2;
19070
- if (isDefined(_regions)) {
19071
- const getValue = (v, def) => isUndefined(v) ? def : isTimeSeries ? parseDate.call($$, v) : v;
19072
- for (let i = 0, reg; reg = _regions[i]; i++) {
19073
- const start = getValue(reg.start, d[0].x);
19074
- const end = getValue(reg.end, d[d.length - 1].x);
19075
- const style = reg.style || { dasharray };
19076
- regions[i] = { start, end, style };
19077
- }
19078
- }
19079
19127
  const xValue = isRotated ? (dt) => y(dt.value) : (dt) => x(dt.x);
19080
19128
  const yValue = isRotated ? (dt) => x(dt.x) : (dt) => y(dt.value);
19081
19129
  const generateM = (points) => `M${points[0][0]},${points[0][1]}L${points[1][0]},${points[1][1]}`;
@@ -19087,17 +19135,36 @@ function updateRatio(data) {
19087
19135
  const points = isRotated ? [[y(yp(k)), x(xv0)], [y(yp(k + diff)), x(xv1)]] : [[x(xv0), y(yp(k))], [x(xv1), y(yp(k + diff))]];
19088
19136
  return generateM(points);
19089
19137
  } : (d0, d1, k, otherDiff) => {
19090
- const points = isRotated ? [[y(yp(k), true), x(xp(k))], [
19091
- y(yp(k + otherDiff), true),
19092
- x(xp(k + otherDiff))
19093
- ]] : [[x(xp(k), true), y(yp(k))], [
19094
- x(xp(k + otherDiff), true),
19095
- y(yp(k + otherDiff))
19096
- ]];
19138
+ const x0 = x(d1.x, !isRotated);
19139
+ const y0 = y(d1.value, isRotated);
19140
+ const gap = k + otherDiff;
19141
+ const xValue2 = x(xp(k), !isRotated);
19142
+ const yValue2 = y(yp(k), isRotated);
19143
+ let xDiff = x(xp(gap), !isRotated);
19144
+ let yDiff = y(yp(gap), isRotated);
19145
+ if (xDiff > x0) {
19146
+ xDiff = x0;
19147
+ }
19148
+ if (d0.value > d1.value && (isRotated ? yDiff < y0 : yDiff > y0)) {
19149
+ yDiff = y0;
19150
+ }
19151
+ const points = [
19152
+ [xValue2, yValue2],
19153
+ [xDiff, yDiff]
19154
+ ];
19155
+ isRotated && points.forEach((v) => v.reverse());
19097
19156
  return generateM(points);
19098
19157
  };
19099
19158
  const axisType = { x: $$.axis.getAxisType("x"), y: $$.axis.getAxisType("y") };
19100
19159
  let path = "";
19160
+ const target = $$.$el.line.filter(({ id }) => id === d[0].id);
19161
+ const tempNode = target.clone().style("display", "none");
19162
+ const getLength = (node, path2) => node.attr("d", path2).node().getTotalLength();
19163
+ const dashArray = {
19164
+ dash: [],
19165
+ lastLength: 0
19166
+ };
19167
+ let isLastX = false;
19101
19168
  for (let i = 0, data; data = d[i]; i++) {
19102
19169
  const prevData = d[i - 1];
19103
19170
  const hasPrevData = prevData && isValue(prevData.value);
@@ -19108,26 +19175,61 @@ function updateRatio(data) {
19108
19175
  if (isUndefined(regions) || !style || !hasPrevData) {
19109
19176
  path += `${i && hasPrevData ? "L" : "M"}${xValue(data)},${yValue(data)}`;
19110
19177
  } else if (hasPrevData) {
19111
- try {
19112
- style = style.dasharray.split(" ");
19113
- } catch (e) {
19114
- style = dasharray.split(" ");
19115
- }
19178
+ style = ((style == null ? void 0 : style.dasharray) || dasharray).split(" ").map(Number);
19116
19179
  xp = getScale(axisType.x, prevData.x, data.x);
19117
19180
  yp = getScale(axisType.y, prevData.value, data.value);
19118
- const dx = x(data.x) - x(prevData.x);
19119
- const dy = y(data.value) - y(prevData.value);
19120
- const dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
19121
- diff = style[0] / dd;
19122
- diffx2 = diff * style[1];
19123
- for (let j = diff; j <= 1; j += diffx2) {
19124
- path += sWithRegion(prevData, data, j, diff);
19125
- if (j + diffx2 >= 1) {
19126
- path += sWithRegion(prevData, data, 1, 0);
19181
+ if (hasNullDataValue) {
19182
+ const dx = x(data.x) - x(prevData.x);
19183
+ const dy = y(data.value) - y(prevData.value);
19184
+ const dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
19185
+ diff = style[0] / dd;
19186
+ diffx2 = diff * style[1];
19187
+ for (let j = diff; j <= 1; j += diffx2) {
19188
+ path += sWithRegion(prevData, data, j, diff);
19189
+ if (j + diffx2 >= 1) {
19190
+ path += sWithRegion(prevData, data, 1, 0);
19191
+ }
19127
19192
  }
19193
+ } else {
19194
+ let points = [];
19195
+ isLastX = data.x === d[d.length - 1].x;
19196
+ if (isTimeSeries) {
19197
+ const x0 = +prevData.x;
19198
+ const xv0 = new Date(x0);
19199
+ const xv1 = new Date(x0 + (+data.x - x0));
19200
+ points = [
19201
+ [x(xv0), y(yp(0))],
19202
+ // M
19203
+ [x(xv1), y(yp(1))]
19204
+ // L
19205
+ ];
19206
+ } else {
19207
+ points = [
19208
+ [x(xp(0)), y(yp(0))],
19209
+ // M
19210
+ [x(xp(1)), y(yp(1))]
19211
+ // L
19212
+ ];
19213
+ }
19214
+ isRotated && points.forEach((v) => v.reverse());
19215
+ const startLength = getLength(tempNode, path);
19216
+ const endLength = getLength(tempNode, path += `L${points[1].join(",")}`);
19217
+ const strokeDashArray = getStrokeDashArray(
19218
+ startLength - dashArray.lastLength,
19219
+ endLength - dashArray.lastLength,
19220
+ style,
19221
+ isLastX
19222
+ );
19223
+ dashArray.lastLength += strokeDashArray.length;
19224
+ dashArray.dash.push(strokeDashArray.dash);
19128
19225
  }
19129
19226
  }
19130
19227
  }
19228
+ if (dashArray.dash.length) {
19229
+ !isLastX && dashArray.dash.push(getLength(tempNode, path));
19230
+ tempNode.remove();
19231
+ target.attr("stroke-dasharray", dashArray.dash.join(" "));
19232
+ }
19131
19233
  return path;
19132
19234
  },
19133
19235
  isWithinRegions(withinX, withinRegions) {
@@ -20432,14 +20534,19 @@ ${percentValue}%`;
20432
20534
  * @property {number} [bar.radius] Set the radius of bar edge in pixel.
20433
20535
  * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
20434
20536
  * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
20435
- * @property {number} [bar.width] Change the width of bar chart.
20537
+ * @property {number|Function|object} [bar.width] Change the width of bar chart.
20436
20538
  * @property {number} [bar.width.ratio=0.6] Change the width of bar chart by ratio.
20539
+ * - **NOTE:** Criteria for ratio.
20540
+ * - When x ticks count is same with the data count, the baseline for ratio is the minimum interval value of x ticks.
20541
+ * - 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`
20542
+ * - if the minimum interval is 30px, then ratio=1 means 30px.
20543
+ * - When x ticks count is lower than the data count, the baseline will be calculated as `chart width / data count`.
20544
+ * - ex. when chart width is 500, data count is 5, then ratio=1 means 100px.
20437
20545
  * @property {number} [bar.width.max] The maximum width value for ratio.
20438
20546
  * @property {number} [bar.width.dataname] Change the width of bar for indicated dataset only.
20439
- * - **NOTE:**
20440
- * - Works only for non-stacked bar
20441
- * - Bars are centered accoding its total width value
20442
20547
  * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
20548
+ * - **NOTE:**
20549
+ * - Works only for non-stacked bar
20443
20550
  * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
20444
20551
  * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
20445
20552
  * @see [Demo: bar front](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarFront)
@@ -20507,7 +20614,15 @@ ${percentValue}%`;
20507
20614
  *
20508
20615
  * width: 10,
20509
20616
  *
20510
- * // or
20617
+ * // or specify width callback. The callback will receive width, targetsNum, maxDataCount as arguments.
20618
+ * // - width: chart area width
20619
+ * // - targetsNum: number of targets
20620
+ * // - maxDataCount: maximum data count among targets
20621
+ * width: function(width, targetsNum, maxDataCount) {
20622
+ * return width / (targetsNum * maxDataCount);
20623
+ * }
20624
+ *
20625
+ * // or specify ratio & max
20511
20626
  * width: {
20512
20627
  * ratio: 0.2,
20513
20628
  * max: 20
@@ -21488,6 +21603,7 @@ function extendArc(module, option) {
21488
21603
  }
21489
21604
  let resolver_shape_area = () => (extendLine(shape_area, [Options_shape_area]), (resolver_shape_area = () => TYPE.AREA)());
21490
21605
  let areaLineRange = () => (extendLine(shape_area, [Options_shape_area]), (areaLineRange = () => TYPE.AREA_LINE_RANGE)());
21606
+ let areaStepRange = () => (extendLine(shape_area, [Options_shape_area]), (areaStepRange = () => TYPE.AREA_STEP_RANGE)());
21491
21607
  let areaSpline = () => (extendLine(shape_area, [Options_shape_area, spline]), (areaSpline = () => TYPE.AREA_SPLINE)());
21492
21608
  let areaSplineRange = () => (extendLine(shape_area, [Options_shape_area, spline]), (areaSplineRange = () => TYPE.AREA_SPLINE_RANGE)());
21493
21609
  let areaStep = () => (extendLine(shape_area, [Options_shape_area]), (areaStep = () => TYPE.AREA_STEP)());
@@ -21530,7 +21646,7 @@ const bb = {
21530
21646
  * bb.version; // "1.0.0"
21531
21647
  * @memberof bb
21532
21648
  */
21533
- version: "3.12.4",
21649
+ version: "3.13.0-next.1",
21534
21650
  /**
21535
21651
  * Generate chart
21536
21652
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
@@ -5,5 +5,5 @@
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.1
9
9
  */.bb svg{font:10px sans-serif;-webkit-tap-highlight-color:rgba(0,0,0,0)}.bb path,.bb line{fill:none;stroke:#000}.bb text,.bb .bb-button{-webkit-user-select:none;-moz-user-select:none;user-select:none}.bb-legend-item-tile,.bb-xgrid-focus,.bb-ygrid-focus,.bb-ygrid{shape-rendering:crispEdges}.bb-chart-arcs .bb-needle,.bb-chart-arc .bb-gauge-value{fill:#000}.bb-chart-arc path{stroke:#fff}.bb-chart-arc rect{stroke:#fff;stroke-width:1}.bb-chart-arc text{fill:#fff;font-size:13px}.bb-chart-funnels path{stroke-width:0}.bb-chart-funnels+.bb-chart-texts text{font-size:13px;fill:#fff}.bb-axis{shape-rendering:crispEdges}.bb-axis .bb-axis-x-tooltip,.bb-axis .bb-axis-y-tooltip,.bb-axis .bb-axis-y2-tooltip{font-size:1em;fill:#fff;white-space:nowrap}.bb-grid{pointer-events:none}.bb-grid line{stroke:#aaa}.bb-grid text{fill:#aaa}.bb-xgrid,.bb-ygrid{stroke-dasharray:3 3}.bb-text.bb-empty{fill:gray;font-size:2em}.bb-line{stroke-width:1px}.bb-circle._expanded_{stroke-width:1px;stroke:#fff}.bb-selected-circle{fill:#fff;stroke-width:2px}.bb-bar{stroke-width:0}.bb-bar._expanded_{fill-opacity:.75}.bb-candlestick{stroke-width:1px}.bb-candlestick._expanded_{fill-opacity:.75}.bb-target.bb-focused,.bb-circles.bb-focused{opacity:1}.bb-target.bb-focused path.bb-line,.bb-target.bb-focused path.bb-step,.bb-circles.bb-focused path.bb-line,.bb-circles.bb-focused path.bb-step{stroke-width:2px}.bb-target.bb-defocused,.bb-circles.bb-defocused{opacity:.3!important}.bb-target.bb-defocused .text-overlapping,.bb-circles.bb-defocused .text-overlapping{opacity:.05!important}.bb-region{fill:#4682b4}.bb-region rect{fill-opacity:.1}.bb-zoom-brush,.bb-brush .extent{fill-opacity:.1}.bb-legend-item{font-size:12px;user-select:none}.bb-legend-item-hidden{opacity:.15}.bb-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.bb-title{font:14px sans-serif}.bb-chart-treemaps rect{stroke:#fff;stroke-width:1px}.bb-tooltip-container{z-index:10;user-select:none}.bb-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;opacity:.9;box-shadow:7px 7px 12px -9px #777;white-space:nowrap}.bb-tooltip tr{border:1px solid #CCC}.bb-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#fff}.bb-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.bb-tooltip td>span,.bb-tooltip td>svg{display:inline-block;width:10px;height:10px;margin-right:6px}.bb-tooltip.value{text-align:right}.bb-area{stroke-width:0;opacity:.2}.bb-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}text.bb-chart-arcs-gauge-title{dominant-baseline:middle;font-size:2.7em}.bb-chart-arcs .bb-chart-arcs-background{fill:#e0e0e0;stroke:#fff}.bb-chart-arcs .bb-chart-arcs-gauge-unit{fill:#000;font-size:16px}.bb-chart-arcs .bb-chart-arcs-gauge-max,.bb-chart-arcs .bb-chart-arcs-gauge-min{fill:#777}.bb-chart-arcs .bb-levels circle{fill:none;stroke:#848282;stroke-width:.5px}.bb-chart-arcs .bb-levels text{fill:#848282}.bb-chart-radars .bb-levels polygon{fill:none;stroke:#848282;stroke-width:.5px}.bb-chart-radars .bb-levels text{fill:#848282}.bb-chart-radars .bb-axis line{stroke:#848282;stroke-width:.5px}.bb-chart-radars .bb-axis text{font-size:1.15em;cursor:default}.bb-chart-radars .bb-shapes polygon{fill-opacity:.2;stroke-width:1px}.bb-button{position:absolute;top:10px;right:10px}.bb-button .bb-zoom-reset{font-size:11px;border:solid 1px #ccc;background-color:#fff;padding:5px;border-radius:5px;cursor:pointer}