billboard.js 3.17.2 → 3.17.3

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 (49) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +25 -15
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +12 -12
  5. package/dist/billboard.pkgd.js +2127 -1610
  6. package/dist/billboard.pkgd.min.js +21 -19
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +16 -4
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
  11. package/dist/plugin/billboardjs-plugin-stanford.js +16 -4
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
  13. package/dist/plugin/billboardjs-plugin-tableview.js +18 -8
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +16 -4
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -4
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2168 -1661
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -6
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2178 -1659
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -8
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2179 -1660
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -10
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2182 -1665
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +11 -9
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2181 -1662
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -8
  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 +27 -16
  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 +27 -6
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  43. package/package.json +3 -3
  44. package/src/ChartInternal/internals/color.ts +4 -6
  45. package/src/ChartInternal/internals/legend.ts +2 -1
  46. package/src/ChartInternal/internals/tooltip.ts +2 -2
  47. package/src/ChartInternal/shape/point.common.ts +4 -4
  48. package/src/Plugin/tableview/index.ts +2 -5
  49. package/src/module/util.ts +24 -6
@@ -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.2
8
+ * @version 3.17.3
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.17.2
8
+ * @version 3.17.3
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -2494,8 +2494,20 @@ function endall(transition, cb) {
2494
2494
  transition.call(end);
2495
2495
  }
2496
2496
  }
2497
+ const dangerousTags = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|svg|math";
2498
+ const sanitizeRx = {
2499
+ tags: new RegExp(
2500
+ `<(${dangerousTags})[\\s\\S]*?>[\\s\\S]*?<\\/\\1>|<(${dangerousTags})[^>]*\\/?>`,
2501
+ "gi"
2502
+ ),
2503
+ eventHandlers: /\s*on\w+\s*=\s*["'][^"']*["']|\s*on\w+\s*=\s*[^\s>]+/gi,
2504
+ dangerousUrls: /(href|src|action|formaction|xlink:href)\s*=\s*["']?\s*(javascript|data|vbscript):[^"'\s>]*/gi
2505
+ };
2497
2506
  function sanitize(str) {
2498
- return isString(str) ? str.replace(/<(script|img)?/ig, "&lt;").replace(/(script)?>/ig, "&gt;") : str;
2507
+ if (!isString(str) || !str || str.indexOf("<") === -1) {
2508
+ return str;
2509
+ }
2510
+ return str.replace(sanitizeRx.tags, "").replace(sanitizeRx.eventHandlers, "").replace(sanitizeRx.dangerousUrls, '$1=""');
2499
2511
  }
2500
2512
  function setTextValue(node, text, dy = [-1, 1], toMiddle = false) {
2501
2513
  if (!node || !isString(text)) {
@@ -2807,7 +2819,7 @@ function tplProcess(tpl, data) {
2807
2819
  for (const x in data) {
2808
2820
  res = res.replace(new RegExp(`{=${x}}`, "g"), data[x]);
2809
2821
  }
2810
- return res;
2822
+ return sanitize(res);
2811
2823
  }
2812
2824
  function parseDate(date) {
2813
2825
  var _a;
@@ -5217,12 +5229,10 @@ const schemeCategory10 = [
5217
5229
  }
5218
5230
  ids.forEach((v) => {
5219
5231
  const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${isString(color) ? $$.getTargetSelectorSuffix(color) : ""}`;
5220
- const colorValue = v === "" ? color : (color == null ? void 0 : color[v]) || "";
5232
+ const colorValue = sanitize(v === "" ? color : (color == null ? void 0 : color[v]) || "");
5221
5233
  if (defs.select(`#${id}`).empty()) {
5222
- defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id).html(
5223
- `<feFlood flood-color="${colorValue}" />
5224
- <feComposite in="SourceGraphic" />`
5225
- );
5234
+ defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id).html(`<feFlood flood-color="${colorValue}" />
5235
+ <feComposite in="SourceGraphic" />`);
5226
5236
  }
5227
5237
  });
5228
5238
  }
@@ -5822,7 +5832,7 @@ function getFormattedText(id, formatted = true) {
5822
5832
  const ids = [];
5823
5833
  let html = "";
5824
5834
  targets.forEach((v) => {
5825
- const content = isFunction(template) ? template.bind($$.api)(v, $$.color(v), $$.api.data(v)[0].values) : tplProcess(template, {
5835
+ const content = isFunction(template) ? sanitize(template.call($$.api, v, $$.color(v), $$.api.data(v)[0].values)) : tplProcess(template, {
5826
5836
  COLOR: $$.color(v),
5827
5837
  TITLE: v
5828
5838
  });
@@ -8111,7 +8121,7 @@ function getTextXPos(pos = "left", width) {
8111
8121
  if (!datum || datum.current !== dataStr) {
8112
8122
  const { index, x } = selectedData.concat().sort()[0];
8113
8123
  callFn(config.tooltip_onshow, $$.api, selectedData);
8114
- tooltip.html($$.getTooltipHTML(
8124
+ tooltip.html(sanitize($$.getTooltipHTML(
8115
8125
  selectedData,
8116
8126
  // data
8117
8127
  $$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$),
@@ -8120,7 +8130,7 @@ function getTextXPos(pos = "left", width) {
8120
8130
  // defaultValueFormat
8121
8131
  $$.color
8122
8132
  // color
8123
- )).style("display", null).style("visibility", null).datum(datum = {
8133
+ ))).style("display", null).style("visibility", null).datum(datum = {
8124
8134
  index,
8125
8135
  x,
8126
8136
  current: dataStr,
@@ -20472,7 +20482,7 @@ function insertPointInfoDefs(point, id) {
20472
20482
  target.setAttribute(name, from.getAttribute(name));
20473
20483
  }
20474
20484
  };
20475
- const doc = new DOMParser().parseFromString(point, "image/svg+xml");
20485
+ const doc = new DOMParser().parseFromString(sanitize(point), "image/svg+xml");
20476
20486
  const node = doc.documentElement;
20477
20487
  const clone = browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, node.nodeName.toLowerCase());
20478
20488
  clone.id = id;
@@ -20482,7 +20492,7 @@ function insertPointInfoDefs(point, id) {
20482
20492
  if ((_a = node.childNodes) == null ? void 0 : _a.length) {
20483
20493
  const parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(clone);
20484
20494
  if ("innerHTML" in clone) {
20485
- parent.html(node.innerHTML);
20495
+ parent.html(sanitize(node.innerHTML));
20486
20496
  } else {
20487
20497
  toArray(node.childNodes).forEach((v) => {
20488
20498
  copyAttr(v, parent.append(v.tagName).node());
@@ -20538,7 +20548,7 @@ function insertPointInfoDefs(point, id) {
20538
20548
  const pointId = $$.getDefsPointId(id);
20539
20549
  const defsPoint = $el.defs.select(`#${pointId}`);
20540
20550
  if (defsPoint.size() < 1) {
20541
- insertPointInfoDefs.bind($$)(point, pointId);
20551
+ insertPointInfoDefs.call($$, point, pointId);
20542
20552
  }
20543
20553
  if (method === "create") {
20544
20554
  return (_b = $$.custom) == null ? void 0 : _b.create.bind(context)(element, pointId, ...args);
@@ -22710,7 +22720,7 @@ const bb = {
22710
22720
  * bb.version; // "1.0.0"
22711
22721
  * @memberof bb
22712
22722
  */
22713
- version: "3.17.2",
22723
+ version: "3.17.3",
22714
22724
  /**
22715
22725
  * Generate chart
22716
22726
  * - **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.17.2
8
+ * @version 3.17.3
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;transform:translateZ(0)}.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}