billboard.js 3.18.0-next.2 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +319 -100
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +10 -9
- package/dist/billboard.pkgd.js +2059 -1625
- package/dist/billboard.pkgd.min.js +23 -22
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +305 -79
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-stanford.js +305 -79
- package/dist/plugin/billboardjs-plugin-stanford.min.js +11 -11
- package/dist/plugin/billboardjs-plugin-tableview.js +305 -79
- package/dist/plugin/billboardjs-plugin-tableview.min.js +6 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +305 -79
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -4
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1743 -1528
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -8
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2047 -1606
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2048 -1607
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +17 -17
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2049 -1608
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +13 -12
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2050 -1609
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -10
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/billboard.js +441 -135
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +416 -102
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +1 -1
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/internals/tooltip.ts +11 -9
- package/src/config/Options/axis/y2.ts +0 -13
- package/src/config/Options/common/legend.ts +1 -0
- package/src/config/Options/common/point.ts +1 -1
- package/src/config/Options/common/tooltip.ts +3 -1
- package/src/module/sanitize.ts +471 -0
- package/src/module/util.ts +1 -131
package/dist/billboard.css
CHANGED
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.18.0
|
|
8
|
+
* @version 3.18.0
|
|
9
9
|
*/
|
|
10
10
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
11
11
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -523,6 +523,7 @@ const $ZOOM = {
|
|
|
523
523
|
* @property {string|HTMLElement} [legend.contents.bindto=undefined] Set CSS selector or element reference to bind legend items.
|
|
524
524
|
* - **NOTE:** Should be used along with `legend.contents.template`.
|
|
525
525
|
* @property {string|function} [legend.contents.template="<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>"] Set item's template.<br>
|
|
526
|
+
* - **NOTE:** Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.
|
|
526
527
|
* - If set `string` value, within template the 'color' and 'title' can be replaced using template-like syntax string:
|
|
527
528
|
* - {=COLOR}: data color value
|
|
528
529
|
* - {=TITLE}: data title value
|
|
@@ -1185,6 +1186,7 @@ const $ZOOM = {
|
|
|
1185
1186
|
* If tooltip.grouped is true, data includes multiple data points.<br><br>
|
|
1186
1187
|
* Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
|
|
1187
1188
|
* - **Note:**
|
|
1189
|
+
* - Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.<br><br>
|
|
1188
1190
|
* - defaultTitleFormat:
|
|
1189
1191
|
* - if `axis.x.tick.format` option will be used if set.
|
|
1190
1192
|
* - otherwise, will return function based on tick format type(category, timeseries).
|
|
@@ -1194,7 +1196,8 @@ const $ZOOM = {
|
|
|
1194
1196
|
* - otherwise, will parse value and return as number.
|
|
1195
1197
|
* @property {string|HTMLElement} [tooltip.contents.bindto=undefined] Set CSS selector or element reference to bind tooltip.
|
|
1196
1198
|
* - **NOTE:** When is specified, will not be updating tooltip's position.
|
|
1197
|
-
* @property {string} [tooltip.contents.template=undefined] Set tooltip's template
|
|
1199
|
+
* @property {string} [tooltip.contents.template=undefined] Set tooltip's template.
|
|
1200
|
+
* - **NOTE:** Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.<br><br>
|
|
1198
1201
|
* Within template, below syntax will be replaced using template-like syntax string:
|
|
1199
1202
|
* - **{{ ... }}**: the doubly curly brackets indicate loop block for data rows.
|
|
1200
1203
|
* - **{=CLASS_TOOLTIP}**: default tooltip class name `bb-tooltip`.
|
|
@@ -2431,6 +2434,308 @@ const [
|
|
|
2431
2434
|
] = getFallback(win);
|
|
2432
2435
|
|
|
2433
2436
|
|
|
2437
|
+
;// ./src/module/sanitize.ts
|
|
2438
|
+
const ALLOWED_TAGS = /* @__PURE__ */ new Set([
|
|
2439
|
+
// HTML tags for tooltip/legend templates
|
|
2440
|
+
"span",
|
|
2441
|
+
"div",
|
|
2442
|
+
"p",
|
|
2443
|
+
"br",
|
|
2444
|
+
"b",
|
|
2445
|
+
"i",
|
|
2446
|
+
"em",
|
|
2447
|
+
"strong",
|
|
2448
|
+
"u",
|
|
2449
|
+
"s",
|
|
2450
|
+
"sub",
|
|
2451
|
+
"sup",
|
|
2452
|
+
"ul",
|
|
2453
|
+
"ol",
|
|
2454
|
+
"li",
|
|
2455
|
+
"dl",
|
|
2456
|
+
"dt",
|
|
2457
|
+
"dd",
|
|
2458
|
+
"table",
|
|
2459
|
+
"thead",
|
|
2460
|
+
"tbody",
|
|
2461
|
+
"tfoot",
|
|
2462
|
+
"tr",
|
|
2463
|
+
"th",
|
|
2464
|
+
"td",
|
|
2465
|
+
"caption",
|
|
2466
|
+
"colgroup",
|
|
2467
|
+
"col",
|
|
2468
|
+
"hr",
|
|
2469
|
+
"pre",
|
|
2470
|
+
"code",
|
|
2471
|
+
"blockquote",
|
|
2472
|
+
"a",
|
|
2473
|
+
"img",
|
|
2474
|
+
// SVG tags for point patterns
|
|
2475
|
+
"svg",
|
|
2476
|
+
"g",
|
|
2477
|
+
"path",
|
|
2478
|
+
"circle",
|
|
2479
|
+
"ellipse",
|
|
2480
|
+
"rect",
|
|
2481
|
+
"line",
|
|
2482
|
+
"polyline",
|
|
2483
|
+
"polygon",
|
|
2484
|
+
"text",
|
|
2485
|
+
"tspan",
|
|
2486
|
+
"textPath",
|
|
2487
|
+
"use",
|
|
2488
|
+
"defs",
|
|
2489
|
+
"symbol",
|
|
2490
|
+
"clipPath",
|
|
2491
|
+
"mask",
|
|
2492
|
+
"linearGradient",
|
|
2493
|
+
"radialGradient",
|
|
2494
|
+
"stop",
|
|
2495
|
+
"pattern",
|
|
2496
|
+
"marker",
|
|
2497
|
+
"title",
|
|
2498
|
+
"desc"
|
|
2499
|
+
]);
|
|
2500
|
+
const ALLOWED_ATTRS = /* @__PURE__ */ new Set([
|
|
2501
|
+
// Common attributes
|
|
2502
|
+
"class",
|
|
2503
|
+
"id",
|
|
2504
|
+
"style",
|
|
2505
|
+
"title",
|
|
2506
|
+
"lang",
|
|
2507
|
+
"dir",
|
|
2508
|
+
// HTML specific
|
|
2509
|
+
"href",
|
|
2510
|
+
"src",
|
|
2511
|
+
"alt",
|
|
2512
|
+
"width",
|
|
2513
|
+
"height",
|
|
2514
|
+
"colspan",
|
|
2515
|
+
"rowspan",
|
|
2516
|
+
"scope",
|
|
2517
|
+
"headers",
|
|
2518
|
+
// SVG presentation attributes
|
|
2519
|
+
"d",
|
|
2520
|
+
"points",
|
|
2521
|
+
"x",
|
|
2522
|
+
"y",
|
|
2523
|
+
"x1",
|
|
2524
|
+
"x2",
|
|
2525
|
+
"y1",
|
|
2526
|
+
"y2",
|
|
2527
|
+
"cx",
|
|
2528
|
+
"cy",
|
|
2529
|
+
"r",
|
|
2530
|
+
"rx",
|
|
2531
|
+
"ry",
|
|
2532
|
+
"dx",
|
|
2533
|
+
"dy",
|
|
2534
|
+
"viewBox",
|
|
2535
|
+
"preserveAspectRatio",
|
|
2536
|
+
"transform",
|
|
2537
|
+
"fill",
|
|
2538
|
+
"fill-opacity",
|
|
2539
|
+
"fill-rule",
|
|
2540
|
+
"stroke",
|
|
2541
|
+
"stroke-width",
|
|
2542
|
+
"stroke-opacity",
|
|
2543
|
+
"stroke-linecap",
|
|
2544
|
+
"stroke-linejoin",
|
|
2545
|
+
"stroke-dasharray",
|
|
2546
|
+
"stroke-dashoffset",
|
|
2547
|
+
"opacity",
|
|
2548
|
+
"clip-path",
|
|
2549
|
+
"clip-rule",
|
|
2550
|
+
"mask",
|
|
2551
|
+
"font-family",
|
|
2552
|
+
"font-size",
|
|
2553
|
+
"font-weight",
|
|
2554
|
+
"font-style",
|
|
2555
|
+
"text-anchor",
|
|
2556
|
+
"dominant-baseline",
|
|
2557
|
+
"offset",
|
|
2558
|
+
"stop-color",
|
|
2559
|
+
"stop-opacity",
|
|
2560
|
+
"gradientUnits",
|
|
2561
|
+
"gradientTransform",
|
|
2562
|
+
"spreadMethod",
|
|
2563
|
+
"patternUnits",
|
|
2564
|
+
"patternTransform",
|
|
2565
|
+
"marker-start",
|
|
2566
|
+
"marker-mid",
|
|
2567
|
+
"marker-end",
|
|
2568
|
+
"markerWidth",
|
|
2569
|
+
"markerHeight",
|
|
2570
|
+
"refX",
|
|
2571
|
+
"refY",
|
|
2572
|
+
"xlink:href"
|
|
2573
|
+
]);
|
|
2574
|
+
const ALLOWED_URI_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
2575
|
+
"http:",
|
|
2576
|
+
"https:",
|
|
2577
|
+
"mailto:"
|
|
2578
|
+
]);
|
|
2579
|
+
const URI_ATTRS = /* @__PURE__ */ new Set(["href", "src", "xlink:href"]);
|
|
2580
|
+
const TAG_NAME_REGEX = /^<\/?([a-zA-Z][a-zA-Z0-9]*)/;
|
|
2581
|
+
const CLOSING_TAG_REGEX = /^<\/([a-zA-Z][a-zA-Z0-9]*)\s*>$/;
|
|
2582
|
+
const OPENING_TAG_REGEX = /^<([a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?)>$/;
|
|
2583
|
+
const ATTR_REGEX = /([a-zA-Z][\w:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
|
|
2584
|
+
const URL_IN_STYLE_REGEX = /url\s*\(\s*["']?([^"')]+)["']?\s*\)/gi;
|
|
2585
|
+
const DANGEROUS_CSS_PATTERNS = [
|
|
2586
|
+
"expression(",
|
|
2587
|
+
"behavior:",
|
|
2588
|
+
"binding:",
|
|
2589
|
+
"@import",
|
|
2590
|
+
"@charset",
|
|
2591
|
+
"-moz-binding:"
|
|
2592
|
+
];
|
|
2593
|
+
function decodeHTMLEntities(str) {
|
|
2594
|
+
return str.replace(/:/gi, ":").replace(/&newline;/gi, "\n").replace(/&tab;/gi, " ").replace(/ /gi, " ").replace(/</gi, "<").replace(/>/gi, ">").replace(/&/gi, "&").replace(/"/gi, '"').replace(/'/gi, "'").replace(/&#(\d+);/gi, (_, code) => String.fromCharCode(parseInt(code, 10))).replace(/&#x([0-9a-f]+);/gi, (_, code) => String.fromCharCode(parseInt(code, 16)));
|
|
2595
|
+
}
|
|
2596
|
+
function isSafeURI(uri) {
|
|
2597
|
+
const decoded = decodeHTMLEntities(uri).trim();
|
|
2598
|
+
const normalized = decoded.replace(/[\s\u0000-\u001f]/g, "").toLowerCase();
|
|
2599
|
+
if (!normalized || normalized.startsWith("#")) {
|
|
2600
|
+
return true;
|
|
2601
|
+
}
|
|
2602
|
+
if (normalized.startsWith("/") || normalized.startsWith("./") || normalized.startsWith("../") || !normalized.includes(":")) {
|
|
2603
|
+
return true;
|
|
2604
|
+
}
|
|
2605
|
+
const colonIndex = normalized.indexOf(":");
|
|
2606
|
+
if (colonIndex > 0) {
|
|
2607
|
+
const protocol = normalized.substring(0, colonIndex + 1);
|
|
2608
|
+
return ALLOWED_URI_PROTOCOLS.has(protocol);
|
|
2609
|
+
}
|
|
2610
|
+
return false;
|
|
2611
|
+
}
|
|
2612
|
+
function sanitizeStyleValue(style) {
|
|
2613
|
+
const decoded = decodeHTMLEntities(style);
|
|
2614
|
+
const cleaned = decoded.replace(/[\u0000-\u001f]/g, "");
|
|
2615
|
+
URL_IN_STYLE_REGEX.lastIndex = 0;
|
|
2616
|
+
let match;
|
|
2617
|
+
while ((match = URL_IN_STYLE_REGEX.exec(cleaned)) !== null) {
|
|
2618
|
+
if (!isSafeURI(match[1])) {
|
|
2619
|
+
return null;
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
const normalizedLower = cleaned.toLowerCase().replace(/\s/g, "");
|
|
2623
|
+
for (const pattern of DANGEROUS_CSS_PATTERNS) {
|
|
2624
|
+
if (normalizedLower.includes(pattern)) {
|
|
2625
|
+
return null;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
return style;
|
|
2629
|
+
}
|
|
2630
|
+
const ATTR_ENCODE_MAP = {
|
|
2631
|
+
'"': """,
|
|
2632
|
+
"'": "'",
|
|
2633
|
+
"`": "`"
|
|
2634
|
+
};
|
|
2635
|
+
const ATTR_ENCODE_REGEX = /["'`]/g;
|
|
2636
|
+
function encodeAttrValue(value) {
|
|
2637
|
+
return value.replace(ATTR_ENCODE_REGEX, (char) => ATTR_ENCODE_MAP[char]);
|
|
2638
|
+
}
|
|
2639
|
+
function sanitizeAttrValue(name, value, wasUnquoted = false) {
|
|
2640
|
+
if (URI_ATTRS.has(name)) {
|
|
2641
|
+
if (!isSafeURI(value)) {
|
|
2642
|
+
return null;
|
|
2643
|
+
}
|
|
2644
|
+
return wasUnquoted ? encodeAttrValue(value) : value;
|
|
2645
|
+
}
|
|
2646
|
+
if (name === "style") {
|
|
2647
|
+
const sanitizedStyle = sanitizeStyleValue(value);
|
|
2648
|
+
if (sanitizedStyle === null) {
|
|
2649
|
+
return null;
|
|
2650
|
+
}
|
|
2651
|
+
return wasUnquoted ? encodeAttrValue(sanitizedStyle) : sanitizedStyle;
|
|
2652
|
+
}
|
|
2653
|
+
const decoded = decodeHTMLEntities(value).toLowerCase().replace(/\s/g, "");
|
|
2654
|
+
if (/\bon\w+=/.test(decoded)) {
|
|
2655
|
+
return null;
|
|
2656
|
+
}
|
|
2657
|
+
return wasUnquoted ? encodeAttrValue(value) : value;
|
|
2658
|
+
}
|
|
2659
|
+
function extractTagName(tag) {
|
|
2660
|
+
const match = tag.match(TAG_NAME_REGEX);
|
|
2661
|
+
return match ? match[1].toLowerCase() : null;
|
|
2662
|
+
}
|
|
2663
|
+
function isAllowedTag(tag) {
|
|
2664
|
+
const tagName = extractTagName(tag);
|
|
2665
|
+
return tagName !== null && ALLOWED_TAGS.has(tagName);
|
|
2666
|
+
}
|
|
2667
|
+
function sanitizeTag(fullTag) {
|
|
2668
|
+
const closingMatch = fullTag.match(CLOSING_TAG_REGEX);
|
|
2669
|
+
if (closingMatch) {
|
|
2670
|
+
return `</${closingMatch[1].toLowerCase()}>`;
|
|
2671
|
+
}
|
|
2672
|
+
const openingMatch = fullTag.match(OPENING_TAG_REGEX);
|
|
2673
|
+
if (!openingMatch) {
|
|
2674
|
+
return "";
|
|
2675
|
+
}
|
|
2676
|
+
const [, tagName, attrString, selfClose] = openingMatch;
|
|
2677
|
+
const lowerTagName = tagName.toLowerCase();
|
|
2678
|
+
const allowedAttrs = [];
|
|
2679
|
+
ATTR_REGEX.lastIndex = 0;
|
|
2680
|
+
let attrMatch;
|
|
2681
|
+
while ((attrMatch = ATTR_REGEX.exec(attrString)) !== null) {
|
|
2682
|
+
const attrName = attrMatch[1].toLowerCase();
|
|
2683
|
+
const doubleQuotedValue = attrMatch[2];
|
|
2684
|
+
const singleQuotedValue = attrMatch[3];
|
|
2685
|
+
const unquotedValue = attrMatch[4];
|
|
2686
|
+
if (attrName.startsWith("on")) {
|
|
2687
|
+
continue;
|
|
2688
|
+
}
|
|
2689
|
+
let attrValue;
|
|
2690
|
+
let quoteChar;
|
|
2691
|
+
if (doubleQuotedValue !== void 0) {
|
|
2692
|
+
attrValue = doubleQuotedValue;
|
|
2693
|
+
quoteChar = '"';
|
|
2694
|
+
} else if (singleQuotedValue !== void 0) {
|
|
2695
|
+
attrValue = singleQuotedValue;
|
|
2696
|
+
quoteChar = "'";
|
|
2697
|
+
} else if (unquotedValue !== void 0) {
|
|
2698
|
+
attrValue = unquotedValue;
|
|
2699
|
+
quoteChar = '"';
|
|
2700
|
+
} else {
|
|
2701
|
+
if (ALLOWED_ATTRS.has(attrName)) {
|
|
2702
|
+
allowedAttrs.push(attrName);
|
|
2703
|
+
}
|
|
2704
|
+
continue;
|
|
2705
|
+
}
|
|
2706
|
+
if (ALLOWED_ATTRS.has(attrName)) {
|
|
2707
|
+
const wasUnquoted = unquotedValue !== void 0;
|
|
2708
|
+
const sanitizedValue = sanitizeAttrValue(attrName, attrValue, wasUnquoted);
|
|
2709
|
+
if (sanitizedValue !== null) {
|
|
2710
|
+
allowedAttrs.push(`${attrName}=${quoteChar}${sanitizedValue}${quoteChar}`);
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
const attrsStr = allowedAttrs.length > 0 ? ` ${allowedAttrs.join(" ")}` : "";
|
|
2715
|
+
const selfCloseStr = selfClose ? "/>" : ">";
|
|
2716
|
+
return `<${lowerTagName}${attrsStr}${selfCloseStr}`;
|
|
2717
|
+
}
|
|
2718
|
+
function sanitize(str) {
|
|
2719
|
+
if (typeof str !== "string" || !str || str.indexOf("<") === -1) {
|
|
2720
|
+
return str;
|
|
2721
|
+
}
|
|
2722
|
+
return str.replace(
|
|
2723
|
+
/<\/?[^>]*>|[^<>\s]+>/g,
|
|
2724
|
+
(match) => {
|
|
2725
|
+
if (match.startsWith("<!--")) {
|
|
2726
|
+
return "";
|
|
2727
|
+
}
|
|
2728
|
+
if (!match.startsWith("<")) {
|
|
2729
|
+
return match.slice(0, -1) + ">";
|
|
2730
|
+
}
|
|
2731
|
+
if (isAllowedTag(match)) {
|
|
2732
|
+
return sanitizeTag(match);
|
|
2733
|
+
}
|
|
2734
|
+
return match.replace(/</g, "<");
|
|
2735
|
+
}
|
|
2736
|
+
);
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2434
2739
|
;// ./src/module/util.ts
|
|
2435
2740
|
var util_defProp = Object.defineProperty;
|
|
2436
2741
|
var util_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -2451,6 +2756,7 @@ var util_spreadValues = (a, b) => {
|
|
|
2451
2756
|
|
|
2452
2757
|
|
|
2453
2758
|
|
|
2759
|
+
|
|
2454
2760
|
function _getRect(relativeViewport, node, forceEval = false) {
|
|
2455
2761
|
const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
|
|
2456
2762
|
if (forceEval) {
|
|
@@ -2468,66 +2774,6 @@ function _forEachValidItem(items, callback) {
|
|
|
2468
2774
|
}
|
|
2469
2775
|
}
|
|
2470
2776
|
}
|
|
2471
|
-
const _sanitize = (() => {
|
|
2472
|
-
const DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
|
|
2473
|
-
const ENTITY_MAP = {
|
|
2474
|
-
quot: 34,
|
|
2475
|
-
amp: 38,
|
|
2476
|
-
apos: 39,
|
|
2477
|
-
lt: 60,
|
|
2478
|
-
gt: 62,
|
|
2479
|
-
nbsp: 160,
|
|
2480
|
-
iexcl: 161,
|
|
2481
|
-
cent: 162,
|
|
2482
|
-
pound: 163,
|
|
2483
|
-
curren: 164,
|
|
2484
|
-
yen: 165
|
|
2485
|
-
};
|
|
2486
|
-
const LT_CODE = 60;
|
|
2487
|
-
const GT_CODE = 62;
|
|
2488
|
-
const MAX_ITERATIONS = 10;
|
|
2489
|
-
const rx = {
|
|
2490
|
-
tags: new RegExp(
|
|
2491
|
-
`<(${DANGEROUS_TAGS})\\b[\\s\\S]*?>([\\s\\S]*?<\\/(${DANGEROUS_TAGS})\\s*>)?`,
|
|
2492
|
-
"gi"
|
|
2493
|
-
),
|
|
2494
|
-
htmlEntity: /&#x([0-9a-f]+);?|&#([0-9]+);?|&([a-z]+);/gi,
|
|
2495
|
-
// eslint-disable-next-line no-control-regex
|
|
2496
|
-
controlChar: /[\x00-\x1F\x7F]/g,
|
|
2497
|
-
eventHandler: /\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)|on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)/gi,
|
|
2498
|
-
dangerousUri: /(href|src|action|xlink:href)\s*=\s*(['"`]?)([^'"`>\s]*)\2/gi,
|
|
2499
|
-
dangerousProtocol: /^(javascript|data|vbscript):/
|
|
2500
|
-
};
|
|
2501
|
-
return {
|
|
2502
|
-
ENTITY_MAP,
|
|
2503
|
-
LT_CODE,
|
|
2504
|
-
GT_CODE,
|
|
2505
|
-
MAX_ITERATIONS,
|
|
2506
|
-
rx,
|
|
2507
|
-
/**
|
|
2508
|
-
* Decode HTML entities to prevent bypass attacks
|
|
2509
|
-
* @param {string} str String with potential HTML entities
|
|
2510
|
-
* @returns {string} Decoded string
|
|
2511
|
-
*/
|
|
2512
|
-
decodeEntities(str) {
|
|
2513
|
-
return str.replace(rx.htmlEntity, (match, hex, dec, named) => {
|
|
2514
|
-
const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : named ? ENTITY_MAP[named.toLowerCase()] || 0 : 0;
|
|
2515
|
-
return code && code !== LT_CODE && code !== GT_CODE ? String.fromCharCode(code) : match;
|
|
2516
|
-
});
|
|
2517
|
-
},
|
|
2518
|
-
/**
|
|
2519
|
-
* Remove dangerous URI protocols from attribute values
|
|
2520
|
-
* @param {string} str String to sanitize
|
|
2521
|
-
* @returns {string} Sanitized string
|
|
2522
|
-
*/
|
|
2523
|
-
removeDangerousUris(str) {
|
|
2524
|
-
return str.replace(rx.dangerousUri, (match, attr, quote, value) => {
|
|
2525
|
-
const normalized = value.toLowerCase().replace(/\s/g, "");
|
|
2526
|
-
return rx.dangerousProtocol.test(normalized) ? `${attr}=${quote}${quote}` : match;
|
|
2527
|
-
});
|
|
2528
|
-
}
|
|
2529
|
-
};
|
|
2530
|
-
})();
|
|
2531
2777
|
const isValue = (v) => v || v === 0;
|
|
2532
2778
|
const isFunction = (v) => typeof v === "function";
|
|
2533
2779
|
const isString = (v) => typeof v === "string";
|
|
@@ -2574,23 +2820,6 @@ function endall(transition, cb) {
|
|
|
2574
2820
|
transition.call(end);
|
|
2575
2821
|
}
|
|
2576
2822
|
}
|
|
2577
|
-
function sanitize(str) {
|
|
2578
|
-
if (!isString(str) || !str || str.indexOf("<") === -1) {
|
|
2579
|
-
return str;
|
|
2580
|
-
}
|
|
2581
|
-
let result = str;
|
|
2582
|
-
let prev;
|
|
2583
|
-
let iterations = 0;
|
|
2584
|
-
do {
|
|
2585
|
-
prev = result;
|
|
2586
|
-
result = _sanitize.decodeEntities(result).replace(_sanitize.rx.controlChar, "").replace(_sanitize.rx.tags, "").replace(_sanitize.rx.eventHandler, "");
|
|
2587
|
-
result = _sanitize.removeDangerousUris(result);
|
|
2588
|
-
if (++iterations >= _sanitize.MAX_ITERATIONS) {
|
|
2589
|
-
break;
|
|
2590
|
-
}
|
|
2591
|
-
} while (result !== prev);
|
|
2592
|
-
return result;
|
|
2593
|
-
}
|
|
2594
2823
|
function setTextValue(node, text, dy = [-1, 1], toMiddle = false) {
|
|
2595
2824
|
if (!node || !isString(text)) {
|
|
2596
2825
|
return;
|
|
@@ -8099,7 +8328,9 @@ function _getTextXPos(pos = "left", width) {
|
|
|
8099
8328
|
getTooltipHTML(...args) {
|
|
8100
8329
|
const $$ = this;
|
|
8101
8330
|
const { api, config } = $$;
|
|
8102
|
-
return
|
|
8331
|
+
return sanitize(
|
|
8332
|
+
isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api)(...args) : $$.getTooltipContent(...args)
|
|
8333
|
+
);
|
|
8103
8334
|
},
|
|
8104
8335
|
/**
|
|
8105
8336
|
* Returns the tooltip content(HTML string)
|
|
@@ -8118,8 +8349,8 @@ function _getTextXPos(pos = "left", width) {
|
|
|
8118
8349
|
const fn = config[`tooltip_format_${v}`];
|
|
8119
8350
|
return isFunction(fn) ? fn.bind(api) : fn;
|
|
8120
8351
|
});
|
|
8121
|
-
const titleFormat = (...arg) =>
|
|
8122
|
-
const nameFormat = (...arg) =>
|
|
8352
|
+
const titleFormat = (...arg) => (titleFn || defaultTitleFormat)(...arg);
|
|
8353
|
+
const nameFormat = (...arg) => (nameFn || ((name) => name))(...arg);
|
|
8123
8354
|
const valueFormat = (v, ratio, id, index) => {
|
|
8124
8355
|
let fn = valueFn;
|
|
8125
8356
|
if (!fn) {
|
|
@@ -8129,7 +8360,7 @@ function _getTextXPos(pos = "left", width) {
|
|
|
8129
8360
|
fn = defaultValueFormat;
|
|
8130
8361
|
}
|
|
8131
8362
|
}
|
|
8132
|
-
return
|
|
8363
|
+
return fn(v, ratio, id, index);
|
|
8133
8364
|
};
|
|
8134
8365
|
const order = config.tooltip_order;
|
|
8135
8366
|
const getRowValue = (row2) => $$.axis && $$.isBubbleZType(row2) ? $$.getBubbleZData(row2.value, "z") : $$.getBaseValue(row2);
|
|
@@ -8415,7 +8646,7 @@ function _getTextXPos(pos = "left", width) {
|
|
|
8415
8646
|
if (!datum || datum.current !== dataStr) {
|
|
8416
8647
|
const { index, x } = selectedData.concat().sort()[0];
|
|
8417
8648
|
callFn(config.tooltip_onshow, $$.api, selectedData);
|
|
8418
|
-
tooltip.html(
|
|
8649
|
+
tooltip.html($$.getTooltipHTML(
|
|
8419
8650
|
selectedData,
|
|
8420
8651
|
// data
|
|
8421
8652
|
$$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$),
|
|
@@ -8424,7 +8655,7 @@ function _getTextXPos(pos = "left", width) {
|
|
|
8424
8655
|
// defaultValueFormat
|
|
8425
8656
|
$$.color
|
|
8426
8657
|
// color
|
|
8427
|
-
))
|
|
8658
|
+
)).style("display", null).style("visibility", null).datum(datum = {
|
|
8428
8659
|
index,
|
|
8429
8660
|
x,
|
|
8430
8661
|
current: dataStr,
|
|
@@ -9576,7 +9807,7 @@ class ChartInternal {
|
|
|
9576
9807
|
if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
|
|
9577
9808
|
$el.defs = $el.svg.append("defs");
|
|
9578
9809
|
if (hasAxis) {
|
|
9579
|
-
["id", "idXAxis", "idYAxis", "
|
|
9810
|
+
["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
|
|
9580
9811
|
$$.appendClip($el.defs, state.clip[v]);
|
|
9581
9812
|
});
|
|
9582
9813
|
}
|
|
@@ -17347,18 +17578,6 @@ function _smoothLines(el, type) {
|
|
|
17347
17578
|
|
|
17348
17579
|
;// ./src/config/Options/axis/y2.ts
|
|
17349
17580
|
/* harmony default export */ var y2 = ({
|
|
17350
|
-
/**
|
|
17351
|
-
* Set clip-path attribute for y2 axis element
|
|
17352
|
-
* - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
|
|
17353
|
-
* @name axis․y2․clipPath
|
|
17354
|
-
* @memberof Options
|
|
17355
|
-
* @type {boolean}
|
|
17356
|
-
* @default true
|
|
17357
|
-
* @example
|
|
17358
|
-
* // don't set 'clip-path' attribute
|
|
17359
|
-
* clipPath: false
|
|
17360
|
-
*/
|
|
17361
|
-
axis_y2_clipPath: true,
|
|
17362
17581
|
/**
|
|
17363
17582
|
* Show or hide y2 axis.
|
|
17364
17583
|
* - **NOTE**:
|
|
@@ -21729,7 +21948,7 @@ ${percentValue}%`;
|
|
|
21729
21948
|
* - This is an `experimental` feature and can have some unexpected behaviors.
|
|
21730
21949
|
* - If chart has 'bubble' type, only circle can be used.
|
|
21731
21950
|
* - For IE, non circle point expansions are not supported due to lack of transform support.
|
|
21732
|
-
* -
|
|
21951
|
+
* - Only common SVG tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.
|
|
21733
21952
|
* - **Available Values:**
|
|
21734
21953
|
* - circle
|
|
21735
21954
|
* - rectangle
|
|
@@ -23411,7 +23630,7 @@ const bb = {
|
|
|
23411
23630
|
* bb.version; // "1.0.0"
|
|
23412
23631
|
* @memberof bb
|
|
23413
23632
|
*/
|
|
23414
|
-
version: "3.18.0
|
|
23633
|
+
version: "3.18.0",
|
|
23415
23634
|
/**
|
|
23416
23635
|
* Generate chart
|
|
23417
23636
|
* - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when:
|
package/dist/billboard.min.css
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.18.0
|
|
8
|
+
* @version 3.18.0
|
|
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-arc .bb-arc-label-line{fill:none;stroke-width:1px;pointer-events:none}.bb-chart-arc .bb-arc-label-line{stroke:#7f7f7f}.bb-chart-arc>text.bb-arc-label-line-text{fill:#000}.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}
|