chartjs-chart-treemap 4.2.2 → 5.0.0-next.10
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/README.md +41 -1
- package/dist/chartjs-chart-treemap.cjs +777 -382
- package/dist/chartjs-chart-treemap.esm.js +781 -404
- package/dist/chartjs-chart-treemap.min.js +2 -2
- package/dist/chartjs-chart-treemap.min.js.map +1 -1
- package/dist/controller.d.cts +62 -0
- package/dist/controller.d.ts +39 -4
- package/dist/element.d.cts +65 -0
- package/dist/element.d.ts +6 -15
- package/dist/geometry.d.cts +38 -0
- package/dist/geometry.d.ts +3 -3
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.d.cts +4 -0
- package/dist/index.esm.d.ts +4 -3
- package/dist/layout.d.cts +29 -0
- package/dist/layout.d.ts +29 -0
- package/dist/options.d.cts +15 -0
- package/dist/options.d.ts +7 -1
- package/dist/rect.d.cts +18 -0
- package/dist/rect.d.ts +1 -1
- package/dist/squarify.d.cts +21 -0
- package/dist/squarify.d.ts +20 -0
- package/dist/statArray.d.cts +18 -0
- package/dist/text/draw.d.ts +30 -0
- package/dist/text/fit.d.ts +9 -0
- package/dist/{text.d.ts → text/index.d.ts} +3 -4
- package/dist/text/measure.d.ts +26 -0
- package/dist/text/wrap.d.ts +6 -0
- package/dist/types.d.cts +167 -0
- package/dist/types.d.ts +54 -28
- package/dist/utils.d.cts +17 -0
- package/dist/utils.d.ts +11 -2
- package/package.json +46 -35
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type {} from './types.js' with { 'resolution-mode': 'import' };
|
|
2
|
+
import type { BorderRadius, Chart, ChartComponent, Color, CoreChartOptions, DatasetController, Element, FontSpec, Scriptable, ScriptableContext, VisualElement } from 'chart.js' with { 'resolution-mode': 'import' };
|
|
3
|
+
export type AnyObject = Record<string, unknown>;
|
|
4
|
+
export type LabelPosition = 'top' | 'middle' | 'bottom';
|
|
5
|
+
export type LabelAlign = 'left' | 'center' | 'right';
|
|
6
|
+
export type LabelOverflow = 'cut' | 'ellipsis' | 'fit' | 'hidden';
|
|
7
|
+
/**
|
|
8
|
+
* How a value becomes an area. `linear` keeps area proportional to value;
|
|
9
|
+
* the others compress a wide range so small items stay visible.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The part of the chart area a dataset lays out into, as fractions of it.
|
|
13
|
+
* Two datasets can then sit side by side instead of painting over each other.
|
|
14
|
+
*/
|
|
15
|
+
export type TreemapRegion = {
|
|
16
|
+
left?: number;
|
|
17
|
+
top?: number;
|
|
18
|
+
width?: number;
|
|
19
|
+
height?: number;
|
|
20
|
+
};
|
|
21
|
+
export type TreemapOthers = {
|
|
22
|
+
/** Bucket a leaf below this share of its siblings' total layout weight. */
|
|
23
|
+
threshold: number;
|
|
24
|
+
label?: string;
|
|
25
|
+
/** Only bucket when at least this many leaves fall below the threshold. */
|
|
26
|
+
minCount?: number;
|
|
27
|
+
};
|
|
28
|
+
export type TreemapValueScale<DType = AnyObject> = 'linear' | 'log' | 'sqrt' | ((value: number, item: DType) => number);
|
|
29
|
+
export type TreemapDisplayMode = 'containerBoxes' | 'headerBoxes';
|
|
30
|
+
export type TreemapBorderWidth = number | Partial<Record<'bottom' | 'left' | 'right' | 'top', number>>;
|
|
31
|
+
export type TreemapBorderRadius = Required<BorderRadius>;
|
|
32
|
+
export type TreemapFontSpec = Partial<FontSpec>;
|
|
33
|
+
export type TreemapScriptableContext = ScriptableContext<'treemap'> & {
|
|
34
|
+
raw: TreemapDataPoint;
|
|
35
|
+
};
|
|
36
|
+
export type TreemapFormatter<T> = T | ((context: TreemapScriptableContext) => T);
|
|
37
|
+
export type TreemapControllerDatasetCaptionsOptions = {
|
|
38
|
+
align?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
39
|
+
overflow?: Scriptable<LabelOverflow, TreemapScriptableContext>;
|
|
40
|
+
textAlign?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
41
|
+
color?: Scriptable<Color, TreemapScriptableContext>;
|
|
42
|
+
display?: boolean;
|
|
43
|
+
formatter?: TreemapFormatter<string>;
|
|
44
|
+
font?: TreemapFontSpec;
|
|
45
|
+
hoverColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
46
|
+
hoverFont?: TreemapFontSpec;
|
|
47
|
+
padding?: number;
|
|
48
|
+
};
|
|
49
|
+
export type TreemapControllerDatasetLabelsOptions = {
|
|
50
|
+
align?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
51
|
+
textAlign?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
52
|
+
wrap?: boolean;
|
|
53
|
+
color?: Scriptable<Color | Color[], TreemapScriptableContext>;
|
|
54
|
+
display?: boolean;
|
|
55
|
+
formatter?: TreemapFormatter<string | string[]>;
|
|
56
|
+
font?: Scriptable<TreemapFontSpec | TreemapFontSpec[], TreemapScriptableContext>;
|
|
57
|
+
hoverColor?: Scriptable<Color | Color[], TreemapScriptableContext>;
|
|
58
|
+
hoverFont?: Scriptable<TreemapFontSpec | TreemapFontSpec[], TreemapScriptableContext>;
|
|
59
|
+
overflow?: Scriptable<LabelOverflow, TreemapScriptableContext>;
|
|
60
|
+
padding?: number;
|
|
61
|
+
position?: Scriptable<LabelPosition, TreemapScriptableContext>;
|
|
62
|
+
};
|
|
63
|
+
export type TreemapCaptionsOptions = {
|
|
64
|
+
align?: LabelAlign;
|
|
65
|
+
overflow?: LabelOverflow;
|
|
66
|
+
textAlign?: LabelAlign;
|
|
67
|
+
color: Color;
|
|
68
|
+
display?: boolean;
|
|
69
|
+
font: TreemapFontSpec;
|
|
70
|
+
formatter?: TreemapFormatter<string>;
|
|
71
|
+
hoverColor?: Color;
|
|
72
|
+
hoverFont?: TreemapFontSpec;
|
|
73
|
+
padding: number;
|
|
74
|
+
};
|
|
75
|
+
export type TreemapLabelsOptions = {
|
|
76
|
+
align: LabelAlign;
|
|
77
|
+
textAlign?: LabelAlign;
|
|
78
|
+
wrap?: boolean;
|
|
79
|
+
color: Color | Color[];
|
|
80
|
+
display?: boolean;
|
|
81
|
+
font: TreemapFontSpec | TreemapFontSpec[];
|
|
82
|
+
formatter?: TreemapFormatter<string | string[]>;
|
|
83
|
+
hoverColor?: Color | Color[];
|
|
84
|
+
hoverFont?: TreemapFontSpec | TreemapFontSpec[];
|
|
85
|
+
overflow: LabelOverflow;
|
|
86
|
+
padding: number;
|
|
87
|
+
position: LabelPosition;
|
|
88
|
+
};
|
|
89
|
+
export interface TreemapControllerDatasetOptions<DType> {
|
|
90
|
+
displayMode?: TreemapDisplayMode;
|
|
91
|
+
rtl?: boolean;
|
|
92
|
+
spacing?: number;
|
|
93
|
+
others?: false | TreemapOthers;
|
|
94
|
+
region?: TreemapRegion;
|
|
95
|
+
unsorted?: boolean;
|
|
96
|
+
valueScale?: TreemapValueScale<DType>;
|
|
97
|
+
backgroundColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
98
|
+
borderColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
99
|
+
borderRadius?: Scriptable<number | Partial<BorderRadius>, TreemapScriptableContext>;
|
|
100
|
+
borderWidth?: number;
|
|
101
|
+
hoverBackgroundColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
102
|
+
hoverBorderColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
103
|
+
hoverBorderWidth?: number;
|
|
104
|
+
captions?: TreemapControllerDatasetCaptionsOptions;
|
|
105
|
+
labels?: TreemapControllerDatasetLabelsOptions;
|
|
106
|
+
label?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Numbers, objects, or a nested object addressed through `leafKey`.
|
|
109
|
+
* The array is read, never written: the layout nodes live in the parsed data.
|
|
110
|
+
*/
|
|
111
|
+
data: number[] | DType[] | AnyObject;
|
|
112
|
+
groups?: Array<keyof DType>;
|
|
113
|
+
sumKeys?: Array<keyof DType>;
|
|
114
|
+
leafKey?: keyof DType;
|
|
115
|
+
key?: keyof DType;
|
|
116
|
+
}
|
|
117
|
+
export interface TreemapDataPoint {
|
|
118
|
+
x: number;
|
|
119
|
+
y: number;
|
|
120
|
+
w: number;
|
|
121
|
+
h: number;
|
|
122
|
+
v: number;
|
|
123
|
+
s: number;
|
|
124
|
+
l?: number;
|
|
125
|
+
g?: string;
|
|
126
|
+
gs?: number;
|
|
127
|
+
vs?: AnyObject;
|
|
128
|
+
_data?: AnyObject;
|
|
129
|
+
isLeaf?: boolean;
|
|
130
|
+
/** Set on the synthetic node that absorbed the items below `others.threshold`. */
|
|
131
|
+
isOthers?: boolean;
|
|
132
|
+
/** headerBoxes: the group's caption does not fit, so nothing is drawn. */
|
|
133
|
+
hidden?: boolean;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Element scope: everything that can differ from one rectangle to the next. */
|
|
137
|
+
export interface TreemapOptions {
|
|
138
|
+
backgroundColor: Color;
|
|
139
|
+
borderColor: Color;
|
|
140
|
+
borderRadius: number | Partial<BorderRadius>;
|
|
141
|
+
borderWidth: TreemapBorderWidth;
|
|
142
|
+
captions: TreemapCaptionsOptions;
|
|
143
|
+
labels: TreemapLabelsOptions;
|
|
144
|
+
}
|
|
145
|
+
/** Dataset scope: resolved once per dataset and passed into layout and draw. */
|
|
146
|
+
export interface TreemapLayoutOptions {
|
|
147
|
+
displayMode: TreemapDisplayMode;
|
|
148
|
+
rtl: boolean;
|
|
149
|
+
spacing: number;
|
|
150
|
+
}
|
|
151
|
+
export interface TreemapConfig {
|
|
152
|
+
x: number;
|
|
153
|
+
y: number;
|
|
154
|
+
width: number;
|
|
155
|
+
height: number;
|
|
156
|
+
}
|
|
157
|
+
export type TreemapController = DatasetController;
|
|
158
|
+
export type TreemapControllerComponent = ChartComponent & {
|
|
159
|
+
prototype: TreemapController;
|
|
160
|
+
new (chart: Chart, datasetIndex: number): TreemapController;
|
|
161
|
+
};
|
|
162
|
+
export interface TreemapElement<T extends TreemapConfig = TreemapConfig, O extends TreemapOptions = TreemapOptions> extends Element<T, O>, VisualElement {
|
|
163
|
+
}
|
|
164
|
+
export type TreemapElementComponent = ChartComponent & {
|
|
165
|
+
prototype: TreemapElement;
|
|
166
|
+
new (cfg: TreemapConfig): TreemapElement;
|
|
167
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,29 @@ import type { BorderRadius, Chart, ChartComponent, Color, CoreChartOptions, Data
|
|
|
2
2
|
export type AnyObject = Record<string, unknown>;
|
|
3
3
|
export type LabelPosition = 'top' | 'middle' | 'bottom';
|
|
4
4
|
export type LabelAlign = 'left' | 'center' | 'right';
|
|
5
|
-
export type LabelOverflow = 'cut' | '
|
|
5
|
+
export type LabelOverflow = 'cut' | 'ellipsis' | 'fit' | 'hidden';
|
|
6
|
+
/**
|
|
7
|
+
* How a value becomes an area. `linear` keeps area proportional to value;
|
|
8
|
+
* the others compress a wide range so small items stay visible.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The part of the chart area a dataset lays out into, as fractions of it.
|
|
12
|
+
* Two datasets can then sit side by side instead of painting over each other.
|
|
13
|
+
*/
|
|
14
|
+
export type TreemapRegion = {
|
|
15
|
+
left?: number;
|
|
16
|
+
top?: number;
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
};
|
|
20
|
+
export type TreemapOthers = {
|
|
21
|
+
/** Bucket a leaf below this share of its siblings' total layout weight. */
|
|
22
|
+
threshold: number;
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Only bucket when at least this many leaves fall below the threshold. */
|
|
25
|
+
minCount?: number;
|
|
26
|
+
};
|
|
27
|
+
export type TreemapValueScale<DType = AnyObject> = 'linear' | 'log' | 'sqrt' | ((value: number, item: DType) => number);
|
|
6
28
|
export type TreemapDisplayMode = 'containerBoxes' | 'headerBoxes';
|
|
7
29
|
export type TreemapBorderWidth = number | Partial<Record<'bottom' | 'left' | 'right' | 'top', number>>;
|
|
8
30
|
export type TreemapBorderRadius = Required<BorderRadius>;
|
|
@@ -13,6 +35,8 @@ export type TreemapScriptableContext = ScriptableContext<'treemap'> & {
|
|
|
13
35
|
export type TreemapFormatter<T> = T | ((context: TreemapScriptableContext) => T);
|
|
14
36
|
export type TreemapControllerDatasetCaptionsOptions = {
|
|
15
37
|
align?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
38
|
+
overflow?: Scriptable<LabelOverflow, TreemapScriptableContext>;
|
|
39
|
+
textAlign?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
16
40
|
color?: Scriptable<Color, TreemapScriptableContext>;
|
|
17
41
|
display?: boolean;
|
|
18
42
|
formatter?: TreemapFormatter<string>;
|
|
@@ -23,6 +47,8 @@ export type TreemapControllerDatasetCaptionsOptions = {
|
|
|
23
47
|
};
|
|
24
48
|
export type TreemapControllerDatasetLabelsOptions = {
|
|
25
49
|
align?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
50
|
+
textAlign?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
51
|
+
wrap?: boolean;
|
|
26
52
|
color?: Scriptable<Color | Color[], TreemapScriptableContext>;
|
|
27
53
|
display?: boolean;
|
|
28
54
|
formatter?: TreemapFormatter<string | string[]>;
|
|
@@ -33,16 +59,10 @@ export type TreemapControllerDatasetLabelsOptions = {
|
|
|
33
59
|
padding?: number;
|
|
34
60
|
position?: Scriptable<LabelPosition, TreemapScriptableContext>;
|
|
35
61
|
};
|
|
36
|
-
export type TreemapControllerDatasetDividersOptions = {
|
|
37
|
-
display?: boolean;
|
|
38
|
-
lineCapStyle?: CanvasLineCap;
|
|
39
|
-
lineColor?: Color;
|
|
40
|
-
lineDash?: number[];
|
|
41
|
-
lineDashOffset?: number;
|
|
42
|
-
lineWidth?: number;
|
|
43
|
-
};
|
|
44
62
|
export type TreemapCaptionsOptions = {
|
|
45
63
|
align?: LabelAlign;
|
|
64
|
+
overflow?: LabelOverflow;
|
|
65
|
+
textAlign?: LabelAlign;
|
|
46
66
|
color: Color;
|
|
47
67
|
display?: boolean;
|
|
48
68
|
font: TreemapFontSpec;
|
|
@@ -53,6 +73,8 @@ export type TreemapCaptionsOptions = {
|
|
|
53
73
|
};
|
|
54
74
|
export type TreemapLabelsOptions = {
|
|
55
75
|
align: LabelAlign;
|
|
76
|
+
textAlign?: LabelAlign;
|
|
77
|
+
wrap?: boolean;
|
|
56
78
|
color: Color | Color[];
|
|
57
79
|
display?: boolean;
|
|
58
80
|
font: TreemapFontSpec | TreemapFontSpec[];
|
|
@@ -63,18 +85,14 @@ export type TreemapLabelsOptions = {
|
|
|
63
85
|
padding: number;
|
|
64
86
|
position: LabelPosition;
|
|
65
87
|
};
|
|
66
|
-
export type TreemapDividersOptions = {
|
|
67
|
-
display?: boolean;
|
|
68
|
-
lineCapStyle: CanvasLineCap;
|
|
69
|
-
lineColor: Color;
|
|
70
|
-
lineDash: number[];
|
|
71
|
-
lineDashOffset: number;
|
|
72
|
-
lineWidth: number;
|
|
73
|
-
};
|
|
74
88
|
export interface TreemapControllerDatasetOptions<DType> {
|
|
75
|
-
|
|
89
|
+
displayMode?: TreemapDisplayMode;
|
|
76
90
|
rtl?: boolean;
|
|
77
|
-
|
|
91
|
+
spacing?: number;
|
|
92
|
+
others?: false | TreemapOthers;
|
|
93
|
+
region?: TreemapRegion;
|
|
94
|
+
unsorted?: boolean;
|
|
95
|
+
valueScale?: TreemapValueScale<DType>;
|
|
78
96
|
backgroundColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
79
97
|
borderColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
80
98
|
borderRadius?: Scriptable<number | Partial<BorderRadius>, TreemapScriptableContext>;
|
|
@@ -83,15 +101,16 @@ export interface TreemapControllerDatasetOptions<DType> {
|
|
|
83
101
|
hoverBorderColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
84
102
|
hoverBorderWidth?: number;
|
|
85
103
|
captions?: TreemapControllerDatasetCaptionsOptions;
|
|
86
|
-
dividers?: TreemapControllerDatasetDividersOptions;
|
|
87
104
|
labels?: TreemapControllerDatasetLabelsOptions;
|
|
88
105
|
label?: string;
|
|
89
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Numbers, objects, or a nested object addressed through `leafKey`.
|
|
108
|
+
* The array is read, never written: the layout nodes live in the parsed data.
|
|
109
|
+
*/
|
|
110
|
+
data: number[] | DType[] | AnyObject;
|
|
90
111
|
groups?: Array<keyof DType>;
|
|
91
112
|
sumKeys?: Array<keyof DType>;
|
|
92
|
-
|
|
93
|
-
treeLeafKey?: keyof DType;
|
|
94
|
-
treeVersion?: number | string;
|
|
113
|
+
leafKey?: keyof DType;
|
|
95
114
|
key?: keyof DType;
|
|
96
115
|
}
|
|
97
116
|
export interface TreemapDataPoint {
|
|
@@ -107,28 +126,35 @@ export interface TreemapDataPoint {
|
|
|
107
126
|
vs?: AnyObject;
|
|
108
127
|
_data?: AnyObject;
|
|
109
128
|
isLeaf?: boolean;
|
|
129
|
+
/** Set on the synthetic node that absorbed the items below `others.threshold`. */
|
|
130
|
+
isOthers?: boolean;
|
|
131
|
+
/** headerBoxes: the group's caption does not fit, so nothing is drawn. */
|
|
132
|
+
hidden?: boolean;
|
|
110
133
|
}
|
|
111
134
|
declare module 'chart.js' {
|
|
112
135
|
interface ChartTypeRegistry {
|
|
113
136
|
treemap: {
|
|
114
137
|
chartOptions: CoreChartOptions<'treemap'>;
|
|
115
138
|
datasetOptions: TreemapControllerDatasetOptions<Record<string, unknown>>;
|
|
116
|
-
defaultDataPoint:
|
|
139
|
+
defaultDataPoint: number | AnyObject;
|
|
117
140
|
metaExtensions: AnyObject;
|
|
118
|
-
parsedDataType:
|
|
141
|
+
parsedDataType: TreemapDataPoint;
|
|
119
142
|
scales: never;
|
|
120
143
|
};
|
|
121
144
|
}
|
|
122
145
|
}
|
|
146
|
+
/** Element scope: everything that can differ from one rectangle to the next. */
|
|
123
147
|
export interface TreemapOptions {
|
|
124
148
|
backgroundColor: Color;
|
|
125
149
|
borderColor: Color;
|
|
126
150
|
borderRadius: number | Partial<BorderRadius>;
|
|
127
151
|
borderWidth: TreemapBorderWidth;
|
|
128
152
|
captions: TreemapCaptionsOptions;
|
|
129
|
-
displayMode: TreemapDisplayMode;
|
|
130
|
-
dividers: TreemapDividersOptions;
|
|
131
153
|
labels: TreemapLabelsOptions;
|
|
154
|
+
}
|
|
155
|
+
/** Dataset scope: resolved once per dataset and passed into layout and draw. */
|
|
156
|
+
export interface TreemapLayoutOptions {
|
|
157
|
+
displayMode: TreemapDisplayMode;
|
|
132
158
|
rtl: boolean;
|
|
133
159
|
spacing: number;
|
|
134
160
|
}
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AnyObject } from './types.cjs';
|
|
2
|
+
export declare const getGroupKey: (lvl: unknown) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Flattens a nested object into the array form of `data`.
|
|
5
|
+
*
|
|
6
|
+
* The controller does this at runtime, so JavaScript configurations never need
|
|
7
|
+
* it. TypeScript users who would rather pass an array than a generic can call
|
|
8
|
+
* it up front.
|
|
9
|
+
*/
|
|
10
|
+
export declare function flattenTree<T = AnyObject>(tree: AnyObject, keys: string[], leafKey: string): T[];
|
|
11
|
+
export declare function normalizeTreeToArray(keys: string[], leafKey: string, obj: Record<string, any>): Record<string, any>[];
|
|
12
|
+
export declare function flatten(input: any[]): any[];
|
|
13
|
+
export declare function group(values: Record<string, any>[], grp: string, keys: string[], leafKey: string, mainGrp?: string, mainValue?: any, groups?: string[], allGroups?: string[], groupIndex?: number): Record<string, any>[];
|
|
14
|
+
export declare function index(values: any[], key: string): string;
|
|
15
|
+
export declare function sort(values: any[], key?: string): void;
|
|
16
|
+
export declare function sum(values: any[], key?: string): number;
|
|
17
|
+
export declare function requireVersion(pkg: string, min: string, ver: string, strict?: boolean): boolean;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import type { AnyObject } from './types.js';
|
|
1
2
|
export declare const getGroupKey: (lvl: unknown) => string;
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Flattens a nested object into the array form of `data`.
|
|
5
|
+
*
|
|
6
|
+
* The controller does this at runtime, so JavaScript configurations never need
|
|
7
|
+
* it. TypeScript users who would rather pass an array than a generic can call
|
|
8
|
+
* it up front.
|
|
9
|
+
*/
|
|
10
|
+
export declare function flattenTree<T = AnyObject>(tree: AnyObject, keys: string[], leafKey: string): T[];
|
|
11
|
+
export declare function normalizeTreeToArray(keys: string[], leafKey: string, obj: Record<string, any>): Record<string, any>[];
|
|
3
12
|
export declare function flatten(input: any[]): any[];
|
|
4
|
-
export declare function group(values: Record<string, any>[], grp: string, keys: string[],
|
|
13
|
+
export declare function group(values: Record<string, any>[], grp: string, keys: string[], leafKey: string, mainGrp?: string, mainValue?: any, groups?: string[], allGroups?: string[], groupIndex?: number): Record<string, any>[];
|
|
5
14
|
export declare function index(values: any[], key: string): string;
|
|
6
15
|
export declare function sort(values: any[], key?: string): void;
|
|
7
16
|
export declare function sum(values: any[], key?: string): number;
|
package/package.json
CHANGED
|
@@ -7,53 +7,56 @@
|
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@astrojs/check": "^0.9.9",
|
|
9
9
|
"@astrojs/mdx": "^8.0.0",
|
|
10
|
-
"@astrojs/starlight": "^0.
|
|
10
|
+
"@astrojs/starlight": "^0.43.1",
|
|
11
11
|
"@biomejs/biome": "^2.4.14",
|
|
12
12
|
"@emnapi/core": "^1.11.2",
|
|
13
13
|
"@emnapi/runtime": "^1.11.2",
|
|
14
|
-
"@kurkle/
|
|
14
|
+
"@kurkle/astro-chartjs-editor": "^1.3.1",
|
|
15
|
+
"@kurkle/configs": "^1.5.1",
|
|
15
16
|
"@napi-rs/canvas": "^1.0.0",
|
|
16
17
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
17
18
|
"@rollup/plugin-json": "^6.1.0",
|
|
18
19
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
19
20
|
"@rollup/plugin-swc": "^0.4.0",
|
|
20
21
|
"@rollup/plugin-terser": "^1.0.0",
|
|
21
|
-
"@swc/cli": "^0.8.1",
|
|
22
22
|
"@swc/core": "^1.11.9",
|
|
23
|
-
"@types/jasmine": "^6.0.0",
|
|
24
23
|
"@types/node": "^26.0.0",
|
|
24
|
+
"@vitest/browser": "^5.0.0",
|
|
25
|
+
"@vitest/browser-playwright": "^5.0.0",
|
|
26
|
+
"@vitest/coverage-istanbul": "^5.0.0",
|
|
27
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
25
28
|
"astro": "^7.0.6",
|
|
26
|
-
"c8": "^12.0.0",
|
|
27
29
|
"chart.js": "^4.0.1",
|
|
28
30
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
29
31
|
"chartjs-plugin-zoom": "^2.0.0",
|
|
30
|
-
"chartjs-test-utils": "^0.5.0",
|
|
31
32
|
"concurrently": "^10.0.3",
|
|
32
|
-
"
|
|
33
|
+
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
33
34
|
"globals": "^17.0.0",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"karma-chrome-launcher": "^3.1.0",
|
|
38
|
-
"karma-coverage": "^2.0.3",
|
|
39
|
-
"karma-firefox-launcher": "^2.1.0",
|
|
40
|
-
"karma-jasmine": "^5.1.0",
|
|
41
|
-
"karma-jasmine-html-reporter": "^2.0.0",
|
|
42
|
-
"karma-rollup-preprocessor": "^7.0.8",
|
|
43
|
-
"karma-spec-reporter": "^0.0.36",
|
|
44
|
-
"pixelmatch": "^7.1.0",
|
|
35
|
+
"pixelmatch": "^8.0.0",
|
|
36
|
+
"playwright": "^1.63.0",
|
|
37
|
+
"png-to-ico": "^3.0.2",
|
|
45
38
|
"rollup": "^4.21.2",
|
|
46
39
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
47
40
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
48
|
-
"rollup-plugin-istanbul": "^5.0.0",
|
|
49
41
|
"semantic-release": "^25.0.3",
|
|
50
|
-
"
|
|
42
|
+
"sharp": "^0.35.4",
|
|
43
|
+
"typescript": "^6.0.3",
|
|
44
|
+
"vitest": "^5.0.0",
|
|
45
|
+
"webpack": "^5.110.3"
|
|
51
46
|
},
|
|
52
47
|
"exports": {
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
".": {
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./dist/index.esm.d.ts",
|
|
51
|
+
"default": "./dist/chartjs-chart-treemap.esm.js"
|
|
52
|
+
},
|
|
53
|
+
"require": {
|
|
54
|
+
"types": "./dist/index.d.cts",
|
|
55
|
+
"default": "./dist/chartjs-chart-treemap.cjs"
|
|
56
|
+
},
|
|
57
|
+
"script": "./dist/chartjs-chart-treemap.min.js"
|
|
58
|
+
},
|
|
59
|
+
"./package.json": "./package.json"
|
|
57
60
|
},
|
|
58
61
|
"files": [
|
|
59
62
|
"dist/*",
|
|
@@ -71,7 +74,7 @@
|
|
|
71
74
|
"module": "dist/chartjs-chart-treemap.esm.js",
|
|
72
75
|
"name": "chartjs-chart-treemap",
|
|
73
76
|
"peerDependencies": {
|
|
74
|
-
"chart.js": ">=
|
|
77
|
+
"chart.js": ">=4.0.0"
|
|
75
78
|
},
|
|
76
79
|
"repository": {
|
|
77
80
|
"type": "git",
|
|
@@ -79,25 +82,33 @@
|
|
|
79
82
|
},
|
|
80
83
|
"scripts": {
|
|
81
84
|
"autobuild": "rollup -c -w",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"dev
|
|
85
|
+
"bench": "node bench/update.mjs",
|
|
86
|
+
"build": "rollup -c && tsc -p tsconfig.json --emitDeclarationOnly && kurkle-build-cjs-types",
|
|
87
|
+
"dev": "vitest --config vitest.browser.config.ts",
|
|
85
88
|
"docs": "npm run build && astro build",
|
|
86
89
|
"docs:dev": "npm run build && astro dev",
|
|
87
90
|
"docs:version": "node ./docs/scripts/write-docs-version.cjs",
|
|
91
|
+
"fixtures:update": "node scripts/update-fixtures.mjs",
|
|
88
92
|
"format": "biome check --write",
|
|
93
|
+
"icons": "kurkle-generate-icons",
|
|
89
94
|
"lint": "biome check",
|
|
95
|
+
"predev": "playwright install chromium firefox",
|
|
90
96
|
"predocs": "npm run docs:version",
|
|
91
97
|
"predocs:dev": "npm run docs:version",
|
|
98
|
+
"prefixtures:update": "playwright install chromium",
|
|
99
|
+
"prepack": "npm run build",
|
|
92
100
|
"prepare": "git config core.hooksPath .githooks || true",
|
|
93
|
-
"pretest:
|
|
94
|
-
"
|
|
95
|
-
"test
|
|
96
|
-
"test:
|
|
101
|
+
"pretest:fixture": "playwright install chromium firefox",
|
|
102
|
+
"pretest:integration:browser-module": "playwright install chromium",
|
|
103
|
+
"test": "npm run test:unit && npm run test:fixture && npm run test:integration:browser-module && npm run test:integration:node-commonjs && npm run test:integration:node-module && npm run test:integration:webpack && npm run test:pack",
|
|
104
|
+
"test:fixture": "vitest run --config vitest.browser.config.ts --coverage",
|
|
105
|
+
"test:integration:browser-module": "vitest run --config vitest.integration.config.ts",
|
|
97
106
|
"test:integration:node-commonjs": "node test/integration/node-commonjs/test.cjs",
|
|
98
107
|
"test:integration:node-module": "node test/integration/node-module/test.mjs",
|
|
99
|
-
"test:
|
|
100
|
-
"
|
|
108
|
+
"test:integration:webpack": "node test/integration/webpack/test.mjs",
|
|
109
|
+
"test:pack": "kurkle-check-package",
|
|
110
|
+
"test:unit": "vitest run --config vitest.config.ts --coverage",
|
|
111
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json && tsc -p tsconfig.json --emitDeclarationOnly && tsc --noEmit -p test/types/ && tsc --noEmit -p tsconfig.tooling.json",
|
|
101
112
|
"typecheck:docs": "astro check"
|
|
102
113
|
},
|
|
103
114
|
"sideEffects": [
|
|
@@ -107,5 +118,5 @@
|
|
|
107
118
|
"type": "module",
|
|
108
119
|
"types": "dist/index.esm.d.ts",
|
|
109
120
|
"unpkg": "dist/chartjs-chart-treemap.min.js",
|
|
110
|
-
"version": "
|
|
121
|
+
"version": "5.0.0-next.10"
|
|
111
122
|
}
|