billboard.js 3.17.4 → 3.18.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 (137) hide show
  1. package/CONTRIBUTING.md +12 -12
  2. package/README.md +12 -12
  3. package/dist/billboard.css +15 -1
  4. package/dist/billboard.js +1146 -463
  5. package/dist/billboard.min.css +2 -2
  6. package/dist/billboard.min.js +10 -10
  7. package/dist/billboard.pkgd.js +1147 -464
  8. package/dist/billboard.pkgd.min.js +21 -21
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-sparkline.js +117 -26
  12. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
  13. package/dist/plugin/billboardjs-plugin-stanford.js +119 -28
  14. package/dist/plugin/billboardjs-plugin-stanford.min.js +10 -10
  15. package/dist/plugin/billboardjs-plugin-tableview.js +117 -27
  16. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  17. package/dist/plugin/billboardjs-plugin-textoverlap.js +116 -26
  18. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +117 -26
  22. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +120 -29
  24. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +14 -14
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +117 -27
  26. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -12
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +116 -26
  28. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -10
  29. package/dist/theme/dark.css +15 -1
  30. package/dist/theme/dark.min.css +2 -2
  31. package/dist/theme/datalab.css +15 -1
  32. package/dist/theme/datalab.min.css +2 -2
  33. package/dist/theme/graph.css +15 -1
  34. package/dist/theme/graph.min.css +2 -2
  35. package/dist/theme/insight.css +15 -1
  36. package/dist/theme/insight.min.css +2 -2
  37. package/dist/theme/modern.css +15 -1
  38. package/dist/theme/modern.min.css +2 -2
  39. package/dist-esm/billboard.js +1467 -536
  40. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -2
  42. package/dist-esm/plugin/billboardjs-plugin-stanford.js +5 -4
  43. package/dist-esm/plugin/billboardjs-plugin-tableview.js +94 -16
  44. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  45. package/package.json +38 -37
  46. package/src/Chart/Chart.ts +1 -1
  47. package/src/Chart/api/chart.ts +5 -5
  48. package/src/Chart/api/data.ts +2 -1
  49. package/src/Chart/api/export.ts +1 -1
  50. package/src/Chart/api/flow.ts +1 -1
  51. package/src/Chart/api/load.ts +3 -3
  52. package/src/Chart/api/subchart.ts +3 -3
  53. package/src/Chart/api/tooltip.ts +1 -1
  54. package/src/Chart/api/zoom.ts +1 -1
  55. package/src/ChartInternal/Axis/Axis.ts +1 -1
  56. package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
  57. package/src/ChartInternal/ChartInternal.ts +3 -2
  58. package/src/ChartInternal/data/IData.ts +3 -0
  59. package/src/ChartInternal/data/convert.helper.ts +1 -1
  60. package/src/ChartInternal/data/convert.ts +9 -8
  61. package/src/ChartInternal/data/data.ts +135 -17
  62. package/src/ChartInternal/data/load.ts +8 -8
  63. package/src/ChartInternal/interactions/drag.ts +53 -42
  64. package/src/ChartInternal/interactions/eventrect.ts +15 -5
  65. package/src/ChartInternal/interactions/flow.ts +1 -1
  66. package/src/ChartInternal/interactions/interaction.ts +1 -1
  67. package/src/ChartInternal/interactions/zoom.ts +24 -20
  68. package/src/ChartInternal/internals/color.ts +27 -10
  69. package/src/ChartInternal/internals/domain.ts +22 -5
  70. package/src/ChartInternal/internals/format.ts +4 -4
  71. package/src/ChartInternal/internals/grid.ts +11 -11
  72. package/src/ChartInternal/internals/legend.ts +80 -19
  73. package/src/ChartInternal/internals/scale.ts +6 -6
  74. package/src/ChartInternal/internals/selection.ts +1 -1
  75. package/src/ChartInternal/internals/style.ts +3 -3
  76. package/src/ChartInternal/internals/text.arc.ts +304 -0
  77. package/src/ChartInternal/internals/text.ts +44 -14
  78. package/src/ChartInternal/internals/text.util.ts +19 -0
  79. package/src/ChartInternal/internals/title.ts +3 -3
  80. package/src/ChartInternal/internals/tooltip.ts +23 -15
  81. package/src/ChartInternal/shape/arc.ts +174 -71
  82. package/src/ChartInternal/shape/area.ts +2 -2
  83. package/src/ChartInternal/shape/bar.ts +7 -6
  84. package/src/ChartInternal/shape/candlestick.ts +3 -3
  85. package/src/ChartInternal/shape/funnel.ts +18 -18
  86. package/src/ChartInternal/shape/line.ts +9 -10
  87. package/src/ChartInternal/shape/point.common.ts +24 -6
  88. package/src/ChartInternal/shape/radar.ts +4 -4
  89. package/src/ChartInternal/shape/shape.ts +24 -6
  90. package/src/ChartInternal/shape/treemap.ts +19 -5
  91. package/src/Plugin/stanford/Options.ts +2 -2
  92. package/src/Plugin/tableview/Options.ts +1 -1
  93. package/src/config/Options/axis/axis.ts +7 -7
  94. package/src/config/Options/axis/x.ts +6 -6
  95. package/src/config/Options/axis/y.ts +4 -4
  96. package/src/config/Options/axis/y2.ts +16 -3
  97. package/src/config/Options/common/color.ts +2 -2
  98. package/src/config/Options/common/legend.ts +6 -5
  99. package/src/config/Options/common/main.ts +23 -23
  100. package/src/config/Options/common/point.ts +4 -3
  101. package/src/config/Options/common/tooltip.ts +14 -13
  102. package/src/config/Options/data/axis.ts +31 -6
  103. package/src/config/Options/data/data.ts +44 -44
  104. package/src/config/Options/data/selection.ts +4 -4
  105. package/src/config/Options/interaction/interaction.ts +2 -1
  106. package/src/config/Options/interaction/subchart.ts +2 -2
  107. package/src/config/Options/interaction/zoom.ts +4 -4
  108. package/src/config/Options/shape/arc.ts +4 -4
  109. package/src/config/Options/shape/area.ts +1 -1
  110. package/src/config/Options/shape/bar.ts +4 -4
  111. package/src/config/Options/shape/bubble.ts +2 -2
  112. package/src/config/Options/shape/candlestick.ts +1 -1
  113. package/src/config/Options/shape/donut.ts +34 -3
  114. package/src/config/Options/shape/gauge.ts +36 -4
  115. package/src/config/Options/shape/line.ts +1 -1
  116. package/src/config/Options/shape/pie.ts +34 -3
  117. package/src/config/Options/shape/polar.ts +35 -4
  118. package/src/config/Options/shape/radar.ts +1 -1
  119. package/src/config/Options/shape/scatter.ts +1 -1
  120. package/src/config/Options/shape/treemap.ts +31 -5
  121. package/src/config/Store/State.ts +11 -1
  122. package/src/config/classes.ts +1 -0
  123. package/src/core.ts +1 -1
  124. package/src/module/Cache.ts +29 -4
  125. package/src/module/generator.ts +1 -1
  126. package/src/module/util.ts +308 -117
  127. package/src/module/worker.ts +3 -3
  128. package/src/scss/billboard.scss +15 -0
  129. package/src/scss/theme/dark.scss +15 -0
  130. package/src/scss/theme/datalab.scss +15 -0
  131. package/src/scss/theme/graph.scss +15 -0
  132. package/src/scss/theme/insight.scss +15 -0
  133. package/src/scss/theme/modern.scss +15 -0
  134. package/types/axis.d.ts +3 -3
  135. package/types/chart.d.ts +4 -4
  136. package/types/options.d.ts +22 -9
  137. package/types/options.shape.d.ts +59 -2
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.17.4
8
+ * @version 3.18.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -23653,7 +23653,7 @@ var map = Array.prototype.map, prefixes = ["y", "z", "a", "f", "p", "n", "\xB5",
23653
23653
  if (type === "n") comma = true, type = "g";
23654
23654
  else if (!formatTypes[type]) precision === void 0 && (precision = 12), trim = true, type = "g";
23655
23655
  if (zero || fill === "0" && align === "=") zero = true, fill = "0", align = "=";
23656
- var prefix = ((options == null ? void 0 : options.prefix) !== void 0 ? options.prefix : "") + (symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : ""), suffix = (symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "") + ((options == null ? void 0 : options.suffix) !== void 0 ? options.suffix : "");
23656
+ var prefix = (options && options.prefix !== void 0 ? options.prefix : "") + (symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : ""), suffix = (symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "") + (options && options.suffix !== void 0 ? options.suffix : "");
23657
23657
  var formatType = formatTypes[type], maybeSuffix = /[defgprs%]/.test(type);
23658
23658
  precision = precision === void 0 ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
23659
23659
  function format(value) {
@@ -24133,6 +24133,7 @@ const $COMMON = {
24133
24133
  const $ARC = {
24134
24134
  arc: "bb-arc",
24135
24135
  arcLabelLine: "bb-arc-label-line",
24136
+ arcLabelLineText: "bb-arc-label-line-text",
24136
24137
  arcRange: "bb-arc-range",
24137
24138
  arcs: "bb-arcs",
24138
24139
  chartArc: "bb-chart-arc",
@@ -26815,7 +26816,83 @@ var util_spreadValues = (a, b) => {
26815
26816
 
26816
26817
 
26817
26818
 
26818
-
26819
+ function _getRect(relativeViewport, node, forceEval = false) {
26820
+ const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
26821
+ if (forceEval) {
26822
+ return _(node);
26823
+ } else {
26824
+ const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +(node.getAttribute("width") || 0);
26825
+ return needEvaluate ? node.rect = _(node) : node.rect;
26826
+ }
26827
+ }
26828
+ function _forEachValidItem(items, callback) {
26829
+ for (let i = 0; i < items.length; i++) {
26830
+ const item = items[i];
26831
+ if (item) {
26832
+ callback(item, i);
26833
+ }
26834
+ }
26835
+ }
26836
+ const _sanitize = (() => {
26837
+ const DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
26838
+ const ENTITY_MAP = {
26839
+ quot: 34,
26840
+ amp: 38,
26841
+ apos: 39,
26842
+ lt: 60,
26843
+ gt: 62,
26844
+ nbsp: 160,
26845
+ iexcl: 161,
26846
+ cent: 162,
26847
+ pound: 163,
26848
+ curren: 164,
26849
+ yen: 165
26850
+ };
26851
+ const LT_CODE = 60;
26852
+ const GT_CODE = 62;
26853
+ const MAX_ITERATIONS = 10;
26854
+ const rx = {
26855
+ tags: new RegExp(
26856
+ `<(${DANGEROUS_TAGS})\\b[\\s\\S]*?>([\\s\\S]*?<\\/(${DANGEROUS_TAGS})\\s*>)?`,
26857
+ "gi"
26858
+ ),
26859
+ htmlEntity: /&#x([0-9a-f]+);?|&#([0-9]+);?|&([a-z]+);/gi,
26860
+ // eslint-disable-next-line no-control-regex
26861
+ controlChar: /[\x00-\x1F\x7F]/g,
26862
+ eventHandler: /\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)|on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)/gi,
26863
+ dangerousUri: /(href|src|action|xlink:href)\s*=\s*(['"`]?)([^'"`>\s]*)\2/gi,
26864
+ dangerousProtocol: /^(javascript|data|vbscript):/
26865
+ };
26866
+ return {
26867
+ ENTITY_MAP,
26868
+ LT_CODE,
26869
+ GT_CODE,
26870
+ MAX_ITERATIONS,
26871
+ rx,
26872
+ /**
26873
+ * Decode HTML entities to prevent bypass attacks
26874
+ * @param {string} str String with potential HTML entities
26875
+ * @returns {string} Decoded string
26876
+ */
26877
+ decodeEntities(str) {
26878
+ return str.replace(rx.htmlEntity, (match, hex, dec, named) => {
26879
+ const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : named ? ENTITY_MAP[named.toLowerCase()] || 0 : 0;
26880
+ return code && code !== LT_CODE && code !== GT_CODE ? String.fromCharCode(code) : match;
26881
+ });
26882
+ },
26883
+ /**
26884
+ * Remove dangerous URI protocols from attribute values
26885
+ * @param {string} str String to sanitize
26886
+ * @returns {string} Sanitized string
26887
+ */
26888
+ removeDangerousUris(str) {
26889
+ return str.replace(rx.dangerousUri, (match, attr, quote, value) => {
26890
+ const normalized = value.toLowerCase().replace(/\s/g, "");
26891
+ return rx.dangerousProtocol.test(normalized) ? `${attr}=${quote}${quote}` : match;
26892
+ });
26893
+ }
26894
+ };
26895
+ })();
26819
26896
  const isValue = (v) => v || v === 0;
26820
26897
  const isFunction = (v) => typeof v === "function";
26821
26898
  const isString = (v) => typeof v === "string";
@@ -26862,26 +26939,20 @@ function endall(transition, cb) {
26862
26939
  transition.call(end);
26863
26940
  }
26864
26941
  }
26865
- const DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
26866
- const sanitizeRx = {
26867
- tags: new RegExp(
26868
- `<(${DANGEROUS_TAGS})\\b[\\s\\S]*?>([\\s\\S]*?<\\/(${DANGEROUS_TAGS})\\s*>)?`,
26869
- "gi"
26870
- ),
26871
- // Handles: whitespace, slash, quotes before event handlers (e.g., <img/onerror=...>, <img src="x"onerror=...>)
26872
- eventHandlers: /[\s/"']+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,
26873
- // Handles: javascript/data/vbscript URIs with optional whitespace/newlines between protocol and colon
26874
- dangerousURIs: /(href|src|action|xlink:href)\s*=\s*["']?\s*(javascript|data|vbscript)\s*:/gi
26875
- };
26876
26942
  function sanitize(str) {
26877
26943
  if (!isString(str) || !str || str.indexOf("<") === -1) {
26878
26944
  return str;
26879
26945
  }
26880
26946
  let result = str;
26881
26947
  let prev;
26948
+ let iterations = 0;
26882
26949
  do {
26883
26950
  prev = result;
26884
- result = result.replace(sanitizeRx.tags, "").replace(sanitizeRx.eventHandlers, "").replace(sanitizeRx.dangerousURIs, '$1=""');
26951
+ result = _sanitize.decodeEntities(result).replace(_sanitize.rx.controlChar, "").replace(_sanitize.rx.tags, "").replace(_sanitize.rx.eventHandler, "");
26952
+ result = _sanitize.removeDangerousUris(result);
26953
+ if (++iterations >= _sanitize.MAX_ITERATIONS) {
26954
+ break;
26955
+ }
26885
26956
  } while (result !== prev);
26886
26957
  return result;
26887
26958
  }
@@ -26949,20 +27020,11 @@ function getBrushSelection(ctx) {
26949
27020
  }
26950
27021
  return selection;
26951
27022
  }
26952
- function getRect(relativeViewport, node, forceEval = false) {
26953
- const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
26954
- if (forceEval) {
26955
- return _(node);
26956
- } else {
26957
- const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +(node.getAttribute("width") || 0);
26958
- return needEvaluate ? node.rect = _(node) : node.rect;
26959
- }
26960
- }
26961
27023
  function getBoundingRect(node, forceEval = false) {
26962
- return getRect(true, node, forceEval);
27024
+ return _getRect(true, node, forceEval);
26963
27025
  }
26964
27026
  function getBBox(node, forceEval = false) {
26965
- return getRect(false, node, forceEval);
27027
+ return _getRect(false, node, forceEval);
26966
27028
  }
26967
27029
  function getRandom(asStr = true, min = 0, max = 1e4) {
26968
27030
  const crpt = win.crypto || win.msCrypto;
@@ -27274,6 +27336,35 @@ function parseShorthand(value) {
27274
27336
  const [a, b = a, c = a, d = b] = values;
27275
27337
  return { top: a, right: b, bottom: c, left: d };
27276
27338
  }
27339
+ function scheduleRAFUpdate(rafState, callback) {
27340
+ if (rafState.pendingRaf !== null) {
27341
+ win.cancelAnimationFrame(rafState.pendingRaf);
27342
+ rafState.pendingRaf = win.requestAnimationFrame(() => {
27343
+ rafState.pendingRaf = null;
27344
+ callback();
27345
+ });
27346
+ } else {
27347
+ rafState.pendingRaf = win.requestAnimationFrame(() => {
27348
+ rafState.pendingRaf = null;
27349
+ });
27350
+ callback();
27351
+ }
27352
+ }
27353
+ function toSet(items, keyFn = ((item) => item)) {
27354
+ const set = /* @__PURE__ */ new Set();
27355
+ _forEachValidItem(items, (item, i) => {
27356
+ set.add(keyFn(item, i));
27357
+ });
27358
+ return set;
27359
+ }
27360
+ function toMap(items, keyFn, valueFn = ((item) => item)) {
27361
+ const map = /* @__PURE__ */ new Map();
27362
+ _forEachValidItem(items, (item, i) => {
27363
+ map.set(keyFn(item, i), valueFn(item, i));
27364
+ });
27365
+ return map;
27366
+ }
27367
+
27277
27368
 
27278
27369
  ;// ./src/config/config.ts
27279
27370
 
@@ -27355,7 +27446,7 @@ class Plugin {
27355
27446
  });
27356
27447
  }
27357
27448
  }
27358
- __publicField(Plugin, "version", "3.17.4");
27449
+ __publicField(Plugin, "version", "3.18.0-next.2");
27359
27450
 
27360
27451
  ;// ./node_modules/d3-axis/src/identity.js
27361
27452
  /* harmony default export */ function d3_axis_src_identity(x) {
@@ -27684,7 +27775,7 @@ class Options {
27684
27775
  * Set the color of the color scale. This function receives a value between 0 and 1, and should return a color.
27685
27776
  * @name colors
27686
27777
  * @memberof plugin-stanford
27687
- * @type {Function}
27778
+ * @type {function}
27688
27779
  * @default undefined
27689
27780
  * @example
27690
27781
  * colors: d3.interpolateHslLong(
@@ -27732,7 +27823,7 @@ class Options {
27732
27823
  * @property {number} [scale.min=undefined] Minimum value of the color scale. Default: lowest value in epochs
27733
27824
  * @property {number} [scale.max=undefined] Maximum value of the color scale. Default: highest value in epochs
27734
27825
  * @property {number} [scale.width=20] Width of the color scale
27735
- * @property {string|Function} [scale.format=undefined] Format of the axis of the color scale. Use 'pow10' to format as powers of 10 or a custom function. Example: d3.format("d")
27826
+ * @property {string|function} [scale.format=undefined] Format of the axis of the color scale. Use 'pow10' to format as powers of 10 or a custom function. Example: d3.format("d")
27736
27827
  * @example
27737
27828
  * scale: {
27738
27829
  * max: 10000,