chartjs-chart-treemap 3.1.0 → 4.0.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.
@@ -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[]): 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
- "@rollup/plugin-commonjs": "^26.0.1",
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": "^15.0.1",
61
- "@rollup/plugin-terser": "^0.4.4",
62
- "@typescript-eslint/eslint-plugin": "^5.4.0",
63
- "@typescript-eslint/parser": "^5.4.0",
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": "^9.0.0",
69
- "cross-env": "^7.0.3",
70
- "eslint": "^8.3.0",
71
- "eslint-config-chartjs": "^0.3.0",
72
- "eslint-plugin-es": "^4.1.0",
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.7",
42
+ "karma-rollup-preprocessor": "^7.0.8",
83
43
  "karma-spec-reporter": "^0.0.36",
84
- "karma-summary-reporter": "^4.0.1",
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
- "typescript": "^5.6.2",
91
- "vuepress": "^1.9.7",
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.0.0"
99
110
  }
@@ -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
- };