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
|
@@ -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
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -139,6 +139,308 @@ const [
|
|
|
139
139
|
] = getFallback(win);
|
|
140
140
|
|
|
141
141
|
|
|
142
|
+
;// ./src/module/sanitize.ts
|
|
143
|
+
const ALLOWED_TAGS = /* @__PURE__ */ new Set([
|
|
144
|
+
// HTML tags for tooltip/legend templates
|
|
145
|
+
"span",
|
|
146
|
+
"div",
|
|
147
|
+
"p",
|
|
148
|
+
"br",
|
|
149
|
+
"b",
|
|
150
|
+
"i",
|
|
151
|
+
"em",
|
|
152
|
+
"strong",
|
|
153
|
+
"u",
|
|
154
|
+
"s",
|
|
155
|
+
"sub",
|
|
156
|
+
"sup",
|
|
157
|
+
"ul",
|
|
158
|
+
"ol",
|
|
159
|
+
"li",
|
|
160
|
+
"dl",
|
|
161
|
+
"dt",
|
|
162
|
+
"dd",
|
|
163
|
+
"table",
|
|
164
|
+
"thead",
|
|
165
|
+
"tbody",
|
|
166
|
+
"tfoot",
|
|
167
|
+
"tr",
|
|
168
|
+
"th",
|
|
169
|
+
"td",
|
|
170
|
+
"caption",
|
|
171
|
+
"colgroup",
|
|
172
|
+
"col",
|
|
173
|
+
"hr",
|
|
174
|
+
"pre",
|
|
175
|
+
"code",
|
|
176
|
+
"blockquote",
|
|
177
|
+
"a",
|
|
178
|
+
"img",
|
|
179
|
+
// SVG tags for point patterns
|
|
180
|
+
"svg",
|
|
181
|
+
"g",
|
|
182
|
+
"path",
|
|
183
|
+
"circle",
|
|
184
|
+
"ellipse",
|
|
185
|
+
"rect",
|
|
186
|
+
"line",
|
|
187
|
+
"polyline",
|
|
188
|
+
"polygon",
|
|
189
|
+
"text",
|
|
190
|
+
"tspan",
|
|
191
|
+
"textPath",
|
|
192
|
+
"use",
|
|
193
|
+
"defs",
|
|
194
|
+
"symbol",
|
|
195
|
+
"clipPath",
|
|
196
|
+
"mask",
|
|
197
|
+
"linearGradient",
|
|
198
|
+
"radialGradient",
|
|
199
|
+
"stop",
|
|
200
|
+
"pattern",
|
|
201
|
+
"marker",
|
|
202
|
+
"title",
|
|
203
|
+
"desc"
|
|
204
|
+
]);
|
|
205
|
+
const ALLOWED_ATTRS = /* @__PURE__ */ new Set([
|
|
206
|
+
// Common attributes
|
|
207
|
+
"class",
|
|
208
|
+
"id",
|
|
209
|
+
"style",
|
|
210
|
+
"title",
|
|
211
|
+
"lang",
|
|
212
|
+
"dir",
|
|
213
|
+
// HTML specific
|
|
214
|
+
"href",
|
|
215
|
+
"src",
|
|
216
|
+
"alt",
|
|
217
|
+
"width",
|
|
218
|
+
"height",
|
|
219
|
+
"colspan",
|
|
220
|
+
"rowspan",
|
|
221
|
+
"scope",
|
|
222
|
+
"headers",
|
|
223
|
+
// SVG presentation attributes
|
|
224
|
+
"d",
|
|
225
|
+
"points",
|
|
226
|
+
"x",
|
|
227
|
+
"y",
|
|
228
|
+
"x1",
|
|
229
|
+
"x2",
|
|
230
|
+
"y1",
|
|
231
|
+
"y2",
|
|
232
|
+
"cx",
|
|
233
|
+
"cy",
|
|
234
|
+
"r",
|
|
235
|
+
"rx",
|
|
236
|
+
"ry",
|
|
237
|
+
"dx",
|
|
238
|
+
"dy",
|
|
239
|
+
"viewBox",
|
|
240
|
+
"preserveAspectRatio",
|
|
241
|
+
"transform",
|
|
242
|
+
"fill",
|
|
243
|
+
"fill-opacity",
|
|
244
|
+
"fill-rule",
|
|
245
|
+
"stroke",
|
|
246
|
+
"stroke-width",
|
|
247
|
+
"stroke-opacity",
|
|
248
|
+
"stroke-linecap",
|
|
249
|
+
"stroke-linejoin",
|
|
250
|
+
"stroke-dasharray",
|
|
251
|
+
"stroke-dashoffset",
|
|
252
|
+
"opacity",
|
|
253
|
+
"clip-path",
|
|
254
|
+
"clip-rule",
|
|
255
|
+
"mask",
|
|
256
|
+
"font-family",
|
|
257
|
+
"font-size",
|
|
258
|
+
"font-weight",
|
|
259
|
+
"font-style",
|
|
260
|
+
"text-anchor",
|
|
261
|
+
"dominant-baseline",
|
|
262
|
+
"offset",
|
|
263
|
+
"stop-color",
|
|
264
|
+
"stop-opacity",
|
|
265
|
+
"gradientUnits",
|
|
266
|
+
"gradientTransform",
|
|
267
|
+
"spreadMethod",
|
|
268
|
+
"patternUnits",
|
|
269
|
+
"patternTransform",
|
|
270
|
+
"marker-start",
|
|
271
|
+
"marker-mid",
|
|
272
|
+
"marker-end",
|
|
273
|
+
"markerWidth",
|
|
274
|
+
"markerHeight",
|
|
275
|
+
"refX",
|
|
276
|
+
"refY",
|
|
277
|
+
"xlink:href"
|
|
278
|
+
]);
|
|
279
|
+
const ALLOWED_URI_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
280
|
+
"http:",
|
|
281
|
+
"https:",
|
|
282
|
+
"mailto:"
|
|
283
|
+
]);
|
|
284
|
+
const URI_ATTRS = /* @__PURE__ */ new Set(["href", "src", "xlink:href"]);
|
|
285
|
+
const TAG_NAME_REGEX = /^<\/?([a-zA-Z][a-zA-Z0-9]*)/;
|
|
286
|
+
const CLOSING_TAG_REGEX = /^<\/([a-zA-Z][a-zA-Z0-9]*)\s*>$/;
|
|
287
|
+
const OPENING_TAG_REGEX = /^<([a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?)>$/;
|
|
288
|
+
const ATTR_REGEX = /([a-zA-Z][\w:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
|
|
289
|
+
const URL_IN_STYLE_REGEX = /url\s*\(\s*["']?([^"')]+)["']?\s*\)/gi;
|
|
290
|
+
const DANGEROUS_CSS_PATTERNS = [
|
|
291
|
+
"expression(",
|
|
292
|
+
"behavior:",
|
|
293
|
+
"binding:",
|
|
294
|
+
"@import",
|
|
295
|
+
"@charset",
|
|
296
|
+
"-moz-binding:"
|
|
297
|
+
];
|
|
298
|
+
function decodeHTMLEntities(str) {
|
|
299
|
+
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)));
|
|
300
|
+
}
|
|
301
|
+
function isSafeURI(uri) {
|
|
302
|
+
const decoded = decodeHTMLEntities(uri).trim();
|
|
303
|
+
const normalized = decoded.replace(/[\s\u0000-\u001f]/g, "").toLowerCase();
|
|
304
|
+
if (!normalized || normalized.startsWith("#")) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
if (normalized.startsWith("/") || normalized.startsWith("./") || normalized.startsWith("../") || !normalized.includes(":")) {
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
const colonIndex = normalized.indexOf(":");
|
|
311
|
+
if (colonIndex > 0) {
|
|
312
|
+
const protocol = normalized.substring(0, colonIndex + 1);
|
|
313
|
+
return ALLOWED_URI_PROTOCOLS.has(protocol);
|
|
314
|
+
}
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
function sanitizeStyleValue(style) {
|
|
318
|
+
const decoded = decodeHTMLEntities(style);
|
|
319
|
+
const cleaned = decoded.replace(/[\u0000-\u001f]/g, "");
|
|
320
|
+
URL_IN_STYLE_REGEX.lastIndex = 0;
|
|
321
|
+
let match;
|
|
322
|
+
while ((match = URL_IN_STYLE_REGEX.exec(cleaned)) !== null) {
|
|
323
|
+
if (!isSafeURI(match[1])) {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const normalizedLower = cleaned.toLowerCase().replace(/\s/g, "");
|
|
328
|
+
for (const pattern of DANGEROUS_CSS_PATTERNS) {
|
|
329
|
+
if (normalizedLower.includes(pattern)) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return style;
|
|
334
|
+
}
|
|
335
|
+
const ATTR_ENCODE_MAP = {
|
|
336
|
+
'"': """,
|
|
337
|
+
"'": "'",
|
|
338
|
+
"`": "`"
|
|
339
|
+
};
|
|
340
|
+
const ATTR_ENCODE_REGEX = /["'`]/g;
|
|
341
|
+
function encodeAttrValue(value) {
|
|
342
|
+
return value.replace(ATTR_ENCODE_REGEX, (char) => ATTR_ENCODE_MAP[char]);
|
|
343
|
+
}
|
|
344
|
+
function sanitizeAttrValue(name, value, wasUnquoted = false) {
|
|
345
|
+
if (URI_ATTRS.has(name)) {
|
|
346
|
+
if (!isSafeURI(value)) {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
return wasUnquoted ? encodeAttrValue(value) : value;
|
|
350
|
+
}
|
|
351
|
+
if (name === "style") {
|
|
352
|
+
const sanitizedStyle = sanitizeStyleValue(value);
|
|
353
|
+
if (sanitizedStyle === null) {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
return wasUnquoted ? encodeAttrValue(sanitizedStyle) : sanitizedStyle;
|
|
357
|
+
}
|
|
358
|
+
const decoded = decodeHTMLEntities(value).toLowerCase().replace(/\s/g, "");
|
|
359
|
+
if (/\bon\w+=/.test(decoded)) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
return wasUnquoted ? encodeAttrValue(value) : value;
|
|
363
|
+
}
|
|
364
|
+
function extractTagName(tag) {
|
|
365
|
+
const match = tag.match(TAG_NAME_REGEX);
|
|
366
|
+
return match ? match[1].toLowerCase() : null;
|
|
367
|
+
}
|
|
368
|
+
function isAllowedTag(tag) {
|
|
369
|
+
const tagName = extractTagName(tag);
|
|
370
|
+
return tagName !== null && ALLOWED_TAGS.has(tagName);
|
|
371
|
+
}
|
|
372
|
+
function sanitizeTag(fullTag) {
|
|
373
|
+
const closingMatch = fullTag.match(CLOSING_TAG_REGEX);
|
|
374
|
+
if (closingMatch) {
|
|
375
|
+
return `</${closingMatch[1].toLowerCase()}>`;
|
|
376
|
+
}
|
|
377
|
+
const openingMatch = fullTag.match(OPENING_TAG_REGEX);
|
|
378
|
+
if (!openingMatch) {
|
|
379
|
+
return "";
|
|
380
|
+
}
|
|
381
|
+
const [, tagName, attrString, selfClose] = openingMatch;
|
|
382
|
+
const lowerTagName = tagName.toLowerCase();
|
|
383
|
+
const allowedAttrs = [];
|
|
384
|
+
ATTR_REGEX.lastIndex = 0;
|
|
385
|
+
let attrMatch;
|
|
386
|
+
while ((attrMatch = ATTR_REGEX.exec(attrString)) !== null) {
|
|
387
|
+
const attrName = attrMatch[1].toLowerCase();
|
|
388
|
+
const doubleQuotedValue = attrMatch[2];
|
|
389
|
+
const singleQuotedValue = attrMatch[3];
|
|
390
|
+
const unquotedValue = attrMatch[4];
|
|
391
|
+
if (attrName.startsWith("on")) {
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
let attrValue;
|
|
395
|
+
let quoteChar;
|
|
396
|
+
if (doubleQuotedValue !== void 0) {
|
|
397
|
+
attrValue = doubleQuotedValue;
|
|
398
|
+
quoteChar = '"';
|
|
399
|
+
} else if (singleQuotedValue !== void 0) {
|
|
400
|
+
attrValue = singleQuotedValue;
|
|
401
|
+
quoteChar = "'";
|
|
402
|
+
} else if (unquotedValue !== void 0) {
|
|
403
|
+
attrValue = unquotedValue;
|
|
404
|
+
quoteChar = '"';
|
|
405
|
+
} else {
|
|
406
|
+
if (ALLOWED_ATTRS.has(attrName)) {
|
|
407
|
+
allowedAttrs.push(attrName);
|
|
408
|
+
}
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (ALLOWED_ATTRS.has(attrName)) {
|
|
412
|
+
const wasUnquoted = unquotedValue !== void 0;
|
|
413
|
+
const sanitizedValue = sanitizeAttrValue(attrName, attrValue, wasUnquoted);
|
|
414
|
+
if (sanitizedValue !== null) {
|
|
415
|
+
allowedAttrs.push(`${attrName}=${quoteChar}${sanitizedValue}${quoteChar}`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const attrsStr = allowedAttrs.length > 0 ? ` ${allowedAttrs.join(" ")}` : "";
|
|
420
|
+
const selfCloseStr = selfClose ? "/>" : ">";
|
|
421
|
+
return `<${lowerTagName}${attrsStr}${selfCloseStr}`;
|
|
422
|
+
}
|
|
423
|
+
function sanitize(str) {
|
|
424
|
+
if (typeof str !== "string" || !str || str.indexOf("<") === -1) {
|
|
425
|
+
return str;
|
|
426
|
+
}
|
|
427
|
+
return str.replace(
|
|
428
|
+
/<\/?[^>]*>|[^<>\s]+>/g,
|
|
429
|
+
(match) => {
|
|
430
|
+
if (match.startsWith("<!--")) {
|
|
431
|
+
return "";
|
|
432
|
+
}
|
|
433
|
+
if (!match.startsWith("<")) {
|
|
434
|
+
return match.slice(0, -1) + ">";
|
|
435
|
+
}
|
|
436
|
+
if (isAllowedTag(match)) {
|
|
437
|
+
return sanitizeTag(match);
|
|
438
|
+
}
|
|
439
|
+
return match.replace(/</g, "<");
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
142
444
|
;// ./src/module/util.ts
|
|
143
445
|
var __defProp = Object.defineProperty;
|
|
144
446
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -159,6 +461,7 @@ var __spreadValues = (a, b) => {
|
|
|
159
461
|
|
|
160
462
|
|
|
161
463
|
|
|
464
|
+
|
|
162
465
|
function _getRect(relativeViewport, node, forceEval = false) {
|
|
163
466
|
const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
|
|
164
467
|
if (forceEval) {
|
|
@@ -176,66 +479,6 @@ function _forEachValidItem(items, callback) {
|
|
|
176
479
|
}
|
|
177
480
|
}
|
|
178
481
|
}
|
|
179
|
-
const _sanitize = (() => {
|
|
180
|
-
const DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
|
|
181
|
-
const ENTITY_MAP = {
|
|
182
|
-
quot: 34,
|
|
183
|
-
amp: 38,
|
|
184
|
-
apos: 39,
|
|
185
|
-
lt: 60,
|
|
186
|
-
gt: 62,
|
|
187
|
-
nbsp: 160,
|
|
188
|
-
iexcl: 161,
|
|
189
|
-
cent: 162,
|
|
190
|
-
pound: 163,
|
|
191
|
-
curren: 164,
|
|
192
|
-
yen: 165
|
|
193
|
-
};
|
|
194
|
-
const LT_CODE = 60;
|
|
195
|
-
const GT_CODE = 62;
|
|
196
|
-
const MAX_ITERATIONS = 10;
|
|
197
|
-
const rx = {
|
|
198
|
-
tags: new RegExp(
|
|
199
|
-
`<(${DANGEROUS_TAGS})\\b[\\s\\S]*?>([\\s\\S]*?<\\/(${DANGEROUS_TAGS})\\s*>)?`,
|
|
200
|
-
"gi"
|
|
201
|
-
),
|
|
202
|
-
htmlEntity: /&#x([0-9a-f]+);?|&#([0-9]+);?|&([a-z]+);/gi,
|
|
203
|
-
// eslint-disable-next-line no-control-regex
|
|
204
|
-
controlChar: /[\x00-\x1F\x7F]/g,
|
|
205
|
-
eventHandler: /\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)|on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)/gi,
|
|
206
|
-
dangerousUri: /(href|src|action|xlink:href)\s*=\s*(['"`]?)([^'"`>\s]*)\2/gi,
|
|
207
|
-
dangerousProtocol: /^(javascript|data|vbscript):/
|
|
208
|
-
};
|
|
209
|
-
return {
|
|
210
|
-
ENTITY_MAP,
|
|
211
|
-
LT_CODE,
|
|
212
|
-
GT_CODE,
|
|
213
|
-
MAX_ITERATIONS,
|
|
214
|
-
rx,
|
|
215
|
-
/**
|
|
216
|
-
* Decode HTML entities to prevent bypass attacks
|
|
217
|
-
* @param {string} str String with potential HTML entities
|
|
218
|
-
* @returns {string} Decoded string
|
|
219
|
-
*/
|
|
220
|
-
decodeEntities(str) {
|
|
221
|
-
return str.replace(rx.htmlEntity, (match, hex, dec, named) => {
|
|
222
|
-
const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : named ? ENTITY_MAP[named.toLowerCase()] || 0 : 0;
|
|
223
|
-
return code && code !== LT_CODE && code !== GT_CODE ? String.fromCharCode(code) : match;
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
/**
|
|
227
|
-
* Remove dangerous URI protocols from attribute values
|
|
228
|
-
* @param {string} str String to sanitize
|
|
229
|
-
* @returns {string} Sanitized string
|
|
230
|
-
*/
|
|
231
|
-
removeDangerousUris(str) {
|
|
232
|
-
return str.replace(rx.dangerousUri, (match, attr, quote, value) => {
|
|
233
|
-
const normalized = value.toLowerCase().replace(/\s/g, "");
|
|
234
|
-
return rx.dangerousProtocol.test(normalized) ? `${attr}=${quote}${quote}` : match;
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
})();
|
|
239
482
|
const isValue = (v) => v || v === 0;
|
|
240
483
|
const isFunction = (v) => typeof v === "function";
|
|
241
484
|
const isString = (v) => typeof v === "string";
|
|
@@ -282,23 +525,6 @@ function endall(transition, cb) {
|
|
|
282
525
|
transition.call(end);
|
|
283
526
|
}
|
|
284
527
|
}
|
|
285
|
-
function sanitize(str) {
|
|
286
|
-
if (!isString(str) || !str || str.indexOf("<") === -1) {
|
|
287
|
-
return str;
|
|
288
|
-
}
|
|
289
|
-
let result = str;
|
|
290
|
-
let prev;
|
|
291
|
-
let iterations = 0;
|
|
292
|
-
do {
|
|
293
|
-
prev = result;
|
|
294
|
-
result = _sanitize.decodeEntities(result).replace(_sanitize.rx.controlChar, "").replace(_sanitize.rx.tags, "").replace(_sanitize.rx.eventHandler, "");
|
|
295
|
-
result = _sanitize.removeDangerousUris(result);
|
|
296
|
-
if (++iterations >= _sanitize.MAX_ITERATIONS) {
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
} while (result !== prev);
|
|
300
|
-
return result;
|
|
301
|
-
}
|
|
302
528
|
function setTextValue(node, text, dy = [-1, 1], toMiddle = false) {
|
|
303
529
|
if (!node || !isString(text)) {
|
|
304
530
|
return;
|
|
@@ -789,7 +1015,7 @@ class Plugin {
|
|
|
789
1015
|
});
|
|
790
1016
|
}
|
|
791
1017
|
}
|
|
792
|
-
__publicField(Plugin, "version", "3.18.0
|
|
1018
|
+
__publicField(Plugin, "version", "3.18.0");
|
|
793
1019
|
|
|
794
1020
|
;// ./src/Plugin/textoverlap/Options.ts
|
|
795
1021
|
class Options {
|
|
@@ -5,9 +5,9 @@
|
|
|
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
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
|
-
*/(function(l,
|
|
12
|
-
`)===-1)e.text(t);else{const r=[e.text(),t].map(
|
|
13
|
-
`),
|
|
11
|
+
*/(function(l,u){typeof exports=="object"&&typeof module=="object"?module.exports=u(require("d3-delaunay"),require("d3-polygon"),require("d3-brush"),require("d3-selection")):typeof define=="function"&&define.amd?define("bb",["d3-delaunay","d3-polygon","d3-brush","d3-selection"],u):typeof exports=="object"?exports.bb=u(require("d3-delaunay"),require("d3-polygon"),require("d3-brush"),require("d3-selection")):(l.bb=l.bb||{},l.bb.plugin=l.bb.plugin||{},l.bb.plugin.textoverlap=u(l.d3,l.d3,l.d3,l.d3))})(this,function(v,l,u,q){return(function(){"use strict";var F={263:(function(e){e.exports=l}),348:(function(e){e.exports=v}),747:(function(e){e.exports=q}),853:(function(e){e.exports=u})},O={};function a(e){var t=O[e];if(t!==void 0)return t.exports;var n=O[e]={exports:{}};return F[e](n,n.exports,a),n.exports}(function(){a.d=function(e,t){for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}})(),(function(){a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}})();var m={};a.d(m,{default:function(){return ce}});var B=a(348),P=a(263),me=a(853),be=a(747);function I(){return typeof globalThis=="object"&&globalThis!==null&&globalThis.Object===Object&&globalThis||typeof global=="object"&&global!==null&&global.Object===Object&&global||typeof self=="object"&&self!==null&&self.Object===Object&&self||Function("return this")()}function S(e){const t=typeof(e==null?void 0:e.requestAnimationFrame)=="function"&&typeof(e==null?void 0:e.cancelAnimationFrame)=="function",n=typeof(e==null?void 0:e.requestIdleCallback)=="function"&&typeof(e==null?void 0:e.cancelIdleCallback)=="function",o=i=>setTimeout(i,1),r=i=>clearTimeout(i);return[t?e.requestAnimationFrame:o,t?e.cancelAnimationFrame:r,n?e.requestIdleCallback:o,n?e.cancelIdleCallback:r]}const b=I(),V=b==null?void 0:b.document,[_e,ge,ye,xe]=S(b);var N=Object.defineProperty,E=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,A=(e,t,n)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))U.call(t,n)&&A(e,n,t[n]);if(E)for(var n of E(t))X.call(t,n)&&A(e,n,t[n]);return e};function j(e,t,n=!1){const o=r=>r[e?"getBoundingClientRect":"getBBox"]();return n?o(t):!("rect"in t)||"rect"in t&&t.hasAttribute("width")&&t.rect.width!==+(t.getAttribute("width")||0)?t.rect=o(t):t.rect}function T(e,t){for(let n=0;n<e.length;n++){const o=e[n];o&&t(o,n)}}const we=e=>e||e===0,Y=e=>typeof e=="function",d=e=>typeof e=="string",_=e=>typeof e=="number",L=e=>typeof e=="undefined",$=e=>typeof e!="undefined",ve=e=>typeof e=="boolean",Oe=e=>Math.ceil(e/10)*10,Pe=e=>Math.ceil(e)+.5,Ee=e=>e[1]-e[0],g=e=>typeof e=="object",z=e=>{for(const t in e)return!1;return!0},G=e=>L(e)||e===null||d(e)&&e.length===0||g(e)&&!(e instanceof Date)&&z(e)||_(e)&&isNaN(e),H=e=>!G(e),y=e=>Array.isArray(e),p=e=>e&&!(e!=null&&e.nodeType)&&g(e)&&!y(e);function Ae(e,t,n){return $(e[t])?e[t]:n}function Me(e,t){let n=!1;return Object.keys(e).forEach(o=>e[o]===t&&(n=!0)),n}function je(e,t,...n){const o=Y(e);return o&&e.call(t,...n),o}function Te(e,t){let n=0;const o=function(...r){!--n&&t.apply(this,...r)};"duration"in e?e.each(()=>++n).on("end",o):(++n,e.call(o))}function $e(e,t,n=[-1,1],o=!1){if(!(!e||!d(t)))if(t.indexOf(`
|
|
12
|
+
`)===-1)e.text(t);else{const r=[e.text(),t].map(i=>i.replace(/[\s\n]/g,""));if(r[0]!==r[1]){const i=t.split(`
|
|
13
|
+
`),s=o?i.length-1:1;e.html(""),i.forEach((c,f)=>{e.append("tspan").attr("x",0).attr("dy",`${f===0?n[0]*s:n[1]}em`).text(c)})}}}function K(e){const{x:t,y:n,width:o,height:r}=e.getBBox();return[{x:t,y:n+r},{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+r}]}function Re(e){const{width:t,height:n}=R(e),o=K(e),r=o[0].x,i=Math.min(o[0].y,o[1].y);return{x:r,y:i,width:t,height:n}}function Ce(e,t){var n;const o=e&&((n=e.touches||e.sourceEvent&&e.sourceEvent.touches)==null?void 0:n[0]);let r=[0,0];try{r=d3Pointer(o||e,t)}catch(i){}return r.map(i=>isNaN(i)?0:i)}function W(e){const{event:t,$el:n}=e,o=n.subchart.main||n.main;let r;return t&&t.type==="brush"?r=t.selection:o&&(r=o.select(".bb-brush").node())&&(r=d3BrushSelection(r)),r}function R(e,t=!1){return j(!0,e,t)}function De(e,t=!1){return j(!1,e,t)}function qe(e=!0,t=0,n=1e4){const o=window.crypto||window.msCrypto,r=o?t+o.getRandomValues(new Uint32Array(1))[0]%(n-t+1):Math.floor(Math.random()*(n-t)+t);return e?String(r):r}function C(e,t,n,o,r){if(n>o)return-1;const i=Math.floor((n+o)/2);let{x:s,w:c=0}=e[i];return r&&(s=e[i].y,c=e[i].h),t>=s&&t<=s+c?i:t<s?C(e,t,n,i-1,r):C(e,t,i+1,o,r)}function Fe(e){const t=W(e);return t?t[0]===t[1]:!0}function Be(...e){const t=n=>{if(p(n)&&n.constructor){const o=new n.constructor;for(const r in n)o[r]=t(n[r]);return o}return n};return e.map(n=>t(n)).reduce((n,o)=>M(M({},n),o))}function J(e={},t){y(t)&&t.forEach(n=>J(e,n));for(const n in t)/^\d+$/.test(n)||n in e||(e[n]=t[n]);return e}const Ie=e=>e.charAt(0).toUpperCase()+e.slice(1);function Se(e,t="-"){return e.split(t).map((n,o)=>o?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():n.toLowerCase()).join("")}const Q=e=>[].slice.call(e);function Ve(e,t,n){const{rootSelector:o="",sheet:r}=e,s=`${o} ${(c=>c.replace(/\s?(bb-)/g,".$1").replace(/\.+/g,"."))(t)} {${n.join(";")}}`;return r[r.insertRule?"insertRule":"addRule"](s,r.cssRules.length)}function Ne(e){let t=[];return e.forEach(n=>{var o;try{n.cssRules&&n.cssRules.length&&(t=t.concat(Q(n.cssRules)))}catch(r){(o=window.console)==null||o.warn(`Error while reading rules from ${n.href}: ${r.toString()}`)}}),t}function Ue(e){var t,n,o,r,i,s;return{x:((n=(t=window.pageXOffset)!=null?t:window.scrollX)!=null?n:0)+((o=e.scrollLeft)!=null?o:0),y:((i=(r=window.pageYOffset)!=null?r:window.scrollY)!=null?i:0)+((s=e.scrollTop)!=null?s:0)}}function Xe(e,t=0,n=0,o=!0){const r=new DOMPoint(t,n),i=e.getScreenCTM(),s=r.matrixTransform(o?i==null?void 0:i.inverse():i);if(o===!1){const c=R(e);s.x-=c.x,s.y-=c.y}return s}function Ye(e){const t=e?e.transform:null,n=t&&t.baseVal;return n&&n.numberOfItems?n.getItem(0).matrix:{a:0,b:0,c:0,d:0,e:0,f:0}}function Le(e){const t=e[0]instanceof Date,n=(t?e.map(Number):e).filter((o,r,i)=>i.indexOf(o)===r);return t?n.map(o=>new Date(o)):n}function ze(e){return e&&e.length?e.reduce((t,n)=>t.concat(n)):[]}function x(e,...t){if(!t.length||t.length===1&&!t[0])return e;const n=t.shift();return p(e)&&p(n)&&Object.keys(n).forEach(o=>{if(!/^(__proto__|constructor|prototype)$/i.test(o)){const r=n[o];p(r)?(!e[o]&&(e[o]={}),e[o]=x(e[o],r)):e[o]=y(r)?r.concat():r}}),x(e,...t)}function Z(e,t=!0){let n;return e[0]instanceof Date?n=t?(o,r)=>o-r:(o,r)=>r-o:t&&!e.every(isNaN)?n=(o,r)=>o-r:t||(n=(o,r)=>o>r&&-1||o<r&&1||o===r&&0),e.concat().sort(n)}function Ge(e,t){let n=t.filter(o=>H(o));return n.length?_(n[0])?n=Math[e](...n):n[0]instanceof Date&&(n=Z(n,e==="min")[0]):n=void 0,n}const He=(e,t,n=1)=>{const o=[],r=Math.max(0,Math.ceil((t-e)/n))|0;for(let i=e;i<r;i++)o.push(e+i*n);return o},Ke={mouse:(()=>{const e=()=>({bubbles:!1,cancelable:!1,screenX:0,screenY:0,clientX:0,clientY:0});try{return new MouseEvent("t"),(t,n,o=e())=>{t.dispatchEvent(new MouseEvent(n,o))}}catch(t){return(n,o,r=e())=>{const i=V.createEvent("MouseEvent");i.initMouseEvent(o,r.bubbles,r.cancelable,b,0,r.screenX,r.screenY,r.clientX,r.clientY,!1,!1,!1,!1,0,null),n.dispatchEvent(i)}}})(),touch:(e,t,n)=>{const o=new Touch(x({identifier:Date.now(),target:e,radiusX:2.5,radiusY:2.5,rotationAngle:10,force:.5},n));e.dispatchEvent(new TouchEvent(t,{cancelable:!0,bubbles:!0,shiftKey:!0,touches:[o],targetTouches:[],changedTouches:[o]}))}};function We(e,t){let n=e;for(const o in t)n=n.replace(new RegExp(`{=${o}}`,"g"),t[o]);return sanitize(n)}function Je(e){var t;let n;if(e instanceof Date)n=e;else if(d(e)){const{config:o,format:r}=this;n=(t=r.dataTime(o.data_xFormat)(e))!=null?t:new Date(e)}else _(e)&&!isNaN(e)&&(n=new Date(+e));return(!n||isNaN(+n))&&console&&console.error&&console.error(`Failed to parse x '${e}' to Date object`),n}function Qe(e){const t=e.attr("viewBox");return t?/(\d+(\.\d+)?){3}/.test(t):!1}function Ze(e,t,n=!1){const o=!!e.node;let r=!1;for(const[i,s]of Object.entries(t))if(r=o?e.style(i)===s:e.style[i]===s,n===!1&&r)break;return r}function ke(){var e,t;return((e=document)==null?void 0:e.hidden)===!1||((t=document)==null?void 0:t.visibilityState)==="visible"}function et(e,t){const{DocumentTouch:n,matchMedia:o,navigator:r}=window,i=o==null?void 0:o("(pointer:coarse)").matches;let s=!1;if(t)if(r&&"maxTouchPoints"in r)s=r.maxTouchPoints>0;else if("ontouchmove"in window||n&&document instanceof n)s=!0;else if(i)s=!0;else{const f=r.userAgent;s=/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(f)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(f)}return e&&!i&&(o==null?void 0:o("(pointer:fine)").matches)&&"mouse"||s&&"touch"||"mouse"}function k(e,t){t()===!1?requestAnimationFrame(()=>k(e,t)):e()}function tt(e){if(p(e)&&!d(e)){const s=e;return{top:s.top||0,right:s.right||0,bottom:s.bottom||0,left:s.left||0}}const t=(d(e)?e.trim().split(/\s+/):[e]).map(s=>+s||0),[n,o=n,r=n,i=o]=t;return{top:n,right:o,bottom:r,left:i}}function nt(e,t){e.pendingRaf!==null?(window.cancelAnimationFrame(e.pendingRaf),e.pendingRaf=window.requestAnimationFrame(()=>{e.pendingRaf=null,t()})):(e.pendingRaf=window.requestAnimationFrame(()=>{e.pendingRaf=null}),t())}function ot(e,t=(n=>n)){const n=new Set;return T(e,(o,r)=>{n.add(t(o,r))}),n}function rt(e,t,n=(o=>o)){const o=new Map;return T(e,(r,i)=>{o.set(t(r,i),n(r,i))}),o}function ee(e){const t=this.config;let n,o,r;const i=()=>{const s=o.shift();if(s&&n&&g(n)&&s in n)return n=n[s],i();if(!s)return n};Object.keys(t).forEach(s=>{n=e,o=s.split("_"),r=i(),$(r)&&(t[s]=r)}),this.api&&(this.state.orgConfig=e)}var te=Object.defineProperty,ne=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t,n)=>ne(e,typeof t!="symbol"?t+"":t,n);class D{constructor(t={}){w(this,"$$"),w(this,"options"),this.options=t}$beforeInit(){}$init(){}$afterInit(){}$redraw(){}$willDestroy(){Object.keys(this).forEach(t=>{this[t]=null,delete this[t]})}}w(D,"version","3.18.0");class oe{constructor(){return{selector:void 0,extent:1,area:0}}}var re=Object.defineProperty,ie=(e,t,n)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,se=(e,t,n)=>ie(e,typeof t!="symbol"?t+"":t,n);class ce extends D{constructor(t){return super(t),se(this,"config"),this.config=new oe,this}$init(){ee.call(this,this.options)}$redraw(){const{$$:{$el:t},config:{selector:n}}=this,o=n?t.main.selectAll(n):t.text;!o.empty()&&this.preventLabelOverlap(o)}generateVoronoi(t){const{$$:n}=this,{scale:o}=n,[r,i]=["x","y"].map(s=>o[s].domain());return[r[1],i[0]]=[i[0],r[1]],B.Delaunay.from(t).voronoi([...r,...i])}preventLabelOverlap(t){const{extent:n,area:o}=this.config,r=t.data().map(c=>[c.index,c.value]),i=this.generateVoronoi(r);let s=0;t.each(function(){const c=i.cellPolygon(s);if(c&&this){const[f,le]=r[s],[ae,ue]=(0,P.polygonCentroid)(c),fe=Math.abs((0,P.polygonArea)(c)),h=Math.round(Math.atan2(ue-le,ae-f)/Math.PI*2),de=n*(h===0?1:-1),pe=h===-1?-n:n+5,he=Math.abs(h)===1?"middle":h===0?"start":"end";this.style.display=fe<o?"none":"",this.setAttribute("text-anchor",he),this.setAttribute("dy",`0.${h===1?71:35}em`),this.setAttribute("transform",`translate(${de}, ${pe})`)}s++})}}return m=m.default,m})()});
|