chartjs-chart-treemap 5.0.0-next.2 → 5.0.0-next.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.
- package/dist/chartjs-chart-treemap.cjs +159 -121
- package/dist/chartjs-chart-treemap.esm.js +159 -121
- package/dist/chartjs-chart-treemap.min.js +2 -2
- package/dist/chartjs-chart-treemap.min.js.map +1 -1
- package/dist/controller.d.ts +15 -0
- package/dist/element.d.ts +2 -7
- package/dist/options.d.ts +7 -1
- package/dist/text.d.ts +2 -2
- package/dist/types.d.ts +9 -4
- package/dist/utils.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* chartjs-chart-treemap v5.0.0-next.
|
|
2
|
+
* chartjs-chart-treemap v5.0.0-next.3
|
|
3
3
|
* https://chartjs-chart-treemap.pages.dev/
|
|
4
4
|
* (c) 2026 Jukka Kurkela
|
|
5
5
|
* Released under the MIT license
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { DatasetController, Chart, registry, Element } from 'chart.js';
|
|
8
8
|
import { toTRBL, toTRBLCorners, isObject, defined, toFont, valueOrDefault, isArray, isNumber, clipArea, unclipArea, addRoundedRectPath } from 'chart.js/helpers';
|
|
9
9
|
|
|
10
|
-
var version = "5.0.0-next.
|
|
10
|
+
var version = "5.0.0-next.3";
|
|
11
11
|
|
|
12
12
|
function scaleRect(sq, xScale, yScale, sp) {
|
|
13
13
|
const sp2 = sp * 2;
|
|
@@ -46,6 +46,11 @@ function arrayNotEqual(a, b) {
|
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
const layoutDefaults = {
|
|
50
|
+
displayMode: 'containerBoxes',
|
|
51
|
+
rtl: false,
|
|
52
|
+
spacing: 0.5
|
|
53
|
+
};
|
|
49
54
|
function limit(value, min, max) {
|
|
50
55
|
return Math.max(Math.min(value, max), min);
|
|
51
56
|
}
|
|
@@ -234,7 +239,7 @@ class StatArray {
|
|
|
234
239
|
const isOlderPart = (act, req)=>req > act || act.length > req.length && act.startsWith(req);
|
|
235
240
|
const getGroupKey = (lvl)=>String(lvl);
|
|
236
241
|
const hasGroupValue = (value)=>value !== undefined && value !== null && value !== '';
|
|
237
|
-
function scanTreeObject(keys,
|
|
242
|
+
function scanTreeObject(keys, leafKey, obj, tree = [], lvl = 0, result = []) {
|
|
238
243
|
const objIndex = lvl - 1;
|
|
239
244
|
if (keys[0] in obj && lvl > 0) {
|
|
240
245
|
const record = tree.reduce((reduced, item, i)=>{
|
|
@@ -243,7 +248,7 @@ function scanTreeObject(keys, treeLeafKey, obj, tree = [], lvl = 0, result = [])
|
|
|
243
248
|
}
|
|
244
249
|
return reduced;
|
|
245
250
|
}, {});
|
|
246
|
-
record[
|
|
251
|
+
record[leafKey] = tree[objIndex];
|
|
247
252
|
keys.forEach((k)=>{
|
|
248
253
|
record[k] = obj[k];
|
|
249
254
|
});
|
|
@@ -253,15 +258,15 @@ function scanTreeObject(keys, treeLeafKey, obj, tree = [], lvl = 0, result = [])
|
|
|
253
258
|
const child = obj[childKey];
|
|
254
259
|
if (isObject(child)) {
|
|
255
260
|
tree.push(childKey);
|
|
256
|
-
scanTreeObject(keys,
|
|
261
|
+
scanTreeObject(keys, leafKey, child, tree, lvl + 1, result);
|
|
257
262
|
}
|
|
258
263
|
}
|
|
259
264
|
}
|
|
260
265
|
tree.splice(objIndex, 1);
|
|
261
266
|
return result;
|
|
262
267
|
}
|
|
263
|
-
function normalizeTreeToArray(keys,
|
|
264
|
-
const data = scanTreeObject(keys,
|
|
268
|
+
function normalizeTreeToArray(keys, leafKey, obj) {
|
|
269
|
+
const data = scanTreeObject(keys, leafKey, obj);
|
|
265
270
|
if (!data.length) {
|
|
266
271
|
return data;
|
|
267
272
|
}
|
|
@@ -305,7 +310,7 @@ function getPath(groups, value, defaultValue) {
|
|
|
305
310
|
}
|
|
306
311
|
return path.length ? path.join('.') : defaultValue;
|
|
307
312
|
}
|
|
308
|
-
function resolveGroup(value,
|
|
313
|
+
function resolveGroup(value, leafKey, allGroups, groupIndex) {
|
|
309
314
|
for(let idx = groupIndex; idx < allGroups.length; idx++){
|
|
310
315
|
const groupKey = getGroupKey(allGroups[idx]);
|
|
311
316
|
if (hasGroupValue(value[groupKey])) {
|
|
@@ -316,11 +321,11 @@ function resolveGroup(value, treeLeafKey, allGroups, groupIndex) {
|
|
|
316
321
|
};
|
|
317
322
|
}
|
|
318
323
|
}
|
|
319
|
-
if (hasGroupValue(value[
|
|
324
|
+
if (hasGroupValue(value[leafKey])) {
|
|
320
325
|
return {
|
|
321
|
-
group:
|
|
326
|
+
group: leafKey,
|
|
322
327
|
groupIndex,
|
|
323
|
-
value: value[
|
|
328
|
+
value: value[leafKey]
|
|
324
329
|
};
|
|
325
330
|
}
|
|
326
331
|
return undefined;
|
|
@@ -338,7 +343,7 @@ function ensureGroup(tmp, data, groupValue, addKeys) {
|
|
|
338
343
|
});
|
|
339
344
|
data[groupValue] = [];
|
|
340
345
|
}
|
|
341
|
-
function group(values, grp, keys,
|
|
346
|
+
function group(values, grp, keys, leafKey, mainGrp, mainValue, groups = [], allGroups = groups, groupIndex = groups.length - 1) {
|
|
342
347
|
const key = keys[0];
|
|
343
348
|
const addKeys = keys.slice(1);
|
|
344
349
|
const tmp = Object.create(null);
|
|
@@ -352,7 +357,7 @@ function group(values, grp, keys, treeLeafKey, mainGrp, mainValue, groups = [],
|
|
|
352
357
|
let n;
|
|
353
358
|
for(i = 0, n = values.length; i < n; ++i){
|
|
354
359
|
const v = values[i];
|
|
355
|
-
const itemGroup = resolveGroup(v,
|
|
360
|
+
const itemGroup = resolveGroup(v, leafKey, resolvedAllGroups, resolvedGroupIndex);
|
|
356
361
|
if (!itemGroup) {
|
|
357
362
|
return [];
|
|
358
363
|
}
|
|
@@ -524,20 +529,41 @@ function getCaptionHeight(displayMode, rect, font, padding) {
|
|
|
524
529
|
const captionHeight = font.lineHeight + padding * 2;
|
|
525
530
|
return rect.h < 2 * captionHeight ? rect.h / 3 : captionHeight;
|
|
526
531
|
}
|
|
527
|
-
function drawText(ctx, rect, options, item, element) {
|
|
528
|
-
const { captions, labels
|
|
532
|
+
function drawText(ctx, rect, options, item, element, layout) {
|
|
533
|
+
const { captions, labels } = options;
|
|
534
|
+
const { displayMode } = layout;
|
|
529
535
|
ctx.save();
|
|
530
536
|
ctx.beginPath();
|
|
531
537
|
ctx.rect(rect.x, rect.y, rect.w, rect.h);
|
|
532
538
|
ctx.clip();
|
|
533
539
|
const isLeaf = item && (!defined(item.l) || item.isLeaf);
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
540
|
+
let block;
|
|
541
|
+
if (isLeaf) {
|
|
542
|
+
if (labels.display) {
|
|
543
|
+
block = labelBlock(ctx, rect, options, item, element);
|
|
544
|
+
}
|
|
545
|
+
} else if (shouldDrawCaption(displayMode, rect, captions)) {
|
|
546
|
+
block = captionBlock(ctx, rect, options, item, element, layout);
|
|
547
|
+
}
|
|
548
|
+
if (block) {
|
|
549
|
+
drawTextBlock(ctx, rect, block);
|
|
538
550
|
}
|
|
539
551
|
ctx.restore();
|
|
540
552
|
}
|
|
553
|
+
function drawTextBlock(ctx, rect, block) {
|
|
554
|
+
const { align, colors, fonts, lines, padding, top } = block;
|
|
555
|
+
const x = calculateX(rect, align, padding);
|
|
556
|
+
ctx.textAlign = align;
|
|
557
|
+
ctx.textBaseline = 'middle';
|
|
558
|
+
let offset = 0;
|
|
559
|
+
lines.forEach((line, i)=>{
|
|
560
|
+
const font = fonts[Math.min(i, fonts.length - 1)];
|
|
561
|
+
ctx.font = font.string;
|
|
562
|
+
ctx.fillStyle = colors[Math.min(i, colors.length - 1)];
|
|
563
|
+
ctx.fillText(line, x, top + offset + font.lineHeight / 2);
|
|
564
|
+
offset += font.lineHeight;
|
|
565
|
+
});
|
|
566
|
+
}
|
|
541
567
|
function callbackContext(element, item) {
|
|
542
568
|
const context = element.$context || {
|
|
543
569
|
active: !!element.active,
|
|
@@ -554,16 +580,12 @@ function resolveOption(option, context) {
|
|
|
554
580
|
function resolveCaptionText(captions, element, item) {
|
|
555
581
|
return resolveOption(captions.formatter, callbackContext(element, item)) || item.g || '';
|
|
556
582
|
}
|
|
557
|
-
function
|
|
558
|
-
const {
|
|
583
|
+
function captionBlock(ctx, rect, options, item, element, layout) {
|
|
584
|
+
const { displayMode, rtl, spacing } = layout;
|
|
585
|
+
const { captions } = options;
|
|
559
586
|
const { color, hoverColor, font, hoverFont, padding, align } = captions;
|
|
560
|
-
const oColor = (rect.active ? hoverColor : color) || color;
|
|
561
|
-
const oAlign = align || (rtl ? 'right' : 'left');
|
|
562
587
|
const optFont = (rect.active ? hoverFont : font) || font;
|
|
563
588
|
const oFont = toFont(optFont);
|
|
564
|
-
const fonts = [
|
|
565
|
-
oFont
|
|
566
|
-
];
|
|
567
589
|
if (oFont.lineHeight > rect.h) {
|
|
568
590
|
return;
|
|
569
591
|
}
|
|
@@ -571,20 +593,62 @@ function drawCaption(ctx, rect, options, item, element) {
|
|
|
571
593
|
if (!text) {
|
|
572
594
|
return;
|
|
573
595
|
}
|
|
574
|
-
const
|
|
596
|
+
const fonts = [
|
|
597
|
+
oFont
|
|
598
|
+
];
|
|
599
|
+
if (measureLabelSize(ctx, [
|
|
575
600
|
text
|
|
576
|
-
], fonts)
|
|
577
|
-
if (captionSize.width + 2 * padding > rect.w) {
|
|
601
|
+
], fonts).width + 2 * padding > rect.w) {
|
|
578
602
|
text = sliceTextToFitWidth(ctx, text, rect.w - 2 * padding, fonts);
|
|
579
603
|
}
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
604
|
+
const top = displayMode === 'headerBoxes' ? rect.y + (rect.h - oFont.lineHeight) / 2 : rect.y + padding + spacing;
|
|
605
|
+
return {
|
|
606
|
+
align: align || (rtl ? 'right' : 'left'),
|
|
607
|
+
colors: [
|
|
608
|
+
(rect.active ? hoverColor : color) || color
|
|
609
|
+
],
|
|
610
|
+
fonts,
|
|
611
|
+
lines: [
|
|
612
|
+
text
|
|
613
|
+
],
|
|
614
|
+
padding,
|
|
615
|
+
top
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
function labelBlock(ctx, rect, options, item, element) {
|
|
619
|
+
const labels = options.labels;
|
|
620
|
+
const content = resolveOption(labels.formatter, callbackContext(element, item));
|
|
621
|
+
if (!content) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const lines = isArray(content) ? content : [
|
|
625
|
+
content
|
|
626
|
+
];
|
|
627
|
+
let fonts = getFontFromOptions(rect, labels);
|
|
628
|
+
let labelSize = measureLabelSize(ctx, lines, fonts);
|
|
629
|
+
const lblToDraw = labelToDraw(rect, labels, labelSize);
|
|
630
|
+
if (!lblToDraw) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
if (isNumber(lblToDraw)) {
|
|
634
|
+
labelSize = {
|
|
635
|
+
height: labelSize.height * lblToDraw,
|
|
636
|
+
width: labelSize.width * lblToDraw
|
|
637
|
+
};
|
|
638
|
+
fonts = toFonts(fonts, lblToDraw);
|
|
639
|
+
}
|
|
640
|
+
const { color, hoverColor, align, padding } = labels;
|
|
641
|
+
const optColor = (rect.active ? hoverColor : color) || color;
|
|
642
|
+
return {
|
|
643
|
+
align,
|
|
644
|
+
colors: isArray(optColor) ? optColor : [
|
|
645
|
+
optColor
|
|
646
|
+
],
|
|
647
|
+
fonts,
|
|
648
|
+
lines,
|
|
649
|
+
padding,
|
|
650
|
+
top: calculateBlockTop(rect, labels, labelSize)
|
|
651
|
+
};
|
|
588
652
|
}
|
|
589
653
|
function sliceTextToFitWidth(ctx, text, width, fonts) {
|
|
590
654
|
const ellipsis = '...';
|
|
@@ -649,7 +713,7 @@ function toFonts(fonts, fitRatio) {
|
|
|
649
713
|
});
|
|
650
714
|
});
|
|
651
715
|
}
|
|
652
|
-
function labelToDraw(
|
|
716
|
+
function labelToDraw(rect, options, labelSize) {
|
|
653
717
|
const { overflow, padding } = options;
|
|
654
718
|
const { width, height } = labelSize;
|
|
655
719
|
if (overflow === 'hidden') {
|
|
@@ -669,62 +733,15 @@ function getFontFromOptions(rect, labels) {
|
|
|
669
733
|
toFont(optFont)
|
|
670
734
|
];
|
|
671
735
|
}
|
|
672
|
-
function
|
|
673
|
-
const
|
|
674
|
-
const content = resolveOption(labels.formatter, callbackContext(element, item));
|
|
675
|
-
if (!content) {
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
const contents = isArray(content) ? content : [
|
|
679
|
-
content
|
|
680
|
-
];
|
|
681
|
-
let fonts = getFontFromOptions(rect, labels);
|
|
682
|
-
let labelSize = measureLabelSize(ctx, contents, fonts);
|
|
683
|
-
const lblToDraw = labelToDraw(ctx, rect, labels, labelSize);
|
|
684
|
-
if (!lblToDraw) {
|
|
685
|
-
return;
|
|
686
|
-
}
|
|
687
|
-
if (isNumber(lblToDraw)) {
|
|
688
|
-
labelSize = {
|
|
689
|
-
height: labelSize.height * lblToDraw,
|
|
690
|
-
width: labelSize.width * lblToDraw
|
|
691
|
-
};
|
|
692
|
-
fonts = toFonts(fonts, lblToDraw);
|
|
693
|
-
}
|
|
694
|
-
const { color, hoverColor, align } = labels;
|
|
695
|
-
const optColor = (rect.active ? hoverColor : color) || color;
|
|
696
|
-
const colors = isArray(optColor) ? optColor : [
|
|
697
|
-
optColor
|
|
698
|
-
];
|
|
699
|
-
const xyPoint = calculateXYLabel(rect, labels, labelSize);
|
|
700
|
-
ctx.textAlign = align;
|
|
701
|
-
ctx.textBaseline = 'middle';
|
|
702
|
-
let lhs = 0;
|
|
703
|
-
contents.forEach((l, i)=>{
|
|
704
|
-
const c = colors[Math.min(i, colors.length - 1)];
|
|
705
|
-
const f = fonts[Math.min(i, fonts.length - 1)];
|
|
706
|
-
const lh = f.lineHeight;
|
|
707
|
-
ctx.font = f.string;
|
|
708
|
-
ctx.fillStyle = c;
|
|
709
|
-
ctx.fillText(l, xyPoint.x, xyPoint.y + lh / 2 + lhs);
|
|
710
|
-
lhs += lh;
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
function calculateXYLabel(rect, options, labelSize) {
|
|
714
|
-
const { align, position, padding } = options;
|
|
715
|
-
const x = calculateX(rect, align, padding);
|
|
716
|
-
let y;
|
|
736
|
+
function calculateBlockTop(rect, options, labelSize) {
|
|
737
|
+
const { position, padding } = options;
|
|
717
738
|
if (position === 'top') {
|
|
718
|
-
|
|
719
|
-
} else if (position === 'bottom') {
|
|
720
|
-
y = rect.y + rect.h - padding - labelSize.height;
|
|
721
|
-
} else {
|
|
722
|
-
y = rect.y + (rect.h - labelSize.height) / 2 + padding;
|
|
739
|
+
return rect.y + padding;
|
|
723
740
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
741
|
+
if (position === 'bottom') {
|
|
742
|
+
return rect.y + rect.h - padding - labelSize.height;
|
|
743
|
+
}
|
|
744
|
+
return rect.y + (rect.h - labelSize.height) / 2 + padding;
|
|
728
745
|
}
|
|
729
746
|
function calculateX(rect, align, padding) {
|
|
730
747
|
if (align === 'left') {
|
|
@@ -735,24 +752,22 @@ function calculateX(rect, align, padding) {
|
|
|
735
752
|
return rect.x + rect.w / 2;
|
|
736
753
|
}
|
|
737
754
|
|
|
738
|
-
function buildData(tree,
|
|
739
|
-
const
|
|
755
|
+
function buildData(tree, keys, mainRect, layout) {
|
|
756
|
+
const { borderWidth, captions, displayMode, groups, leafKey } = layout;
|
|
740
757
|
if (isObject(tree)) {
|
|
741
|
-
tree = normalizeTreeToArray(keys,
|
|
758
|
+
tree = normalizeTreeToArray(keys, leafKey, tree);
|
|
742
759
|
}
|
|
743
|
-
const groups = dataset.groups || [];
|
|
744
760
|
const glen = groups.length;
|
|
745
|
-
const sp =
|
|
746
|
-
const captions = dataset.captions || {};
|
|
761
|
+
const sp = displayMode === 'headerBoxes' ? 0 : layout.spacing;
|
|
747
762
|
const font = toFont(captions.font);
|
|
748
763
|
const padding = valueOrDefault(captions.padding, 3);
|
|
749
764
|
function getSubRect(sq, rect) {
|
|
750
|
-
const bw =
|
|
765
|
+
const bw = displayMode === 'headerBoxes' ? {
|
|
751
766
|
b: 0,
|
|
752
767
|
l: 0,
|
|
753
768
|
r: 0,
|
|
754
769
|
t: 0
|
|
755
|
-
} : parseBorderWidth(
|
|
770
|
+
} : parseBorderWidth(borderWidth, sq.w / 2, sq.h / 2);
|
|
756
771
|
const subRect = {
|
|
757
772
|
...rect,
|
|
758
773
|
h: sq.h - 2 * sp - bw.t - bw.b,
|
|
@@ -760,8 +775,8 @@ function buildData(tree, dataset, keys, mainRect) {
|
|
|
760
775
|
x: sq.x + sp + bw.l,
|
|
761
776
|
y: sq.y + sp + bw.t
|
|
762
777
|
};
|
|
763
|
-
if (shouldDrawCaption(
|
|
764
|
-
const captionHeight = getCaptionHeight(
|
|
778
|
+
if (shouldDrawCaption(displayMode, subRect, captions)) {
|
|
779
|
+
const captionHeight = getCaptionHeight(displayMode, subRect, font, padding);
|
|
765
780
|
subRect.y += captionHeight;
|
|
766
781
|
subRect.h -= captionHeight;
|
|
767
782
|
}
|
|
@@ -769,7 +784,7 @@ function buildData(tree, dataset, keys, mainRect) {
|
|
|
769
784
|
}
|
|
770
785
|
function recur(treeElements, gidx, rect, parent, gs) {
|
|
771
786
|
const g = getGroupKey(groups[gidx]);
|
|
772
|
-
const gdata = group(treeElements, g, keys,
|
|
787
|
+
const gdata = group(treeElements, g, keys, leafKey, undefined, parent, groups.filter((_item, index)=>index <= gidx), groups, gidx);
|
|
773
788
|
const gsq = squarify(gdata, rect, keys, g, gidx, gs);
|
|
774
789
|
const ret = gsq.slice();
|
|
775
790
|
if (gidx < glen - 1) {
|
|
@@ -792,13 +807,13 @@ function buildData(tree, dataset, keys, mainRect) {
|
|
|
792
807
|
}
|
|
793
808
|
const result = glen ? recur(tree, 0, mainRect) : squarify(tree, mainRect, keys);
|
|
794
809
|
return result.map((d)=>{
|
|
795
|
-
if (
|
|
810
|
+
if (displayMode !== 'headerBoxes' || d.isLeaf) {
|
|
796
811
|
return d;
|
|
797
812
|
}
|
|
798
|
-
if (!shouldDrawCaption(
|
|
813
|
+
if (!shouldDrawCaption(displayMode, d, captions)) {
|
|
799
814
|
return undefined;
|
|
800
815
|
}
|
|
801
|
-
const captionHeight = getCaptionHeight(
|
|
816
|
+
const captionHeight = getCaptionHeight(displayMode, d, font, padding);
|
|
802
817
|
return {
|
|
803
818
|
...d,
|
|
804
819
|
h: captionHeight
|
|
@@ -857,13 +872,26 @@ class TreemapController extends DatasetController {
|
|
|
857
872
|
yScale.configure();
|
|
858
873
|
}
|
|
859
874
|
}
|
|
875
|
+
_layoutOptions() {
|
|
876
|
+
const dataset = this.getDataset();
|
|
877
|
+
const options = this.options;
|
|
878
|
+
return {
|
|
879
|
+
borderWidth: dataset.borderWidth,
|
|
880
|
+
captions: dataset.captions || {},
|
|
881
|
+
displayMode: options.displayMode,
|
|
882
|
+
groups: options.groups || [],
|
|
883
|
+
leafKey: options.leafKey,
|
|
884
|
+
spacing: valueOrDefault(dataset.spacing, 0)
|
|
885
|
+
};
|
|
886
|
+
}
|
|
860
887
|
update(mode) {
|
|
861
888
|
const dataset = this.getDataset();
|
|
862
889
|
const { data } = this.getMeta();
|
|
863
|
-
const
|
|
890
|
+
const options = this.options;
|
|
891
|
+
const groups = options.groups || [];
|
|
864
892
|
const keys = [
|
|
865
|
-
|
|
866
|
-
].concat(
|
|
893
|
+
options.key || ''
|
|
894
|
+
].concat(options.sumKeys || []);
|
|
867
895
|
dataset.tree = dataset.tree || dataset.data || [];
|
|
868
896
|
const tree = dataset.tree;
|
|
869
897
|
const treeVersion = dataset.treeVersion;
|
|
@@ -876,7 +904,7 @@ class TreemapController extends DatasetController {
|
|
|
876
904
|
this._prevTree = tree;
|
|
877
905
|
this._prevTreeVersion = treeVersion;
|
|
878
906
|
this._rectChanged = false;
|
|
879
|
-
dataset.data = buildData(tree,
|
|
907
|
+
dataset.data = buildData(tree, this._keys, this._rect, this._layoutOptions());
|
|
880
908
|
this._dataCheck();
|
|
881
909
|
this._resyncElements();
|
|
882
910
|
}
|
|
@@ -890,9 +918,10 @@ class TreemapController extends DatasetController {
|
|
|
890
918
|
const sharedOptions = this.getSharedOptions(firstOpts);
|
|
891
919
|
const includeOptions = this.includeOptions(mode, sharedOptions || {});
|
|
892
920
|
const { xScale, yScale } = this.getMeta();
|
|
921
|
+
const spacing = this.options.spacing;
|
|
893
922
|
for(let i = start; i < start + count; i++){
|
|
894
923
|
const options = sharedOptions || this.resolveDataElementOptions(i, mode);
|
|
895
|
-
const properties = scaleRect(dataset.data[i], xScale, yScale,
|
|
924
|
+
const properties = scaleRect(dataset.data[i], xScale, yScale, spacing);
|
|
896
925
|
if (reset) {
|
|
897
926
|
properties.width = 0;
|
|
898
927
|
properties.height = 0;
|
|
@@ -909,11 +938,17 @@ class TreemapController extends DatasetController {
|
|
|
909
938
|
const metadata = this.getMeta().data || [];
|
|
910
939
|
const dataset = this.getDataset();
|
|
911
940
|
const data = dataset.data;
|
|
941
|
+
const { displayMode, rtl, spacing } = this.options;
|
|
942
|
+
const layout = {
|
|
943
|
+
displayMode,
|
|
944
|
+
rtl,
|
|
945
|
+
spacing
|
|
946
|
+
};
|
|
912
947
|
clipArea(ctx, chartArea);
|
|
913
948
|
for(let i = 0, ilen = metadata.length; i < ilen; ++i){
|
|
914
949
|
const rect = metadata[i];
|
|
915
950
|
if (!rect.hidden) {
|
|
916
|
-
rect.draw(ctx, data[i]);
|
|
951
|
+
rect.draw(ctx, data[i], layout);
|
|
917
952
|
}
|
|
918
953
|
}
|
|
919
954
|
unclipArea(ctx);
|
|
@@ -940,7 +975,15 @@ TreemapController.defaults = {
|
|
|
940
975
|
type: 'number'
|
|
941
976
|
}
|
|
942
977
|
},
|
|
943
|
-
dataElementType: 'treemap'
|
|
978
|
+
dataElementType: 'treemap',
|
|
979
|
+
displayMode: layoutDefaults.displayMode,
|
|
980
|
+
groups: [],
|
|
981
|
+
key: '',
|
|
982
|
+
leafKey: '_leaf',
|
|
983
|
+
rtl: layoutDefaults.rtl,
|
|
984
|
+
spacing: layoutDefaults.spacing,
|
|
985
|
+
sumKeys: [],
|
|
986
|
+
unsorted: false
|
|
944
987
|
};
|
|
945
988
|
TreemapController.descriptors = {
|
|
946
989
|
_indexable: false,
|
|
@@ -1070,7 +1113,7 @@ function addNormalRectPath(ctx, rect) {
|
|
|
1070
1113
|
}
|
|
1071
1114
|
|
|
1072
1115
|
class TreemapElement extends Element {
|
|
1073
|
-
draw(ctx, data) {
|
|
1116
|
+
draw(ctx, data, layout = layoutDefaults) {
|
|
1074
1117
|
if (!data) {
|
|
1075
1118
|
return;
|
|
1076
1119
|
}
|
|
@@ -1090,7 +1133,7 @@ class TreemapElement extends Element {
|
|
|
1090
1133
|
addRectPath(ctx, inner);
|
|
1091
1134
|
ctx.fillStyle = options.backgroundColor;
|
|
1092
1135
|
ctx.fill();
|
|
1093
|
-
drawText(ctx, inner, options, data, this);
|
|
1136
|
+
drawText(ctx, inner, options, data, this, layout);
|
|
1094
1137
|
ctx.restore();
|
|
1095
1138
|
}
|
|
1096
1139
|
inRange(mouseX, mouseY, useFinalPosition) {
|
|
@@ -1141,8 +1184,6 @@ TreemapElement.defaults = {
|
|
|
1141
1184
|
},
|
|
1142
1185
|
padding: 3
|
|
1143
1186
|
},
|
|
1144
|
-
displayMode: 'containerBoxes',
|
|
1145
|
-
label: undefined,
|
|
1146
1187
|
labels: {
|
|
1147
1188
|
align: 'center',
|
|
1148
1189
|
color: 'black',
|
|
@@ -1164,10 +1205,7 @@ TreemapElement.defaults = {
|
|
|
1164
1205
|
overflow: 'cut',
|
|
1165
1206
|
padding: 3,
|
|
1166
1207
|
position: 'middle'
|
|
1167
|
-
}
|
|
1168
|
-
rtl: false,
|
|
1169
|
-
spacing: 0.5,
|
|
1170
|
-
unsorted: false
|
|
1208
|
+
}
|
|
1171
1209
|
};
|
|
1172
1210
|
TreemapElement.descriptors = {
|
|
1173
1211
|
_indexable: false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* chartjs-chart-treemap v5.0.0-next.
|
|
2
|
+
* chartjs-chart-treemap v5.0.0-next.3
|
|
3
3
|
* https://chartjs-chart-treemap.pages.dev/
|
|
4
4
|
* (c) 2026 Jukka Kurkela
|
|
5
5
|
* Released under the MIT license
|
|
6
6
|
*/
|
|
7
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["chartjs-chart-treemap"]={},t.Chart,t.Chart.helpers)}(this,function(t,e,n){"use strict";function r(t,e,n,r){const i=2*r,o=e.getPixelForValue(t.x),s=n.getPixelForValue(t.y),a=e.getPixelForValue(t.x+t.w)-o,h=n.getPixelForValue(t.y+t.h)-s;return{height:h-i,hidden:i>a||i>h,width:a-i,x:o+r,y:s+r}}function i(t,e){let n,r;if(!t||!e)return!0;if(t===e)return!1;if(t.length!==e.length)return!0;for(n=0,r=t.length;n<r;++n)if(t[n]!==e[n])return!0;return!1}function o(t,e,n){return Math.max(Math.min(t,n),e)}function s(t,e,r){const i=n.toTRBL(t);return{b:o(i.bottom,0,r),l:o(i.left,0,e),r:o(i.right,0,e),t:o(i.top,0,r)}}function a(t,e,n,r){const i=t._normalized,o=e*i/n,s=Math.sqrt(i*o),a=i/s;return{d1:s,d2:a,h:"_ix"===r?a:s,w:"_ix"===r?s:a}}const h=(t,e)=>t.rtl?t.x+t.iw-e:t.x+t._ix;function l(t,e,n,r){const i={_data:e._data,a:e._normalized,h:n.h,s:r,v:e.value,vs:e.values,w:n.w,x:h(t,n.w),y:t.y+t._iy};return e.group&&(i.g=e.group,i.l=e.level,i.gs=e.groupSum),i}class u{get area(){return this.w*this.h}get iw(){return this.w-this._ix}get ih(){return this.h-this._iy}get dir(){const t=this.ih;return t<=this.iw&&t>0?"y":"x"}get side(){return"x"===this.dir?this.iw:this.ih}map(t){const{dir:e,side:n}=this,r="x"===e?"_ix":"_iy",i=t.nsum,o=t.get(),s=n*n,h=i*i,u=[];let c=0,d=0;for(const e of o){const n=a(e,s,h,r);d+=n.d1,c=Math.max(c,n.d2),u.push(l(this,e,n,t.sum)),this[r]+=n.d1}return this["x"===e?"_iy":"_ix"]+=c,this[r]-=d,u}constructor(t){t=t||{h:1,w:1},this.rtl=!!t.rtl,this.unsorted=!!t.unsorted,this.x=t.x||t.left||0,this.y=t.y||t.top||0,this._ix=0,this._iy=0,this.w=t.w||t.width||t.right-t.left,this.h=t.h||t.height||t.bottom-t.top}}const c=Math.min,d=Math.max;function f(t,e){const n=+e[t.key],r=n*t.ratio;return e._normalized=r,{max:d(t.max,n),min:c(t.min,n),nmax:d(t.nmax,r),nmin:c(t.nmin,r),nsum:t.nsum+r,sum:t.sum+n}}function p(t,e,n){t._arr.push(e),function(t,e){Object.assign(t,e)}(t,n)}class g{get length(){return this._arr.length}reset(){this._arr=[],this._hist=[],this.sum=0,this.nsum=0,this.min=1/0,this.max=-1/0,this.nmin=1/0,this.nmax=-1/0}push(t){p(this,t,f(this,t))}pushIf(t,e,...n){const r=f(this,t);if(!e((i=this,{max:i.max,min:i.min,nmax:i.nmax,nmin:i.nmin,nsum:i.nsum,sum:i.sum}),r,n))return t;var i;p(this,t,r)}get(){return this._arr}constructor(t,e){this._arr=[],this._hist=[],this.sum=0,this.nsum=0,this.min=1/0,this.max=-1/0,this.nmin=1/0,this.nmax=-1/0,this.key=t,this.ratio=e,this.reset()}}const m=(t,e)=>e>t||t.length>e.length&&t.startsWith(e),x=t=>String(t),y=t=>null!=t&&""!==t;function b(t,e,r,i=[],o=0,s=[]){const a=o-1;if(t[0]in r&&o>0){const n=i.reduce((t,e,n)=>(n!==a&&(t[x(n)]=e),t),{});n[e]=i[a],t.forEach(t=>{n[t]=r[t]}),s.push(n)}else for(const a of Object.keys(r)){const h=r[a];n.isObject(h)&&(i.push(a),b(t,e,h,i,o+1,s))}return i.splice(a,1),s}function v(t,e,n){const r=b(t,e,n);if(!r.length)return r;const i=r.reduce((t,e)=>{const n=Object.keys(e).length-2;return Math.max(t,n)},0);return r.forEach(t=>{for(let e=0;e<i;e++){const n=x(e);t[n]||(t[n]="")}}),r}function w(t){const e=[...t],n=[];for(;e.length;){const t=e.pop();Array.isArray(t)?e.push(...t):n.push(t)}return n.reverse()}function _(t,e,n){const r=[];for(const n of t){const t=e[n];y(t)&&r.push(t)}return r.length?r.join("."):n}function M(t,e,n,r){for(let e=r;e<n.length;e++){const r=x(n[e]);if(y(t[r]))return{group:r,groupIndex:e,value:t[r]}}if(y(t[e]))return{group:e,groupIndex:r,value:t[e]}}function k(t,e,n,r){if(n in t)return;t[n]={value:0};const i=t[n];r.forEach(t=>{i[t]=0}),e[n]=[]}function C(t,e,n,r,i,o,s=[],a=s,h=s.length-1){const l=n[0],u=n.slice(1),c=Object.create(null),d=Object.create(null),f=[],p=a.length?a:[e],g=a.length?h:0;let m,x;for(m=0,x=t.length;m<x;++m){const e=t[m];if(i&&e[i]!==o)continue;const n=M(e,r,p,g);if(!n)return[];const s=n.value;k(c,d,s,u),c[s].value+=+e[l],c[s].label=s,c[s].group=n.group,c[s].groupIndex=n.groupIndex;const a=c[s];u.forEach(t=>{a[t]+=e[t]}),c[s].path=_(p.slice(0,n.groupIndex+1),e,s),d[s].push(e)}return Object.keys(c).forEach(t=>{const n={children:d[t]};n[l]=+c[t].value,u.forEach(e=>{n[e]=+c[t][e]}),n[e]=c[t].label,n.group=c[t].group,n.groupIndex=c[t].groupIndex,n.label=t,n.path=c[t].path,i&&(n[i]=o),f.push(n)}),f}function R(t,e){let r,i=t.length;if(!i)return e;const o=n.isObject(t[0]);for(e=o?e:"v",r=0,i=t.length;r<i;++r)o?t[r]._idx=r:t[r]={_idx:r,v:t[r]};return e}function j(t,e){e?t.sort((t,n)=>+n[e]-+t[e]):t.sort((t,e)=>+e-+t)}function E(t,e){let n,r,i;for(n=0,r=0,i=t.length;r<i;++r)n+=e?+t[r][e]:+t[r];return n}function O(t,e,n,r=!0){const i=n.split(".");let o=0;for(const s of e.split(".")){const a=i[o++];if(Number.parseInt(s,10)<Number.parseInt(a,10))break;if(m(a,s)){if(r)throw new Error(`${t} v${n} is not supported. v${e} or newer is required.`);return!1}}return!0}function T(t,e,n){if(0===t.sum)return!0;const[r]=n,i=t.nsum*t.nsum,o=e.nsum*e.nsum,s=r*r,a=Math.max(s*t.nmax/i,i/(s*t.nmin));return Math.max(s*e.nmax/o,o/(s*e.nmin))<=a}function L(t,e,n=[],r,i,o){t=t||[];const s=[],a=new u(e),h=new g("value",a.area/E(t,n[0]));let l=a.side;const c=t.length;let d,f;if(!c)return s;const p=t.slice(),m=R(p,n[0]);e?.unsorted||j(p,m);const x=t=>m?+p[t][m]:+p[t],y=t=>r&&p[t][r];for(d=0;d<c;++d){if(f={_data:t[p[d]._idx],group:void 0,groupSum:o,level:void 0,value:x(d)},r){f.level=p[d].groupIndex??i,f.group=y(d);const t=p[d];f.values=n.reduce((e,n)=>(e[n]=+t[n],e),{})}f=h.pushIf(f,T,l),f&&(s.push(a.map(h)),l=a.side,h.reset(),h.push(f))}return h.length&&s.push(a.map(h)),w(s)}const P=new Map;function I(t,e,r){if(!r||!1===r.display)return!1;if("headerBoxes"===t)return!0;const{w:i,h:o}=e,s=n.toFont(r.font||{}).lineHeight,a=Math.max(Math.min(2*n.valueOrDefault(r.padding,3),Math.min(i,o)),0);return i-a>s&&o-a>s}function S(t,e,n,r){if("headerBoxes"!==t)return n.lineHeight+2*r;const i=n.lineHeight+2*r;return e.h<2*i?e.h/3:i}function A(t,e,r,i,o){const{captions:s,labels:a,displayMode:h}=r;t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip();const l=i&&(!n.defined(i.l)||i.isLeaf);l&&a.display?function(t,e,r,i,o){const s=r.labels,a=F(s.formatter,B(o,i));if(!a)return;const h=n.isArray(a)?a:[a];let l=function(t,e){const{font:r,hoverFont:i}=e,o=(t.active?i:r)||r;return Array.isArray(o)?o.map(t=>n.toFont(t)):[n.toFont(o)]}(e,s),u=D(t,h,l);const c=function(t,e,n,r){const{overflow:i,padding:o}=n,{width:s,height:a}=r;if("hidden"===i)return!(s+2*o>e.w||a+2*o>e.h);if("fit"===i){const t=Math.min(e.w/(s+2*o),e.h/(a+2*o));if(t<1)return t}return!0}(0,e,s,u);if(!c)return;n.isNumber(c)&&(u={height:u.height*c,width:u.width*c},l=function(t,e){return t.map(t=>{const{lineHeight:r,...i}=t;return n.toFont({...i,size:Math.floor(t.size*e)})})}(l,c));const{color:d,hoverColor:f,align:p}=s,g=(e.active?f:d)||d,m=n.isArray(g)?g:[g],x=function(t,e,n){const{align:r,position:i,padding:o}=e,s=z(t,r,o);let a;a="top"===i?t.y+o:"bottom"===i?t.y+t.h-o-n.height:t.y+(t.h-n.height)/2+o;return{x:s,y:a}}(e,s,u);t.textAlign=p,t.textBaseline="middle";let y=0;h.forEach((e,n)=>{const r=m[Math.min(n,m.length-1)],i=l[Math.min(n,l.length-1)],o=i.lineHeight;t.font=i.string,t.fillStyle=r,t.fillText(e,x.x,x.y+o/2+y),y+=o})}(t,e,r,i,o):!l&&I(h,e,s)&&function(t,e,r,i,o){const{captions:s,spacing:a,rtl:h,displayMode:l}=r,{color:u,hoverColor:c,font:d,hoverFont:f,padding:p,align:g}=s,m=(e.active?c:u)||u,x=g||(h?"right":"left"),y=(e.active?f:d)||d,b=n.toFont(y),v=[b];if(b.lineHeight>e.h)return;let w=function(t,e,n){return F(t.formatter,B(e,n))||n.g||""}(s,o,i);if(!w)return;const _=D(t,[w],v);_.width+2*p>e.w&&(w=function(t,e,n,r){const i="...",o=D(t,[i],r).width;if(o>=n)return"";let s,a=1,h=e.length;for(;a<=h;){const i=Math.floor((a+h)/2);s=D(t,[e.slice(0,i)],r).width,s+o>n?h=i-1:a=i+1}const l=e.slice(0,Math.max(0,a-1));return l?l+i:""}(t,w,e.w-2*p,v));const M=b.lineHeight/2,k=z(e,x,p);t.fillStyle=m,t.font=b.string,t.textAlign=x,t.textBaseline="middle";const C="headerBoxes"===l?e.y+e.h/2:e.y+p+a+M;t.fillText(w,k,C)}(t,e,r,i,o),t.restore()}function B(t,e){const n=t.$context||{active:!!t.active,raw:e,type:"data"};return n.active=!!t.active,n.raw=e,n}function F(t,e){return"function"==typeof t?t(e):t}function D(t,e,n){const r=n.reduce((t,e)=>t+=e.string,""),i=e.join()+r+(t._measureText?"-spriting":"");let o=P.get(i);if(!o){t.save();const r=e.length;let s=0,a=0;for(let i=0;i<r;i++){const r=n[Math.min(i,n.length-1)];t.font=r.string;const o=e[i];s=Math.max(s,t.measureText(o).width),a+=r.lineHeight}t.restore(),o={height:a,width:s},P.set(i,o)}return o}function z(t,e,n){return"left"===e?t.x+n:"right"===e?t.x+t.w-n:t.x+t.w/2}function H(t,e,r,i){const o=e.treeLeafKey||"_leaf";n.isObject(t)&&(t=v(r,o,t));const a=e.groups||[],h=a.length,l="headerBoxes"===e.displayMode?0:n.valueOrDefault(e.spacing,0),u=e.captions||{},c=n.toFont(u.font),d=n.valueOrDefault(u.padding,3);const f=h?function t(n,i,f,p,g){const m=x(a[i]),y=C(n,m,r,o,void 0,p,a.filter((t,e)=>e<=i),a,i),b=L(y,f,r,m,i,g),v=b.slice();return i<h-1?b.forEach(n=>{const r=function(t,n){const r="headerBoxes"===e.displayMode?{b:0,l:0,r:0,t:0}:s(e.borderWidth,t.w/2,t.h/2),i={...n,h:t.h-2*l-r.t-r.b,w:t.w-2*l-r.l-r.r,x:t.x+l+r.l,y:t.y+l+r.t};if(I(e.displayMode,i,u)){const t=S(e.displayMode,i,c,d);i.y+=t,i.h-=t}return i}(n,f),i=[],o=n._data.groupIndex+1;o<h&&i.push(...t(n._data.children,o,r,n.g,n.s)),v.push(...i),n.isLeaf=!i.length}):b.forEach(t=>{t.isLeaf=!0}),v}(t,0,i):L(t,i,r);return f.map(t=>{if("headerBoxes"!==e.displayMode||t.isLeaf)return t;if(!I(e.displayMode,t,u))return;const n=S(e.displayMode,t,c,d);return{...t,h:n}}).filter(Boolean)}function V(){const t=e.registry.plugins.get("tooltip");t&&!t.positioners.treemap&&(t.positioners.treemap=t=>{if(!t.length)return!1;return t.at(-1).element.tooltipPosition()})}class $ extends e.DatasetController{initialize(){V(),this.enableOptionSharing=!0,super.initialize()}getMinMax(t){return{max:"x"===t.axis?t.right-t.left:t.bottom-t.top,min:0}}configure(){super.configure();const{xScale:t,yScale:e}=this.getMeta();if(!t||!e)return;const n=t.right-t.left,r=e.bottom-e.top,i={h:r,rtl:!!this.options.rtl,unsorted:!!this.options.unsorted,w:n,x:0,y:0};var o,s;o=this._rect,s=i,o&&s&&o.x===s.x&&o.y===s.y&&o.w===s.w&&o.h===s.h&&o.rtl===s.rtl&&o.unsorted===s.unsorted||(this._rect=i,this._rectChanged=!0),this._rectChanged&&(t.max=n,t.configure(),e.max=r,e.configure())}update(t){const e=this.getDataset(),{data:n}=this.getMeta(),r=e.groups||[],o=[e.key||""].concat(e.sumKeys||[]);e.tree=e.tree||e.data||[];const s=e.tree,a=e.treeVersion;"reset"===t&&this.configure(),(this._rectChanged||i(this._keys||[],o)||i(this._groups||[],r)||this._prevTree!==s||this._prevTreeVersion!==a)&&(this._groups=r.slice(),this._keys=o.slice(),this._prevTree=s,this._prevTreeVersion=a,this._rectChanged=!1,e.data=H(s,e,this._keys,this._rect),this._dataCheck(),this._resyncElements()),this.updateElements(n,0,n.length,t)}updateElements(t,e,n,i){const o="reset"===i,s=this.getDataset(),a=this.resolveDataElementOptions(e,i);this._rect.options=a;const h=this.getSharedOptions(a),l=this.includeOptions(i,h||{}),{xScale:u,yScale:c}=this.getMeta();for(let a=e;a<e+n;a++){const e=h||this.resolveDataElementOptions(a,i),n=r(s.data[a],u,c,e.spacing);o&&(n.width=0,n.height=0),l&&(n.options=e),this.updateElement(t[a],a,n,i)}this.updateSharedOptions(h||{},i,a)}draw(){const{ctx:t,chartArea:e}=this.chart,r=this.getMeta().data||[],i=this.getDataset().data;n.clipArea(t,e);for(let e=0,n=r.length;e<n;++e){const n=r[e];n.hidden||n.draw(t,i[e])}n.unclipArea(t)}constructor(t,e){super(t,e),this._groups=void 0,this._keys=void 0,this._rect=void 0,this._rectChanged=!0}}function q(t,e){const{x:n,y:r,width:i,height:o}=t.getProps(["x","y","width","height"],e);return{bottom:r+o,left:n,right:n+i,top:r}}function W(t){const e=q(t),r=e.right-e.left,i=e.bottom-e.top,a=s(t.options.borderWidth,r/2,i/2),h=function(t,e,r){const i=n.toTRBLCorners(t),s=Math.min(e,r);return{bottomLeft:o(i.bottomLeft,0,s),bottomRight:o(i.bottomRight,0,s),topLeft:o(i.topLeft,0,s),topRight:o(i.topRight,0,s)}}(t.options.borderRadius,r/2,i/2),l={active:t.active,h:i,radius:h,w:r,x:e.left,y:e.top};return{inner:{active:t.active,h:l.h-a.t-a.b,radius:{bottomLeft:Math.max(0,h.bottomLeft-Math.max(a.b,a.l)),bottomRight:Math.max(0,h.bottomRight-Math.max(a.b,a.r)),topLeft:Math.max(0,h.topLeft-Math.max(a.t,a.l)),topRight:Math.max(0,h.topRight-Math.max(a.t,a.r))},w:l.w-a.l-a.r,x:l.x+a.l,y:l.y+a.t},outer:l}}function K(t,e,n,r){const i=null===e,o=null===n,s=!(!t||i&&o)&&q(t,r);return s&&(i||e>=s.left&&e<=s.right)&&(o||n>=s.top&&n<=s.bottom)}function N(t,e){t.rect(e.x,e.y,e.w,e.h)}$.id="treemap",$.version="5.0.0-next.2",$.defaults={animations:{numbers:{properties:["x","y","width","height"],type:"number"}},dataElementType:"treemap"},$.descriptors={_indexable:!1,_scriptable:!0,captions:{_fallback:!0,_scriptable:t=>"formatter"!==t},labels:{_fallback:!0,_scriptable:t=>"formatter"!==t}},$.overrides={hover:{},interaction:{includeInvisible:!0,intersect:!0,mode:"point"},plugins:{tooltip:{callbacks:{label(t){const e=t.dataset,n=e.data[t.dataIndex],r=n.g||n._data.label||e.label;return(r?`${r}: `:"")+n.v},title(t){if(t.length){return t[0].dataset.key||""}return""}},intersect:!0,position:"treemap"}},scales:{x:{alignToPixels:!0,bounds:"data",display:!1,type:"linear"},y:{alignToPixels:!0,bounds:"data",display:!1,reverse:!0,type:"linear"}}},$.beforeRegister=()=>{O("chart.js","4.0",e.Chart.version)},$.afterRegister=()=>{V()},$.afterUnregister=()=>{const t=e.registry.plugins.get("tooltip");t&&delete t.positioners.treemap};class G extends e.Element{draw(t,e){if(!e)return;const r=this.options,{inner:i,outer:o}=W(this),s=(a=o.radius).topLeft||a.topRight||a.bottomLeft||a.bottomRight?n.addRoundedRectPath:N;var a;t.save(),o.w===i.w&&o.h===i.h||(t.beginPath(),s(t,o),t.clip(),s(t,i),t.fillStyle=r.borderColor,t.fill("evenodd")),t.beginPath(),s(t,i),t.fillStyle=r.backgroundColor,t.fill(),A(t,i,r,e,this),t.restore()}inRange(t,e,n){return K(this,t,e,n)}inXRange(t,e){return K(this,t,null,e)}inYRange(t,e){return K(this,null,t,e)}getCenterPoint(t){const{x:e,y:n,width:r,height:i}=this.getProps(["x","y","width","height"],t);return{x:e+r/2,y:n+i/2}}tooltipPosition(){return this.getCenterPoint()}constructor(t){super(),this.width=void 0,this.height=void 0,t&&Object.assign(this,t)}}G.id="treemap",G.defaults={borderRadius:0,borderWidth:0,captions:{align:void 0,color:"black",display:!0,font:{},formatter:t=>{const e=t.raw._data?.label;return t.raw.g||("string"==typeof e?e:"")},padding:3},displayMode:"containerBoxes",label:void 0,labels:{align:"center",color:"black",display:!1,font:{},formatter(t){const e=t.raw._data?.label;return t.raw.g?[t.raw.g,`${t.raw.v}`]:"string"==typeof e?[e,`${t.raw.v}`]:`${t.raw.v}`},overflow:"cut",padding:3,position:"middle"},rtl:!1,spacing:.5,unsorted:!1},G.descriptors={_indexable:!1,_scriptable:!0,captions:{_fallback:!0,_scriptable:t=>"formatter"!==t},labels:{_fallback:!0,_scriptable:t=>"formatter"!==t}},G.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"},e.Chart.register($,G),t.TreemapController=$,t.TreemapElement=G,t.flatten=w,t.getGroupKey=x,t.group=C,t.index=R,t.normalizeTreeToArray=v,t.requireVersion=O,t.sort=j,t.sum=E});
|
|
7
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["chartjs-chart-treemap"]={},t.Chart,t.Chart.helpers)}(this,function(t,e,n){"use strict";function i(t,e,n,i){const r=2*i,o=e.getPixelForValue(t.x),s=n.getPixelForValue(t.y),a=e.getPixelForValue(t.x+t.w)-o,h=n.getPixelForValue(t.y+t.h)-s;return{height:h-r,hidden:r>a||r>h,width:a-r,x:o+i,y:s+i}}function r(t,e){let n,i;if(!t||!e)return!0;if(t===e)return!1;if(t.length!==e.length)return!0;for(n=0,i=t.length;n<i;++n)if(t[n]!==e[n])return!0;return!1}const o={displayMode:"containerBoxes",rtl:!1,spacing:.5};function s(t,e,n){return Math.max(Math.min(t,n),e)}function a(t,e,i){const r=n.toTRBL(t);return{b:s(r.bottom,0,i),l:s(r.left,0,e),r:s(r.right,0,e),t:s(r.top,0,i)}}function h(t,e,n,i){const r=t._normalized,o=e*r/n,s=Math.sqrt(r*o),a=r/s;return{d1:s,d2:a,h:"_ix"===i?a:s,w:"_ix"===i?s:a}}const l=(t,e)=>t.rtl?t.x+t.iw-e:t.x+t._ix;function u(t,e,n,i){const r={_data:e._data,a:e._normalized,h:n.h,s:i,v:e.value,vs:e.values,w:n.w,x:l(t,n.w),y:t.y+t._iy};return e.group&&(r.g=e.group,r.l=e.level,r.gs=e.groupSum),r}class c{get area(){return this.w*this.h}get iw(){return this.w-this._ix}get ih(){return this.h-this._iy}get dir(){const t=this.ih;return t<=this.iw&&t>0?"y":"x"}get side(){return"x"===this.dir?this.iw:this.ih}map(t){const{dir:e,side:n}=this,i="x"===e?"_ix":"_iy",r=t.nsum,o=t.get(),s=n*n,a=r*r,l=[];let c=0,d=0;for(const e of o){const n=h(e,s,a,i);d+=n.d1,c=Math.max(c,n.d2),l.push(u(this,e,n,t.sum)),this[i]+=n.d1}return this["x"===e?"_iy":"_ix"]+=c,this[i]-=d,l}constructor(t){t=t||{h:1,w:1},this.rtl=!!t.rtl,this.unsorted=!!t.unsorted,this.x=t.x||t.left||0,this.y=t.y||t.top||0,this._ix=0,this._iy=0,this.w=t.w||t.width||t.right-t.left,this.h=t.h||t.height||t.bottom-t.top}}const d=Math.min,p=Math.max;function f(t,e){const n=+e[t.key],i=n*t.ratio;return e._normalized=i,{max:p(t.max,n),min:d(t.min,n),nmax:p(t.nmax,i),nmin:d(t.nmin,i),nsum:t.nsum+i,sum:t.sum+n}}function g(t,e,n){t._arr.push(e),function(t,e){Object.assign(t,e)}(t,n)}class m{get length(){return this._arr.length}reset(){this._arr=[],this._hist=[],this.sum=0,this.nsum=0,this.min=1/0,this.max=-1/0,this.nmin=1/0,this.nmax=-1/0}push(t){g(this,t,f(this,t))}pushIf(t,e,...n){const i=f(this,t);if(!e((r=this,{max:r.max,min:r.min,nmax:r.nmax,nmin:r.nmin,nsum:r.nsum,sum:r.sum}),i,n))return t;var r;g(this,t,i)}get(){return this._arr}constructor(t,e){this._arr=[],this._hist=[],this.sum=0,this.nsum=0,this.min=1/0,this.max=-1/0,this.nmin=1/0,this.nmax=-1/0,this.key=t,this.ratio=e,this.reset()}}const x=(t,e)=>e>t||t.length>e.length&&t.startsWith(e),y=t=>String(t),b=t=>null!=t&&""!==t;function v(t,e,i,r=[],o=0,s=[]){const a=o-1;if(t[0]in i&&o>0){const n=r.reduce((t,e,n)=>(n!==a&&(t[y(n)]=e),t),{});n[e]=r[a],t.forEach(t=>{n[t]=i[t]}),s.push(n)}else for(const a of Object.keys(i)){const h=i[a];n.isObject(h)&&(r.push(a),v(t,e,h,r,o+1,s))}return r.splice(a,1),s}function w(t,e,n){const i=v(t,e,n);if(!i.length)return i;const r=i.reduce((t,e)=>{const n=Object.keys(e).length-2;return Math.max(t,n)},0);return i.forEach(t=>{for(let e=0;e<r;e++){const n=y(e);t[n]||(t[n]="")}}),i}function _(t){const e=[...t],n=[];for(;e.length;){const t=e.pop();Array.isArray(t)?e.push(...t):n.push(t)}return n.reverse()}function M(t,e,n){const i=[];for(const n of t){const t=e[n];b(t)&&i.push(t)}return i.length?i.join("."):n}function k(t,e,n,i){for(let e=i;e<n.length;e++){const i=y(n[e]);if(b(t[i]))return{group:i,groupIndex:e,value:t[i]}}if(b(t[e]))return{group:e,groupIndex:i,value:t[e]}}function C(t,e,n,i){if(n in t)return;t[n]={value:0};const r=t[n];i.forEach(t=>{r[t]=0}),e[n]=[]}function R(t,e,n,i,r,o,s=[],a=s,h=s.length-1){const l=n[0],u=n.slice(1),c=Object.create(null),d=Object.create(null),p=[],f=a.length?a:[e],g=a.length?h:0;let m,x;for(m=0,x=t.length;m<x;++m){const e=t[m];if(r&&e[r]!==o)continue;const n=k(e,i,f,g);if(!n)return[];const s=n.value;C(c,d,s,u),c[s].value+=+e[l],c[s].label=s,c[s].group=n.group,c[s].groupIndex=n.groupIndex;const a=c[s];u.forEach(t=>{a[t]+=e[t]}),c[s].path=M(f.slice(0,n.groupIndex+1),e,s),d[s].push(e)}return Object.keys(c).forEach(t=>{const n={children:d[t]};n[l]=+c[t].value,u.forEach(e=>{n[e]=+c[t][e]}),n[e]=c[t].label,n.group=c[t].group,n.groupIndex=c[t].groupIndex,n.label=t,n.path=c[t].path,r&&(n[r]=o),p.push(n)}),p}function O(t,e){let i,r=t.length;if(!r)return e;const o=n.isObject(t[0]);for(e=o?e:"v",i=0,r=t.length;i<r;++i)o?t[i]._idx=i:t[i]={_idx:i,v:t[i]};return e}function j(t,e){e?t.sort((t,n)=>+n[e]-+t[e]):t.sort((t,e)=>+e-+t)}function E(t,e){let n,i,r;for(n=0,i=0,r=t.length;i<r;++i)n+=e?+t[i][e]:+t[i];return n}function T(t,e,n,i=!0){const r=n.split(".");let o=0;for(const s of e.split(".")){const a=r[o++];if(Number.parseInt(s,10)<Number.parseInt(a,10))break;if(x(a,s)){if(i)throw new Error(`${t} v${n} is not supported. v${e} or newer is required.`);return!1}}return!0}function L(t,e,n){if(0===t.sum)return!0;const[i]=n,r=t.nsum*t.nsum,o=e.nsum*e.nsum,s=i*i,a=Math.max(s*t.nmax/r,r/(s*t.nmin));return Math.max(s*e.nmax/o,o/(s*e.nmin))<=a}function P(t,e,n=[],i,r,o){t=t||[];const s=[],a=new c(e),h=new m("value",a.area/E(t,n[0]));let l=a.side;const u=t.length;let d,p;if(!u)return s;const f=t.slice(),g=O(f,n[0]);e?.unsorted||j(f,g);const x=t=>g?+f[t][g]:+f[t],y=t=>i&&f[t][i];for(d=0;d<u;++d){if(p={_data:t[f[d]._idx],group:void 0,groupSum:o,level:void 0,value:x(d)},i){p.level=f[d].groupIndex??r,p.group=y(d);const t=f[d];p.values=n.reduce((e,n)=>(e[n]=+t[n],e),{})}p=h.pushIf(p,L,l),p&&(s.push(a.map(h)),l=a.side,h.reset(),h.push(p))}return h.length&&s.push(a.map(h)),_(s)}const I=new Map;function S(t,e,i){if(!i||!1===i.display)return!1;if("headerBoxes"===t)return!0;const{w:r,h:o}=e,s=n.toFont(i.font||{}).lineHeight,a=Math.max(Math.min(2*n.valueOrDefault(i.padding,3),Math.min(r,o)),0);return r-a>s&&o-a>s}function F(t,e,n,i){if("headerBoxes"!==t)return n.lineHeight+2*i;const r=n.lineHeight+2*i;return e.h<2*r?e.h/3:r}function A(t,e,i,r,o,s){const{captions:a,labels:h}=i,{displayMode:l}=s;t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip();let u;r&&(!n.defined(r.l)||r.isLeaf)?h.display&&(u=function(t,e,i,r,o){const s=i.labels,a=D(s.formatter,B(o,r));if(!a)return;const h=n.isArray(a)?a:[a];let l=function(t,e){const{font:i,hoverFont:r}=e,o=(t.active?r:i)||i;return Array.isArray(o)?o.map(t=>n.toFont(t)):[n.toFont(o)]}(e,s),u=H(t,h,l);const c=function(t,e,n){const{overflow:i,padding:r}=e,{width:o,height:s}=n;if("hidden"===i)return!(o+2*r>t.w||s+2*r>t.h);if("fit"===i){const e=Math.min(t.w/(o+2*r),t.h/(s+2*r));if(e<1)return e}return!0}(e,s,u);if(!c)return;n.isNumber(c)&&(u={height:u.height*c,width:u.width*c},l=function(t,e){return t.map(t=>{const{lineHeight:i,...r}=t;return n.toFont({...r,size:Math.floor(t.size*e)})})}(l,c));const{color:d,hoverColor:p,align:f,padding:g}=s,m=(e.active?p:d)||d;return{align:f,colors:n.isArray(m)?m:[m],fonts:l,lines:h,padding:g,top:z(e,s,u)}}(t,e,i,r,o)):S(l,e,a)&&(u=function(t,e,i,r,o,s){const{displayMode:a,rtl:h,spacing:l}=s,{captions:u}=i,{color:c,hoverColor:d,font:p,hoverFont:f,padding:g,align:m}=u,x=(e.active?f:p)||p,y=n.toFont(x);if(y.lineHeight>e.h)return;let b=function(t,e,n){return D(t.formatter,B(e,n))||n.g||""}(u,o,r);if(!b)return;const v=[y];H(t,[b],v).width+2*g>e.w&&(b=function(t,e,n,i){const r="...",o=H(t,[r],i).width;if(o>=n)return"";let s,a=1,h=e.length;for(;a<=h;){const r=Math.floor((a+h)/2);s=H(t,[e.slice(0,r)],i).width,s+o>n?h=r-1:a=r+1}const l=e.slice(0,Math.max(0,a-1));return l?l+r:""}(t,b,e.w-2*g,v));const w="headerBoxes"===a?e.y+(e.h-y.lineHeight)/2:e.y+g+l;return{align:m||(h?"right":"left"),colors:[(e.active?d:c)||c],fonts:v,lines:[b],padding:g,top:w}}(t,e,i,r,o,s)),u&&function(t,e,n){const{align:i,colors:r,fonts:o,lines:s,padding:a,top:h}=n,l=function(t,e,n){if("left"===e)return t.x+n;if("right"===e)return t.x+t.w-n;return t.x+t.w/2}(e,i,a);t.textAlign=i,t.textBaseline="middle";let u=0;s.forEach((e,n)=>{const i=o[Math.min(n,o.length-1)];t.font=i.string,t.fillStyle=r[Math.min(n,r.length-1)],t.fillText(e,l,h+u+i.lineHeight/2),u+=i.lineHeight})}(t,e,u),t.restore()}function B(t,e){const n=t.$context||{active:!!t.active,raw:e,type:"data"};return n.active=!!t.active,n.raw=e,n}function D(t,e){return"function"==typeof t?t(e):t}function H(t,e,n){const i=n.reduce((t,e)=>t+=e.string,""),r=e.join()+i+(t._measureText?"-spriting":"");let o=I.get(r);if(!o){t.save();const i=e.length;let s=0,a=0;for(let r=0;r<i;r++){const i=n[Math.min(r,n.length-1)];t.font=i.string;const o=e[r];s=Math.max(s,t.measureText(o).width),a+=i.lineHeight}t.restore(),o={height:a,width:s},I.set(r,o)}return o}function z(t,e,n){const{position:i,padding:r}=e;return"top"===i?t.y+r:"bottom"===i?t.y+t.h-r-n.height:t.y+(t.h-n.height)/2+r}function V(t,e,i,r){const{borderWidth:o,captions:s,displayMode:h,groups:l,leafKey:u}=r;n.isObject(t)&&(t=w(e,u,t));const c=l.length,d="headerBoxes"===h?0:r.spacing,p=n.toFont(s.font),f=n.valueOrDefault(s.padding,3);const g=c?function t(n,i,r,g,m){const x=y(l[i]),b=R(n,x,e,u,void 0,g,l.filter((t,e)=>e<=i),l,i),v=P(b,r,e,x,i,m),w=v.slice();return i<c-1?v.forEach(e=>{const n=function(t,e){const n="headerBoxes"===h?{b:0,l:0,r:0,t:0}:a(o,t.w/2,t.h/2),i={...e,h:t.h-2*d-n.t-n.b,w:t.w-2*d-n.l-n.r,x:t.x+d+n.l,y:t.y+d+n.t};if(S(h,i,s)){const t=F(h,i,p,f);i.y+=t,i.h-=t}return i}(e,r),i=[],l=e._data.groupIndex+1;l<c&&i.push(...t(e._data.children,l,n,e.g,e.s)),w.push(...i),e.isLeaf=!i.length}):v.forEach(t=>{t.isLeaf=!0}),w}(t,0,i):P(t,i,e);return g.map(t=>{if("headerBoxes"!==h||t.isLeaf)return t;if(!S(h,t,s))return;const e=F(h,t,p,f);return{...t,h:e}}).filter(Boolean)}function $(){const t=e.registry.plugins.get("tooltip");t&&!t.positioners.treemap&&(t.positioners.treemap=t=>{if(!t.length)return!1;return t.at(-1).element.tooltipPosition()})}class K extends e.DatasetController{initialize(){$(),this.enableOptionSharing=!0,super.initialize()}getMinMax(t){return{max:"x"===t.axis?t.right-t.left:t.bottom-t.top,min:0}}configure(){super.configure();const{xScale:t,yScale:e}=this.getMeta();if(!t||!e)return;const n=t.right-t.left,i=e.bottom-e.top,r={h:i,rtl:!!this.options.rtl,unsorted:!!this.options.unsorted,w:n,x:0,y:0};var o,s;o=this._rect,s=r,o&&s&&o.x===s.x&&o.y===s.y&&o.w===s.w&&o.h===s.h&&o.rtl===s.rtl&&o.unsorted===s.unsorted||(this._rect=r,this._rectChanged=!0),this._rectChanged&&(t.max=n,t.configure(),e.max=i,e.configure())}_layoutOptions(){const t=this.getDataset(),e=this.options;return{borderWidth:t.borderWidth,captions:t.captions||{},displayMode:e.displayMode,groups:e.groups||[],leafKey:e.leafKey,spacing:n.valueOrDefault(t.spacing,0)}}update(t){const e=this.getDataset(),{data:n}=this.getMeta(),i=this.options,o=i.groups||[],s=[i.key||""].concat(i.sumKeys||[]);e.tree=e.tree||e.data||[];const a=e.tree,h=e.treeVersion;"reset"===t&&this.configure(),(this._rectChanged||r(this._keys||[],s)||r(this._groups||[],o)||this._prevTree!==a||this._prevTreeVersion!==h)&&(this._groups=o.slice(),this._keys=s.slice(),this._prevTree=a,this._prevTreeVersion=h,this._rectChanged=!1,e.data=V(a,this._keys,this._rect,this._layoutOptions()),this._dataCheck(),this._resyncElements()),this.updateElements(n,0,n.length,t)}updateElements(t,e,n,r){const o="reset"===r,s=this.getDataset(),a=this.resolveDataElementOptions(e,r);this._rect.options=a;const h=this.getSharedOptions(a),l=this.includeOptions(r,h||{}),{xScale:u,yScale:c}=this.getMeta(),d=this.options.spacing;for(let a=e;a<e+n;a++){const e=h||this.resolveDataElementOptions(a,r),n=i(s.data[a],u,c,d);o&&(n.width=0,n.height=0),l&&(n.options=e),this.updateElement(t[a],a,n,r)}this.updateSharedOptions(h||{},r,a)}draw(){const{ctx:t,chartArea:e}=this.chart,i=this.getMeta().data||[],r=this.getDataset().data,{displayMode:o,rtl:s,spacing:a}=this.options,h={displayMode:o,rtl:s,spacing:a};n.clipArea(t,e);for(let e=0,n=i.length;e<n;++e){const n=i[e];n.hidden||n.draw(t,r[e],h)}n.unclipArea(t)}constructor(t,e){super(t,e),this._groups=void 0,this._keys=void 0,this._rect=void 0,this._rectChanged=!0}}function W(t,e){const{x:n,y:i,width:r,height:o}=t.getProps(["x","y","width","height"],e);return{bottom:i+o,left:n,right:n+r,top:i}}function q(t){const e=W(t),i=e.right-e.left,r=e.bottom-e.top,o=a(t.options.borderWidth,i/2,r/2),h=function(t,e,i){const r=n.toTRBLCorners(t),o=Math.min(e,i);return{bottomLeft:s(r.bottomLeft,0,o),bottomRight:s(r.bottomRight,0,o),topLeft:s(r.topLeft,0,o),topRight:s(r.topRight,0,o)}}(t.options.borderRadius,i/2,r/2),l={active:t.active,h:r,radius:h,w:i,x:e.left,y:e.top};return{inner:{active:t.active,h:l.h-o.t-o.b,radius:{bottomLeft:Math.max(0,h.bottomLeft-Math.max(o.b,o.l)),bottomRight:Math.max(0,h.bottomRight-Math.max(o.b,o.r)),topLeft:Math.max(0,h.topLeft-Math.max(o.t,o.l)),topRight:Math.max(0,h.topRight-Math.max(o.t,o.r))},w:l.w-o.l-o.r,x:l.x+o.l,y:l.y+o.t},outer:l}}function N(t,e,n,i){const r=null===e,o=null===n,s=!(!t||r&&o)&&W(t,i);return s&&(r||e>=s.left&&e<=s.right)&&(o||n>=s.top&&n<=s.bottom)}function G(t,e){t.rect(e.x,e.y,e.w,e.h)}K.id="treemap",K.version="5.0.0-next.3",K.defaults={animations:{numbers:{properties:["x","y","width","height"],type:"number"}},dataElementType:"treemap",displayMode:o.displayMode,groups:[],key:"",leafKey:"_leaf",rtl:o.rtl,spacing:o.spacing,sumKeys:[],unsorted:!1},K.descriptors={_indexable:!1,_scriptable:!0,captions:{_fallback:!0,_scriptable:t=>"formatter"!==t},labels:{_fallback:!0,_scriptable:t=>"formatter"!==t}},K.overrides={hover:{},interaction:{includeInvisible:!0,intersect:!0,mode:"point"},plugins:{tooltip:{callbacks:{label(t){const e=t.dataset,n=e.data[t.dataIndex],i=n.g||n._data.label||e.label;return(i?`${i}: `:"")+n.v},title(t){if(t.length){return t[0].dataset.key||""}return""}},intersect:!0,position:"treemap"}},scales:{x:{alignToPixels:!0,bounds:"data",display:!1,type:"linear"},y:{alignToPixels:!0,bounds:"data",display:!1,reverse:!0,type:"linear"}}},K.beforeRegister=()=>{T("chart.js","4.0",e.Chart.version)},K.afterRegister=()=>{$()},K.afterUnregister=()=>{const t=e.registry.plugins.get("tooltip");t&&delete t.positioners.treemap};class U extends e.Element{draw(t,e,i=o){if(!e)return;const r=this.options,{inner:s,outer:a}=q(this),h=(l=a.radius).topLeft||l.topRight||l.bottomLeft||l.bottomRight?n.addRoundedRectPath:G;var l;t.save(),a.w===s.w&&a.h===s.h||(t.beginPath(),h(t,a),t.clip(),h(t,s),t.fillStyle=r.borderColor,t.fill("evenodd")),t.beginPath(),h(t,s),t.fillStyle=r.backgroundColor,t.fill(),A(t,s,r,e,this,i),t.restore()}inRange(t,e,n){return N(this,t,e,n)}inXRange(t,e){return N(this,t,null,e)}inYRange(t,e){return N(this,null,t,e)}getCenterPoint(t){const{x:e,y:n,width:i,height:r}=this.getProps(["x","y","width","height"],t);return{x:e+i/2,y:n+r/2}}tooltipPosition(){return this.getCenterPoint()}constructor(t){super(),this.width=void 0,this.height=void 0,t&&Object.assign(this,t)}}U.id="treemap",U.defaults={borderRadius:0,borderWidth:0,captions:{align:void 0,color:"black",display:!0,font:{},formatter:t=>{const e=t.raw._data?.label;return t.raw.g||("string"==typeof e?e:"")},padding:3},labels:{align:"center",color:"black",display:!1,font:{},formatter(t){const e=t.raw._data?.label;return t.raw.g?[t.raw.g,`${t.raw.v}`]:"string"==typeof e?[e,`${t.raw.v}`]:`${t.raw.v}`},overflow:"cut",padding:3,position:"middle"}},U.descriptors={_indexable:!1,_scriptable:!0,captions:{_fallback:!0,_scriptable:t=>"formatter"!==t},labels:{_fallback:!0,_scriptable:t=>"formatter"!==t}},U.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"},e.Chart.register(K,U),t.TreemapController=K,t.TreemapElement=U,t.flatten=_,t.getGroupKey=y,t.group=R,t.index=O,t.normalizeTreeToArray=w,t.requireVersion=T,t.sort=j,t.sum=E});
|
|
8
8
|
//# sourceMappingURL=chartjs-chart-treemap.min.js.map
|