chartjs-chart-treemap 3.1.0 → 4.1.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/chartjs-chart-treemap.cjs +1130 -1082
- package/dist/chartjs-chart-treemap.esm.js +1124 -1084
- package/dist/chartjs-chart-treemap.min.js +3 -3
- package/dist/chartjs-chart-treemap.min.js.map +1 -1
- package/dist/controller.d.ts +19 -0
- package/dist/element.d.ts +74 -0
- package/dist/geometry.d.ts +38 -0
- package/dist/helpers/index.d.ts +9 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.esm.d.ts +3 -0
- package/dist/options.d.ts +9 -0
- package/dist/rect.d.ts +18 -0
- package/dist/squarify.d.ts +1 -0
- package/dist/statArray.d.ts +18 -0
- package/dist/text.d.ts +20 -0
- package/dist/types.d.ts +149 -0
- package/dist/utils.d.ts +8 -0
- package/package.json +85 -74
- package/types/index.esm.d.ts +0 -159
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default class StatArray {
|
|
2
|
+
key: string;
|
|
3
|
+
ratio: number;
|
|
4
|
+
_arr: any[];
|
|
5
|
+
_hist: any[];
|
|
6
|
+
sum: number;
|
|
7
|
+
nsum: number;
|
|
8
|
+
min: number;
|
|
9
|
+
max: number;
|
|
10
|
+
nmin: number;
|
|
11
|
+
nmax: number;
|
|
12
|
+
constructor(key: string, ratio: number);
|
|
13
|
+
get length(): number;
|
|
14
|
+
reset(): void;
|
|
15
|
+
push(o: any): void;
|
|
16
|
+
pushIf(o: any, fn: any, ...args: any[]): any;
|
|
17
|
+
get(): any[];
|
|
18
|
+
}
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Element } from 'chart.js';
|
|
2
|
+
import type { DrawRect } from './geometry';
|
|
3
|
+
import type { TreemapCaptionsOptions, TreemapConfig, TreemapDataPoint, TreemapDisplayMode, TreemapOptions, TreemapScriptableContext } from './types';
|
|
4
|
+
type RectSize = {
|
|
5
|
+
h: number;
|
|
6
|
+
w: number;
|
|
7
|
+
};
|
|
8
|
+
type RectHeight = {
|
|
9
|
+
h: number;
|
|
10
|
+
};
|
|
11
|
+
type TextElement = Element<TreemapConfig, TreemapOptions> & {
|
|
12
|
+
$context?: TreemapScriptableContext;
|
|
13
|
+
};
|
|
14
|
+
export declare function shouldDrawCaption(displayMode: TreemapDisplayMode, rect: RectSize, options?: Partial<TreemapCaptionsOptions>): boolean;
|
|
15
|
+
export declare function getCaptionHeight(displayMode: TreemapDisplayMode, rect: RectHeight, font: {
|
|
16
|
+
lineHeight: number;
|
|
17
|
+
}, padding: number): number;
|
|
18
|
+
export declare function drawText(ctx: CanvasRenderingContext2D, rect: DrawRect, options: TreemapOptions, item: TreemapDataPoint, element: TextElement): void;
|
|
19
|
+
export declare function drawDivider(ctx: CanvasRenderingContext2D, rect: DrawRect, options: TreemapOptions, item: TreemapDataPoint): void;
|
|
20
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { BorderRadius, Chart, ChartComponent, Color, CoreChartOptions, DatasetController, Element, FontSpec, Scriptable, ScriptableContext, VisualElement } from 'chart.js';
|
|
2
|
+
export type AnyObject = Record<string, unknown>;
|
|
3
|
+
export type LabelPosition = 'top' | 'middle' | 'bottom';
|
|
4
|
+
export type LabelAlign = 'left' | 'center' | 'right';
|
|
5
|
+
export type LabelOverflow = 'cut' | 'hidden' | 'fit';
|
|
6
|
+
export type TreemapDisplayMode = 'containerBoxes' | 'headerBoxes';
|
|
7
|
+
export type TreemapBorderWidth = number | Partial<Record<'bottom' | 'left' | 'right' | 'top', number>>;
|
|
8
|
+
export type TreemapBorderRadius = Required<BorderRadius>;
|
|
9
|
+
export type TreemapFontSpec = Partial<FontSpec>;
|
|
10
|
+
export type TreemapScriptableContext = ScriptableContext<'treemap'> & {
|
|
11
|
+
raw: TreemapDataPoint;
|
|
12
|
+
};
|
|
13
|
+
export type TreemapFormatter<T> = T | ((context: TreemapScriptableContext) => T);
|
|
14
|
+
export type TreemapControllerDatasetCaptionsOptions = {
|
|
15
|
+
align?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
16
|
+
color?: Scriptable<Color, TreemapScriptableContext>;
|
|
17
|
+
display?: boolean;
|
|
18
|
+
formatter?: TreemapFormatter<string>;
|
|
19
|
+
font?: TreemapFontSpec;
|
|
20
|
+
hoverColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
21
|
+
hoverFont?: TreemapFontSpec;
|
|
22
|
+
padding?: number;
|
|
23
|
+
};
|
|
24
|
+
export type TreemapControllerDatasetLabelsOptions = {
|
|
25
|
+
align?: Scriptable<LabelAlign, TreemapScriptableContext>;
|
|
26
|
+
color?: Scriptable<Color | Color[], TreemapScriptableContext>;
|
|
27
|
+
display?: boolean;
|
|
28
|
+
formatter?: TreemapFormatter<string | string[]>;
|
|
29
|
+
font?: Scriptable<TreemapFontSpec | TreemapFontSpec[], TreemapScriptableContext>;
|
|
30
|
+
hoverColor?: Scriptable<Color | Color[], TreemapScriptableContext>;
|
|
31
|
+
hoverFont?: Scriptable<TreemapFontSpec | TreemapFontSpec[], TreemapScriptableContext>;
|
|
32
|
+
overflow?: Scriptable<LabelOverflow, TreemapScriptableContext>;
|
|
33
|
+
padding?: number;
|
|
34
|
+
position?: Scriptable<LabelPosition, TreemapScriptableContext>;
|
|
35
|
+
};
|
|
36
|
+
export type TreemapControllerDatasetDividersOptions = {
|
|
37
|
+
display?: boolean;
|
|
38
|
+
lineCapStyle?: CanvasLineCap;
|
|
39
|
+
lineColor?: Color;
|
|
40
|
+
lineDash?: number[];
|
|
41
|
+
lineDashOffset?: number;
|
|
42
|
+
lineWidth?: number;
|
|
43
|
+
};
|
|
44
|
+
export type TreemapCaptionsOptions = {
|
|
45
|
+
align?: LabelAlign;
|
|
46
|
+
color: Color;
|
|
47
|
+
display?: boolean;
|
|
48
|
+
font: TreemapFontSpec;
|
|
49
|
+
formatter?: TreemapFormatter<string>;
|
|
50
|
+
hoverColor?: Color;
|
|
51
|
+
hoverFont?: TreemapFontSpec;
|
|
52
|
+
padding: number;
|
|
53
|
+
};
|
|
54
|
+
export type TreemapLabelsOptions = {
|
|
55
|
+
align: LabelAlign;
|
|
56
|
+
color: Color | Color[];
|
|
57
|
+
display?: boolean;
|
|
58
|
+
font: TreemapFontSpec | TreemapFontSpec[];
|
|
59
|
+
formatter?: TreemapFormatter<string | string[]>;
|
|
60
|
+
hoverColor?: Color | Color[];
|
|
61
|
+
hoverFont?: TreemapFontSpec | TreemapFontSpec[];
|
|
62
|
+
overflow: LabelOverflow;
|
|
63
|
+
padding: number;
|
|
64
|
+
position: LabelPosition;
|
|
65
|
+
};
|
|
66
|
+
export type TreemapDividersOptions = {
|
|
67
|
+
display?: boolean;
|
|
68
|
+
lineCapStyle: CanvasLineCap;
|
|
69
|
+
lineColor: Color;
|
|
70
|
+
lineDash: number[];
|
|
71
|
+
lineDashOffset: number;
|
|
72
|
+
lineWidth: number;
|
|
73
|
+
};
|
|
74
|
+
export interface TreemapControllerDatasetOptions<DType> {
|
|
75
|
+
spacing?: number;
|
|
76
|
+
rtl?: boolean;
|
|
77
|
+
displayType?: TreemapDisplayMode;
|
|
78
|
+
backgroundColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
79
|
+
borderColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
80
|
+
borderWidth?: number;
|
|
81
|
+
hoverBackgroundColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
82
|
+
hoverBorderColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
83
|
+
hoverBorderWidth?: number;
|
|
84
|
+
captions?: TreemapControllerDatasetCaptionsOptions;
|
|
85
|
+
dividers?: TreemapControllerDatasetDividersOptions;
|
|
86
|
+
labels?: TreemapControllerDatasetLabelsOptions;
|
|
87
|
+
label?: string;
|
|
88
|
+
data: TreemapDataPoint[];
|
|
89
|
+
groups?: Array<keyof DType>;
|
|
90
|
+
sumKeys?: Array<keyof DType>;
|
|
91
|
+
tree: number[] | DType[] | AnyObject;
|
|
92
|
+
treeLeafKey?: keyof DType;
|
|
93
|
+
key?: keyof DType;
|
|
94
|
+
}
|
|
95
|
+
export interface TreemapDataPoint {
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
w: number;
|
|
99
|
+
h: number;
|
|
100
|
+
v: number;
|
|
101
|
+
s: number;
|
|
102
|
+
l?: number;
|
|
103
|
+
g?: string;
|
|
104
|
+
gs?: number;
|
|
105
|
+
vs?: AnyObject;
|
|
106
|
+
_data?: AnyObject;
|
|
107
|
+
isLeaf?: boolean;
|
|
108
|
+
}
|
|
109
|
+
declare module 'chart.js' {
|
|
110
|
+
interface ChartTypeRegistry {
|
|
111
|
+
treemap: {
|
|
112
|
+
chartOptions: CoreChartOptions<'treemap'>;
|
|
113
|
+
datasetOptions: TreemapControllerDatasetOptions<Record<string, unknown>>;
|
|
114
|
+
defaultDataPoint: TreemapDataPoint;
|
|
115
|
+
metaExtensions: AnyObject;
|
|
116
|
+
parsedDataType: unknown;
|
|
117
|
+
scales: never;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export interface TreemapOptions {
|
|
122
|
+
backgroundColor: Color;
|
|
123
|
+
borderColor: Color;
|
|
124
|
+
borderRadius: number | Partial<BorderRadius>;
|
|
125
|
+
borderWidth: TreemapBorderWidth;
|
|
126
|
+
captions: TreemapCaptionsOptions;
|
|
127
|
+
displayMode: TreemapDisplayMode;
|
|
128
|
+
dividers: TreemapDividersOptions;
|
|
129
|
+
labels: TreemapLabelsOptions;
|
|
130
|
+
rtl: boolean;
|
|
131
|
+
spacing: number;
|
|
132
|
+
}
|
|
133
|
+
export interface TreemapConfig {
|
|
134
|
+
x: number;
|
|
135
|
+
y: number;
|
|
136
|
+
width: number;
|
|
137
|
+
height: number;
|
|
138
|
+
}
|
|
139
|
+
export type TreemapController = DatasetController;
|
|
140
|
+
export type TreemapControllerComponent = ChartComponent & {
|
|
141
|
+
prototype: TreemapController;
|
|
142
|
+
new (chart: Chart, datasetIndex: number): TreemapController;
|
|
143
|
+
};
|
|
144
|
+
export interface TreemapElement<T extends TreemapConfig = TreemapConfig, O extends TreemapOptions = TreemapOptions> extends Element<T, O>, VisualElement {
|
|
145
|
+
}
|
|
146
|
+
export type TreemapElementComponent = ChartComponent & {
|
|
147
|
+
prototype: TreemapElement;
|
|
148
|
+
new (cfg: TreemapConfig): TreemapElement;
|
|
149
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const getGroupKey: (lvl: unknown) => string;
|
|
2
|
+
export declare function normalizeTreeToArray(keys: string[], treeLeafKey: string, obj: Record<string, any>): Record<string, any>[];
|
|
3
|
+
export declare function flatten(input: any[]): any[];
|
|
4
|
+
export declare function group(values: Record<string, any>[], grp: string, keys: string[], treeLeafKey: string, mainGrp?: string, mainValue?: any, groups?: string[], allGroups?: string[], groupIndex?: number): Record<string, any>[];
|
|
5
|
+
export declare function index(values: any[], key: string): string;
|
|
6
|
+
export declare function sort(values: any[], key?: string): void;
|
|
7
|
+
export declare function sum(values: any[], key?: string): number;
|
|
8
|
+
export declare function requireVersion(pkg: string, min: string, ver: string, strict?: boolean): boolean;
|
package/package.json
CHANGED
|
@@ -1,99 +1,110 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "chartjs-chart-treemap",
|
|
3
|
-
"homepage": "https://chartjs-chart-treemap.pages.dev/",
|
|
4
|
-
"version": "3.1.0",
|
|
5
|
-
"description": "Chart.js module for creating treemap charts",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "dist/chartjs-chart-treemap.cjs",
|
|
8
|
-
"module": "dist/chartjs-chart-treemap.esm.js",
|
|
9
|
-
"types": "types/index.esm.d.ts",
|
|
10
|
-
"jsdelivr": "dist/chartjs-chart-treemap.min.js",
|
|
11
|
-
"unpkg": "dist/chartjs-chart-treemap.min.js",
|
|
12
|
-
"exports": {
|
|
13
|
-
"types": "./types/index.esm.d.ts",
|
|
14
|
-
"import": "./dist/chartjs-chart-treemap.esm.js",
|
|
15
|
-
"require": "./dist/chartjs-chart-treemap.cjs",
|
|
16
|
-
"script": "./dist/chartjs-chart-treemap.min.js"
|
|
17
|
-
},
|
|
18
|
-
"sideEffects": [
|
|
19
|
-
"dist/chartjs-chart-treemap.cjs",
|
|
20
|
-
"dist/chartjs-chart-treemap.min.js"
|
|
21
|
-
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"autobuild": "rollup -c -w",
|
|
24
|
-
"build": "rollup -c",
|
|
25
|
-
"dev": "karma start ./karma.conf.cjs --no-single-run --auto-watch --browsers chrome",
|
|
26
|
-
"dev:ff": "karma start ./karma.conf.cjs --no-single-run --auto-watch --browsers firefox",
|
|
27
|
-
"docs": "npm run build && vuepress build docs --no-cache",
|
|
28
|
-
"docs:dev": "concurrently \"npm:autobuild\" \"vuepress dev docs --no-cache\"",
|
|
29
|
-
"lint": "concurrently -r \"npm:lint-*\"",
|
|
30
|
-
"lint-js": "eslint \"src/**/*.js\" \"test/**/*.js\" \"docs/**/*.js\"",
|
|
31
|
-
"lint-md": "eslint \"**/*.md\"",
|
|
32
|
-
"lint-types": "eslint \"types/**/*.ts\" && tsc -p types/tests/",
|
|
33
|
-
"test": "cross-env NODE_ENV=test concurrently \"npm:test-*\"",
|
|
34
|
-
"test-lint": "npm run lint",
|
|
35
|
-
"test-types": "tsc -p types/tests/",
|
|
36
|
-
"test-karma": "karma start ./karma.conf.cjs --no-auto-watch --single-run"
|
|
37
|
-
},
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/kurkle/chartjs-chart-treemap.git"
|
|
41
|
-
},
|
|
42
|
-
"keywords": [
|
|
43
|
-
"chart.js",
|
|
44
|
-
"chart",
|
|
45
|
-
"treemap"
|
|
46
|
-
],
|
|
47
|
-
"files": [
|
|
48
|
-
"dist/*",
|
|
49
|
-
"!dist/docs/**",
|
|
50
|
-
"types/index.esm.d.ts"
|
|
51
|
-
],
|
|
52
2
|
"author": "Jukka Kurkela",
|
|
53
|
-
"license": "MIT",
|
|
54
3
|
"bugs": {
|
|
55
4
|
"url": "https://github.com/kurkle/chartjs-chart-treemap/issues"
|
|
56
5
|
},
|
|
6
|
+
"description": "Chart.js module for creating treemap charts",
|
|
57
7
|
"devDependencies": {
|
|
58
|
-
"@
|
|
8
|
+
"@astrojs/check": "^0.9.9",
|
|
9
|
+
"@astrojs/mdx": "^7.0.2",
|
|
10
|
+
"@astrojs/starlight": "^0.41.3",
|
|
11
|
+
"@biomejs/biome": "^2.4.14",
|
|
12
|
+
"@emnapi/core": "^1.11.2",
|
|
13
|
+
"@emnapi/runtime": "^1.11.2",
|
|
14
|
+
"@kurkle/configs": "^1.0.1",
|
|
15
|
+
"@napi-rs/canvas": "^1.0.0",
|
|
16
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
59
17
|
"@rollup/plugin-json": "^6.1.0",
|
|
60
|
-
"@rollup/plugin-node-resolve": "^
|
|
61
|
-
"@rollup/plugin-
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
18
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
19
|
+
"@rollup/plugin-swc": "^0.4.0",
|
|
20
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
21
|
+
"@swc/cli": "^0.8.1",
|
|
22
|
+
"@swc/core": "^1.11.9",
|
|
23
|
+
"@types/jasmine": "^6.0.0",
|
|
24
|
+
"@types/node": "^26.0.0",
|
|
25
|
+
"astro": "^7.0.6",
|
|
26
|
+
"c8": "^11.0.0",
|
|
64
27
|
"chart.js": "^4.0.1",
|
|
65
28
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
66
29
|
"chartjs-plugin-zoom": "^2.0.0",
|
|
67
30
|
"chartjs-test-utils": "^0.5.0",
|
|
68
|
-
"concurrently": "^
|
|
69
|
-
"cross-env": "^
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"eslint-plugin-html": "^7.1.0",
|
|
74
|
-
"eslint-plugin-markdown": "^3.0.0",
|
|
75
|
-
"jasmine-core": "^5.3.0",
|
|
31
|
+
"concurrently": "^10.0.3",
|
|
32
|
+
"cross-env": "^10.1.0",
|
|
33
|
+
"globals": "^17.0.0",
|
|
34
|
+
"jasmine": "^6.2.0",
|
|
35
|
+
"jasmine-core": "^6.3.0",
|
|
76
36
|
"karma": "^6.3.2",
|
|
77
37
|
"karma-chrome-launcher": "^3.1.0",
|
|
78
38
|
"karma-coverage": "^2.0.3",
|
|
79
39
|
"karma-firefox-launcher": "^2.1.0",
|
|
80
40
|
"karma-jasmine": "^5.1.0",
|
|
81
41
|
"karma-jasmine-html-reporter": "^2.0.0",
|
|
82
|
-
"karma-rollup-preprocessor": "7.0.
|
|
42
|
+
"karma-rollup-preprocessor": "^7.0.8",
|
|
83
43
|
"karma-spec-reporter": "^0.0.36",
|
|
84
|
-
"
|
|
85
|
-
"ng-hammerjs": "^2.0.8",
|
|
86
|
-
"pixelmatch": "^6.0.0",
|
|
44
|
+
"pixelmatch": "^7.1.0",
|
|
87
45
|
"rollup": "^4.21.2",
|
|
88
46
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
47
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
89
48
|
"rollup-plugin-istanbul": "^5.0.0",
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"vuepress-plugin-flexsearch": "^0.3.0",
|
|
93
|
-
"vuepress-plugin-redirect": "^1.2.5",
|
|
94
|
-
"vuepress-theme-chartjs": "^0.2.0"
|
|
49
|
+
"semantic-release": "^25.0.3",
|
|
50
|
+
"typescript": "^6.0.3"
|
|
95
51
|
},
|
|
52
|
+
"exports": {
|
|
53
|
+
"import": "./dist/chartjs-chart-treemap.esm.js",
|
|
54
|
+
"require": "./dist/chartjs-chart-treemap.cjs",
|
|
55
|
+
"script": "./dist/chartjs-chart-treemap.min.js",
|
|
56
|
+
"types": "./dist/index.esm.d.ts"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist/*",
|
|
60
|
+
"!dist/docs/**"
|
|
61
|
+
],
|
|
62
|
+
"homepage": "https://chartjs-chart-treemap.pages.dev/",
|
|
63
|
+
"jsdelivr": "dist/chartjs-chart-treemap.min.js",
|
|
64
|
+
"keywords": [
|
|
65
|
+
"chart.js",
|
|
66
|
+
"chart",
|
|
67
|
+
"treemap"
|
|
68
|
+
],
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"main": "dist/chartjs-chart-treemap.cjs",
|
|
71
|
+
"module": "dist/chartjs-chart-treemap.esm.js",
|
|
72
|
+
"name": "chartjs-chart-treemap",
|
|
96
73
|
"peerDependencies": {
|
|
97
74
|
"chart.js": ">=3.0.0"
|
|
98
|
-
}
|
|
75
|
+
},
|
|
76
|
+
"repository": {
|
|
77
|
+
"type": "git",
|
|
78
|
+
"url": "git+https://github.com/kurkle/chartjs-chart-treemap.git"
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"autobuild": "rollup -c -w",
|
|
82
|
+
"build": "rollup -c && tsc -p tsconfig.json --emitDeclarationOnly",
|
|
83
|
+
"dev": "karma start ./karma.conf.cjs --no-single-run --auto-watch --browsers chrome",
|
|
84
|
+
"dev:ff": "karma start ./karma.conf.cjs --no-single-run --auto-watch --browsers firefox",
|
|
85
|
+
"docs": "npm run build && astro build",
|
|
86
|
+
"docs:dev": "npm run build && astro dev",
|
|
87
|
+
"docs:version": "node ./docs/scripts/write-docs-version.cjs",
|
|
88
|
+
"format": "biome check --write",
|
|
89
|
+
"lint": "biome check",
|
|
90
|
+
"predocs": "npm run docs:version",
|
|
91
|
+
"predocs:dev": "npm run docs:version",
|
|
92
|
+
"pretest:unit": "swc --config-file .swcrc-spec src -d build",
|
|
93
|
+
"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",
|
|
94
|
+
"test:fixture": "cross-env NODE_ENV=test karma start ./karma.conf.cjs --no-auto-watch --single-run",
|
|
95
|
+
"test:integration:browser-module": "karma start ./karma.integration.cjs --single-run",
|
|
96
|
+
"test:integration:node-commonjs": "node test/integration/node-commonjs/test.cjs",
|
|
97
|
+
"test:integration:node-module": "node test/integration/node-module/test.mjs",
|
|
98
|
+
"test:unit": "cross-env JASMINE_CONFIG_PATH=jasmine.json c8 --src=src --reporter=text --reporter=lcov -o=coverage/unit jasmine",
|
|
99
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json && tsc -p tsconfig.json --emitDeclarationOnly && tsc --noEmit -p test/types/",
|
|
100
|
+
"typecheck:docs": "astro check"
|
|
101
|
+
},
|
|
102
|
+
"sideEffects": [
|
|
103
|
+
"dist/chartjs-chart-treemap.cjs",
|
|
104
|
+
"dist/chartjs-chart-treemap.min.js"
|
|
105
|
+
],
|
|
106
|
+
"type": "module",
|
|
107
|
+
"types": "dist/index.esm.d.ts",
|
|
108
|
+
"unpkg": "dist/chartjs-chart-treemap.min.js",
|
|
109
|
+
"version": "4.1.0"
|
|
99
110
|
}
|
package/types/index.esm.d.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Chart,
|
|
3
|
-
ChartComponent,
|
|
4
|
-
CoreChartOptions,
|
|
5
|
-
DatasetController,
|
|
6
|
-
Element, VisualElement,
|
|
7
|
-
ScriptableContext, Color, Scriptable, FontSpec
|
|
8
|
-
} from 'chart.js';
|
|
9
|
-
|
|
10
|
-
type AnyObject = Record<string, unknown>;
|
|
11
|
-
|
|
12
|
-
type TreemapScriptableContext = ScriptableContext<'treemap'> & {
|
|
13
|
-
raw: TreemapDataPoint
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type TreemapControllerDatasetCaptionsOptions = {
|
|
17
|
-
align?: Scriptable<LabelAlign, TreemapScriptableContext>,
|
|
18
|
-
color?: Scriptable<Color, TreemapScriptableContext>,
|
|
19
|
-
display?: boolean;
|
|
20
|
-
formatter?: Scriptable<string, TreemapScriptableContext>,
|
|
21
|
-
font?: FontSpec,
|
|
22
|
-
hoverColor?: Scriptable<Color, TreemapScriptableContext>,
|
|
23
|
-
hoverFont?: FontSpec,
|
|
24
|
-
padding?: number,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type TreemapControllerDatasetLabelsOptions = {
|
|
28
|
-
align?: Scriptable<LabelAlign, TreemapScriptableContext>,
|
|
29
|
-
color?: Scriptable<Color | Color[], TreemapScriptableContext>,
|
|
30
|
-
display?: boolean;
|
|
31
|
-
formatter?: Scriptable<string | Array<string>, TreemapScriptableContext>,
|
|
32
|
-
font?: Scriptable<FontSpec | FontSpec[], TreemapScriptableContext>,
|
|
33
|
-
hoverColor?: Scriptable<Color | Color[], TreemapScriptableContext>,
|
|
34
|
-
hoverFont?: Scriptable<FontSpec | FontSpec[], TreemapScriptableContext>,
|
|
35
|
-
overflow?: Scriptable<LabelOverflow, TreemapScriptableContext>
|
|
36
|
-
padding?: number,
|
|
37
|
-
position?: Scriptable<LabelPosition, TreemapScriptableContext>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type LabelPosition = 'top' | 'middle' | 'bottom';
|
|
41
|
-
|
|
42
|
-
export type LabelAlign = 'left' | 'center' | 'right';
|
|
43
|
-
|
|
44
|
-
export type LabelOverflow = 'cut' | 'hidden' | 'fit';
|
|
45
|
-
|
|
46
|
-
type TreemapControllerDatasetDividersOptions = {
|
|
47
|
-
display?: boolean,
|
|
48
|
-
lineCapStyle?: string,
|
|
49
|
-
lineColor?: string,
|
|
50
|
-
lineDash?: number[],
|
|
51
|
-
lineDashOffset?: number,
|
|
52
|
-
lineWidth?: number,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface TreemapControllerDatasetOptions<DType> {
|
|
56
|
-
spacing?: number,
|
|
57
|
-
rtl?: boolean,
|
|
58
|
-
|
|
59
|
-
backgroundColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
60
|
-
borderColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
61
|
-
borderWidth?: number;
|
|
62
|
-
|
|
63
|
-
hoverBackgroundColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
64
|
-
hoverBorderColor?: Scriptable<Color, TreemapScriptableContext>;
|
|
65
|
-
hoverBorderWidth?: number;
|
|
66
|
-
|
|
67
|
-
captions?: TreemapControllerDatasetCaptionsOptions;
|
|
68
|
-
dividers?: TreemapControllerDatasetDividersOptions;
|
|
69
|
-
labels?: TreemapControllerDatasetLabelsOptions;
|
|
70
|
-
label?: string;
|
|
71
|
-
|
|
72
|
-
data: TreemapDataPoint[]; // This will be auto-generated from `tree`
|
|
73
|
-
groups?: Array<keyof DType>;
|
|
74
|
-
sumKeys?: Array<keyof DType>;
|
|
75
|
-
tree: number[] | DType[] | AnyObject;
|
|
76
|
-
treeLeafKey?: keyof DType;
|
|
77
|
-
key?: keyof DType;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface TreemapDataPoint {
|
|
81
|
-
x: number,
|
|
82
|
-
y: number,
|
|
83
|
-
w: number,
|
|
84
|
-
h: number,
|
|
85
|
-
/**
|
|
86
|
-
* Value
|
|
87
|
-
*/
|
|
88
|
-
v: number,
|
|
89
|
-
/**
|
|
90
|
-
* Sum
|
|
91
|
-
*/
|
|
92
|
-
s: number,
|
|
93
|
-
/**
|
|
94
|
-
* Depth, only available if grouping
|
|
95
|
-
*/
|
|
96
|
-
l?: number,
|
|
97
|
-
/**
|
|
98
|
-
* Group name, only available if grouping
|
|
99
|
-
*/
|
|
100
|
-
g?: string,
|
|
101
|
-
/**
|
|
102
|
-
* Group Sum, only available if grouping
|
|
103
|
-
*/
|
|
104
|
-
gs?: number,
|
|
105
|
-
/**
|
|
106
|
-
* additonal keys sums, only available if grouping
|
|
107
|
-
*/
|
|
108
|
-
vs?: AnyObject
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/*
|
|
112
|
-
export interface TreemapInteractionOptions {
|
|
113
|
-
position: Scriptable<"treemap", ScriptableTooltipContext<"treemap">>
|
|
114
|
-
}*/
|
|
115
|
-
|
|
116
|
-
declare module 'chart.js' {
|
|
117
|
-
export interface ChartTypeRegistry {
|
|
118
|
-
treemap: {
|
|
119
|
-
chartOptions: CoreChartOptions<'treemap'>;
|
|
120
|
-
datasetOptions: TreemapControllerDatasetOptions<Record<string, unknown>>;
|
|
121
|
-
defaultDataPoint: TreemapDataPoint;
|
|
122
|
-
metaExtensions: AnyObject;
|
|
123
|
-
parsedDataType: unknown,
|
|
124
|
-
scales: never;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// interface TooltipOptions<TType extends ChartType> extends CoreInteractionOptions, TreemapInteractionOptions {
|
|
129
|
-
// }
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface TreemapOptions {
|
|
133
|
-
backgroundColor: Color;
|
|
134
|
-
borderColor: Color;
|
|
135
|
-
borderWidth: number | { top?: number, right?: number, bottom?: number, left?: number }
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface TreemapConfig {
|
|
139
|
-
x: number;
|
|
140
|
-
y: number;
|
|
141
|
-
width: number;
|
|
142
|
-
height: number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export type TreemapController = DatasetController;
|
|
146
|
-
export const TreemapController: ChartComponent & {
|
|
147
|
-
prototype: TreemapController;
|
|
148
|
-
new(chart: Chart, datasetIndex: number): TreemapController
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export interface TreemapElement<
|
|
152
|
-
T extends TreemapConfig = TreemapConfig,
|
|
153
|
-
O extends TreemapOptions = TreemapOptions
|
|
154
|
-
> extends Element<T, O>, VisualElement {}
|
|
155
|
-
|
|
156
|
-
export const TreemapElement: ChartComponent & {
|
|
157
|
-
prototype: TreemapElement;
|
|
158
|
-
new(cfg: TreemapConfig): TreemapElement
|
|
159
|
-
};
|