es/no-regexp-s-flag: "error"
es/no-regexp-unicode-property-escapes: "error"
es/no-dynamic-import: "off"
+
+overrides:
+ - files: ['**/*.ts']
+ parser: '@typescript-eslint/parser'
+ plugins:
+ - '@typescript-eslint'
+ extends:
+ - chartjs
+ - plugin:@typescript-eslint/recommended
+
+ rules:
+ # Replace stock eslint rules with typescript-eslint equivalents for proper
+ # TypeScript support.
+ indent: "off"
+ "@typescript-eslint/indent": ["error", 2]
+ no-use-before-define: "off"
+ '@typescript-eslint/no-use-before-define': "error"
+ no-shadow: "off"
+ '@typescript-eslint/no-shadow': "error"
+ space-before-function-paren: "off"
+ '@typescript-eslint/space-before-function-paren': [2, never]
module.exports = [
{
path: 'dist/chart.js',
- limit: '75 KB',
+ limit: '77 KB',
webpack: false,
running: false
},
-import {Chart} from '../types';
+import {Chart} from '../dist/types';
-export * from '../types';
+export * from '../dist/types';
export default Chart;
For example, to provide typings for a new chart type that extends from a bubble chart, you would add a `.d.ts` containing:
-```ts
-import { ChartTypeRegistry } from 'chart.js'
+```typescript
+import { ChartTypeRegistry } from 'chart.js';
declare module 'chart.js' {
interface ChartTypeRegistry {
-export * from '../types/helpers';
+export * from '../dist/helpers/types';
}
if (args.coverage) {
- build.plugins = [
- json(),
- resolve(),
+ build.plugins.push(
istanbul({exclude: ['node_modules/**/*.js', 'package.json']})
- ];
+ );
}
karma.set({
'node_modules/moment-timezone/builds/moment-timezone-with-data.min.js',
{pattern: 'test/index.js', watched: false},
{pattern: 'test/BasicChartWebWorker.js', included: false},
- {pattern: 'src/index.umd.js', watched: false},
+ {pattern: 'src/index.umd.ts', watched: false},
'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js',
{pattern: specPattern}
],
preprocessors: {
'test/index.js': ['rollup'],
- 'src/index.umd.js': ['sources']
+ 'src/index.umd.ts': ['sources']
},
rollupPreprocessor: {
"@rollup/plugin-node-resolve": "^13.3.0",
"@simonbrunel/vuepress-plugin-versions": "^0.2.0",
"@size-limit/preset-big-lib": "^8.0.0",
+ "@swc/core": "^1.2.224",
"@types/estree": "^1.0.0",
"@types/offscreencanvas": "^2019.7.0",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"rollup": "^2.77.2",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-istanbul": "^3.0.0",
+ "rollup-plugin-swc3": "^0.3.0",
"rollup-plugin-terser": "^7.0.2",
"size-limit": "^8.0.0",
"typedoc": "^0.23.10",
"node": ">=10.13.0"
}
},
+ "node_modules/@swc/core": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.224.tgz",
+ "integrity": "sha512-K0B0QKT0eSpPlL4amWJzllYJigQdE7+ha6VQVks6g/oiko1yMYP8lGcCKOKb+KuvW1ltPzlyFqi7h7ryEVG2vQ==",
+ "dev": true,
+ "hasInstallScript": true,
+ "bin": {
+ "swcx": "run_swcx.js"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/swc"
+ },
+ "optionalDependencies": {
+ "@swc/core-android-arm-eabi": "1.2.224",
+ "@swc/core-android-arm64": "1.2.224",
+ "@swc/core-darwin-arm64": "1.2.224",
+ "@swc/core-darwin-x64": "1.2.224",
+ "@swc/core-freebsd-x64": "1.2.224",
+ "@swc/core-linux-arm-gnueabihf": "1.2.224",
+ "@swc/core-linux-arm64-gnu": "1.2.224",
+ "@swc/core-linux-arm64-musl": "1.2.224",
+ "@swc/core-linux-x64-gnu": "1.2.224",
+ "@swc/core-linux-x64-musl": "1.2.224",
+ "@swc/core-win32-arm64-msvc": "1.2.224",
+ "@swc/core-win32-ia32-msvc": "1.2.224",
+ "@swc/core-win32-x64-msvc": "1.2.224"
+ }
+ },
+ "node_modules/@swc/core-android-arm-eabi": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.224.tgz",
+ "integrity": "sha512-viVOYrhSqNxdDOCNu2UUfiAK0qjkmk/fB9mObdSb+48JlHv4kYBnSLjaIhj0NlXCsxgetH7QFbjrKXRJ+gpHqw==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "dependencies": {
+ "@swc/wasm": "1.2.122"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-android-arm64": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.224.tgz",
+ "integrity": "sha512-HCfdnVyslhMX25BDOqE7rOcl3a6QHs34O3xLLY2J/wg2ICtbxehpbpBPrp+VBG3Ngv7VGD9OPhmFgGxElFtZLQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "dependencies": {
+ "@swc/wasm": "1.2.130"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-android-arm64/node_modules/@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ },
+ "node_modules/@swc/core-darwin-arm64": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.224.tgz",
+ "integrity": "sha512-jzv8Eop0GDe4owRDWr02n/xT7Bm6eTFWoM3nFXOM865gNYfASGGm3HHm4z20yndIxq5xuKHcOOH9QXQQhe/lQA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-darwin-x64": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.224.tgz",
+ "integrity": "sha512-hpdJt/BJ45+hcgs461nJxgMJVNN/2uJL8TLvFxeOJiDpF4r1elRxYfDC1W8ctMWB3eB3Wepz3Ku2z8l9UgPnyQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-freebsd-x64": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.224.tgz",
+ "integrity": "sha512-bVIXwwjYA1ZdMKTwrAosxG808nQqvHhzs/fOKUrl1VeZ9CTHA0FzpSXwaBf1shbUVKvQVPKydY0K5q9dkSUkpw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "dependencies": {
+ "@swc/wasm": "1.2.130"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-freebsd-x64/node_modules/@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ },
+ "node_modules/@swc/core-linux-arm-gnueabihf": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.224.tgz",
+ "integrity": "sha512-MY3UQI3IOjME5TpuIhwI0lqKHsU3x7BwlU4n/mLNe2lH3DLaP0rrGHCMI2iJqfiYKU1Rg1r01HXmysuiriF1TA==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "dependencies": {
+ "@swc/wasm": "1.2.130"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-linux-arm-gnueabihf/node_modules/@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ },
+ "node_modules/@swc/core-linux-arm64-gnu": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.224.tgz",
+ "integrity": "sha512-tEpaGq4wp79tR+4s0h8xbzcxW6tZOfb2/Jf1vrmRYfRBqryBRTdtn14Rfy4qlK3s/SC3NfI2MKxZRgcGnMCeWw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-linux-arm64-musl": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.224.tgz",
+ "integrity": "sha512-jnrYqXc7aRzBnEqEp3nAi9tjuUhBnN0pSKiHJytlBP1QkXnH7HD44Da9udmKUFYB5hHpwaXE0NIh7jK0nSMnhw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-linux-x64-gnu": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.224.tgz",
+ "integrity": "sha512-UBkeDlG+PrIXDH1sR4EIXN5qK4a677IHb6RBghbvBDJS61X9/nTDxtCF7/zCqDxJRahhUrT6lDsYpuLCws2hiw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-linux-x64-musl": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.224.tgz",
+ "integrity": "sha512-CQMGDzxKvkzf6TOdaWnmhb6uk1XEhM/mM3BDfX+hx9j3Hg3bFw9qmPvrkoWI2G8J50MvpoR1iPBYyG2LNeQWeg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-win32-arm64-msvc": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.224.tgz",
+ "integrity": "sha512-03V4apubsOhLKQNmfWGlgvDCJkhlh0ZOHcGddxb7bD4PeP6U0lnABG3hlz2uicwcIGBPu/p7jtm5/hezeiXE6Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "dependencies": {
+ "@swc/wasm": "1.2.130"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-win32-arm64-msvc/node_modules/@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ },
+ "node_modules/@swc/core-win32-ia32-msvc": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.224.tgz",
+ "integrity": "sha512-gPOmIdhCwkb5BbDiPs/4t1LIElFLoQwiv45XwK5wADh1qzLD3A8EtpnpXfLsjL/fUMlLIGCgHQ6BQ0x04VrI1Q==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "dependencies": {
+ "@swc/wasm": "1.2.130"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/core-win32-ia32-msvc/node_modules/@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ },
+ "node_modules/@swc/core-win32-x64-msvc": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.224.tgz",
+ "integrity": "sha512-xALNoKi/UAQ2NflIkCBaZ4Nib75a4YwFp2pZ5Yen3vR8hxK2UJYlaNwyfsBwWfMOMsNxQ1Q1aaqoo0L+XON53Q==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/@swc/wasm": {
+ "version": "1.2.122",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.122.tgz",
+ "integrity": "sha512-sM1VCWQxmNhFtdxME+8UXNyPNhxNu7zdb6ikWpz0YKAQQFRGT5ThZgJrubEpah335SUToNg8pkdDF7ibVCjxbQ==",
+ "dev": true,
+ "optional": true
+ },
"node_modules/@szmarczak/http-timer": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
"node": ">=8"
}
},
+ "node_modules/joycon": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
+ "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/js-cleanup": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/js-cleanup/-/js-cleanup-1.2.0.tgz",
"semver": "bin/semver.js"
}
},
+ "node_modules/rollup-plugin-swc3": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-swc3/-/rollup-plugin-swc3-0.3.0.tgz",
+ "integrity": "sha512-ZQK2XxYxSspmT8j6/Y4CaxRxAlZHbNnxI+m+yJ5I87ZLp5uH7CYL4hFlJk1jkcZ+Q2QC19jIg7AClB/7+XFljw==",
+ "dev": true,
+ "dependencies": {
+ "@rollup/pluginutils": "^4.2.1",
+ "deepmerge": "^4.2.2",
+ "joycon": "^3.1.1",
+ "jsonc-parser": "^3.0.0",
+ "typedoc": "^0.22.15"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "peerDependencies": {
+ "@swc/core": ">=1.2.165",
+ "rollup": "^2.0.0"
+ }
+ },
+ "node_modules/rollup-plugin-swc3/node_modules/@rollup/pluginutils": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz",
+ "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==",
+ "dev": true,
+ "dependencies": {
+ "estree-walker": "^2.0.1",
+ "picomatch": "^2.2.2"
+ },
+ "engines": {
+ "node": ">= 8.0.0"
+ }
+ },
+ "node_modules/rollup-plugin-swc3/node_modules/brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "node_modules/rollup-plugin-swc3/node_modules/glob": {
+ "version": "8.0.3",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
+ "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
+ "dev": true,
+ "dependencies": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^5.0.1",
+ "once": "^1.3.0"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/rollup-plugin-swc3/node_modules/minimatch": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
+ "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/rollup-plugin-swc3/node_modules/typedoc": {
+ "version": "0.22.18",
+ "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz",
+ "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==",
+ "dev": true,
+ "dependencies": {
+ "glob": "^8.0.3",
+ "lunr": "^2.3.9",
+ "marked": "^4.0.16",
+ "minimatch": "^5.1.0",
+ "shiki": "^0.10.1"
+ },
+ "bin": {
+ "typedoc": "bin/typedoc"
+ },
+ "engines": {
+ "node": ">= 12.10.0"
+ },
+ "peerDependencies": {
+ "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x || 4.7.x"
+ }
+ },
"node_modules/rollup-plugin-terser": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",
}
}
},
+ "@swc/core": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.224.tgz",
+ "integrity": "sha512-K0B0QKT0eSpPlL4amWJzllYJigQdE7+ha6VQVks6g/oiko1yMYP8lGcCKOKb+KuvW1ltPzlyFqi7h7ryEVG2vQ==",
+ "dev": true,
+ "requires": {
+ "@swc/core-android-arm-eabi": "1.2.224",
+ "@swc/core-android-arm64": "1.2.224",
+ "@swc/core-darwin-arm64": "1.2.224",
+ "@swc/core-darwin-x64": "1.2.224",
+ "@swc/core-freebsd-x64": "1.2.224",
+ "@swc/core-linux-arm-gnueabihf": "1.2.224",
+ "@swc/core-linux-arm64-gnu": "1.2.224",
+ "@swc/core-linux-arm64-musl": "1.2.224",
+ "@swc/core-linux-x64-gnu": "1.2.224",
+ "@swc/core-linux-x64-musl": "1.2.224",
+ "@swc/core-win32-arm64-msvc": "1.2.224",
+ "@swc/core-win32-ia32-msvc": "1.2.224",
+ "@swc/core-win32-x64-msvc": "1.2.224"
+ }
+ },
+ "@swc/core-android-arm-eabi": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.224.tgz",
+ "integrity": "sha512-viVOYrhSqNxdDOCNu2UUfiAK0qjkmk/fB9mObdSb+48JlHv4kYBnSLjaIhj0NlXCsxgetH7QFbjrKXRJ+gpHqw==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "@swc/wasm": "1.2.122"
+ }
+ },
+ "@swc/core-android-arm64": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.224.tgz",
+ "integrity": "sha512-HCfdnVyslhMX25BDOqE7rOcl3a6QHs34O3xLLY2J/wg2ICtbxehpbpBPrp+VBG3Ngv7VGD9OPhmFgGxElFtZLQ==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "@swc/wasm": "1.2.130"
+ },
+ "dependencies": {
+ "@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "@swc/core-darwin-arm64": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.224.tgz",
+ "integrity": "sha512-jzv8Eop0GDe4owRDWr02n/xT7Bm6eTFWoM3nFXOM865gNYfASGGm3HHm4z20yndIxq5xuKHcOOH9QXQQhe/lQA==",
+ "dev": true,
+ "optional": true
+ },
+ "@swc/core-darwin-x64": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.224.tgz",
+ "integrity": "sha512-hpdJt/BJ45+hcgs461nJxgMJVNN/2uJL8TLvFxeOJiDpF4r1elRxYfDC1W8ctMWB3eB3Wepz3Ku2z8l9UgPnyQ==",
+ "dev": true,
+ "optional": true
+ },
+ "@swc/core-freebsd-x64": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.224.tgz",
+ "integrity": "sha512-bVIXwwjYA1ZdMKTwrAosxG808nQqvHhzs/fOKUrl1VeZ9CTHA0FzpSXwaBf1shbUVKvQVPKydY0K5q9dkSUkpw==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "@swc/wasm": "1.2.130"
+ },
+ "dependencies": {
+ "@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "@swc/core-linux-arm-gnueabihf": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.224.tgz",
+ "integrity": "sha512-MY3UQI3IOjME5TpuIhwI0lqKHsU3x7BwlU4n/mLNe2lH3DLaP0rrGHCMI2iJqfiYKU1Rg1r01HXmysuiriF1TA==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "@swc/wasm": "1.2.130"
+ },
+ "dependencies": {
+ "@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "@swc/core-linux-arm64-gnu": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.224.tgz",
+ "integrity": "sha512-tEpaGq4wp79tR+4s0h8xbzcxW6tZOfb2/Jf1vrmRYfRBqryBRTdtn14Rfy4qlK3s/SC3NfI2MKxZRgcGnMCeWw==",
+ "dev": true,
+ "optional": true
+ },
+ "@swc/core-linux-arm64-musl": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.224.tgz",
+ "integrity": "sha512-jnrYqXc7aRzBnEqEp3nAi9tjuUhBnN0pSKiHJytlBP1QkXnH7HD44Da9udmKUFYB5hHpwaXE0NIh7jK0nSMnhw==",
+ "dev": true,
+ "optional": true
+ },
+ "@swc/core-linux-x64-gnu": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.224.tgz",
+ "integrity": "sha512-UBkeDlG+PrIXDH1sR4EIXN5qK4a677IHb6RBghbvBDJS61X9/nTDxtCF7/zCqDxJRahhUrT6lDsYpuLCws2hiw==",
+ "dev": true,
+ "optional": true
+ },
+ "@swc/core-linux-x64-musl": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.224.tgz",
+ "integrity": "sha512-CQMGDzxKvkzf6TOdaWnmhb6uk1XEhM/mM3BDfX+hx9j3Hg3bFw9qmPvrkoWI2G8J50MvpoR1iPBYyG2LNeQWeg==",
+ "dev": true,
+ "optional": true
+ },
+ "@swc/core-win32-arm64-msvc": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.224.tgz",
+ "integrity": "sha512-03V4apubsOhLKQNmfWGlgvDCJkhlh0ZOHcGddxb7bD4PeP6U0lnABG3hlz2uicwcIGBPu/p7jtm5/hezeiXE6Q==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "@swc/wasm": "1.2.130"
+ },
+ "dependencies": {
+ "@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "@swc/core-win32-ia32-msvc": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.224.tgz",
+ "integrity": "sha512-gPOmIdhCwkb5BbDiPs/4t1LIElFLoQwiv45XwK5wADh1qzLD3A8EtpnpXfLsjL/fUMlLIGCgHQ6BQ0x04VrI1Q==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "@swc/wasm": "1.2.130"
+ },
+ "dependencies": {
+ "@swc/wasm": {
+ "version": "1.2.130",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+ "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "@swc/core-win32-x64-msvc": {
+ "version": "1.2.224",
+ "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.224.tgz",
+ "integrity": "sha512-xALNoKi/UAQ2NflIkCBaZ4Nib75a4YwFp2pZ5Yen3vR8hxK2UJYlaNwyfsBwWfMOMsNxQ1Q1aaqoo0L+XON53Q==",
+ "dev": true,
+ "optional": true
+ },
+ "@swc/wasm": {
+ "version": "1.2.122",
+ "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.122.tgz",
+ "integrity": "sha512-sM1VCWQxmNhFtdxME+8UXNyPNhxNu7zdb6ikWpz0YKAQQFRGT5ThZgJrubEpah335SUToNg8pkdDF7ibVCjxbQ==",
+ "dev": true,
+ "optional": true
+ },
"@szmarczak/http-timer": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
}
}
},
+ "joycon": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
+ "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",
+ "dev": true
+ },
"js-cleanup": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/js-cleanup/-/js-cleanup-1.2.0.tgz",
}
}
},
+ "rollup-plugin-swc3": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-swc3/-/rollup-plugin-swc3-0.3.0.tgz",
+ "integrity": "sha512-ZQK2XxYxSspmT8j6/Y4CaxRxAlZHbNnxI+m+yJ5I87ZLp5uH7CYL4hFlJk1jkcZ+Q2QC19jIg7AClB/7+XFljw==",
+ "dev": true,
+ "requires": {
+ "@rollup/pluginutils": "^4.2.1",
+ "deepmerge": "^4.2.2",
+ "joycon": "^3.1.1",
+ "jsonc-parser": "^3.0.0",
+ "typedoc": "^0.22.15"
+ },
+ "dependencies": {
+ "@rollup/pluginutils": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz",
+ "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==",
+ "dev": true,
+ "requires": {
+ "estree-walker": "^2.0.1",
+ "picomatch": "^2.2.2"
+ }
+ },
+ "brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "requires": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "glob": {
+ "version": "8.0.3",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
+ "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^5.0.1",
+ "once": "^1.3.0"
+ }
+ },
+ "minimatch": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
+ "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "^2.0.1"
+ }
+ },
+ "typedoc": {
+ "version": "0.22.18",
+ "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz",
+ "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==",
+ "dev": true,
+ "requires": {
+ "glob": "^8.0.3",
+ "lunr": "^2.3.9",
+ "marked": "^4.0.16",
+ "minimatch": "^5.1.0",
+ "shiki": "^0.10.1"
+ }
+ }
+ }
+ },
"rollup-plugin-terser": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",
"./auto/auto.js",
"./dist/chart.umd.js"
],
- "jsdelivr": "dist/chart.umd.js",
- "unpkg": "dist/chart.umd.js",
- "main": "dist/chart.js",
+ "jsdelivr": "./dist/chart.umd.js",
+ "unpkg": "./dist/chart.umd.js",
+ "main": "./dist/chart.js",
"exports": {
".": "./dist/chart.js",
"./auto": "./auto/auto.js",
"./helpers": "./helpers/helpers.js"
},
- "types": "types/index.d.ts",
+ "types": "./dist/types.d.ts",
"keywords": [
"canvas",
"charts",
],
"scripts": {
"autobuild": "rollup -c -w",
- "build": "rollup -c",
+ "emitDeclarations": "tsc --emitDeclarationOnly",
+ "build": "rollup -c && npm run emitDeclarations",
"dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome --grep",
"dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox --grep",
"docs": "npm run build && vuepress build docs --no-cache",
"docs:dev": "npm run build && vuepress dev docs --no-cache",
- "lint-js": "eslint \"src/**/*.js\" \"test/**/*.js\" \"docs/**/*.js\"",
+ "lint-js": "eslint \"src/**/*.{js,ts}\" \"test/**/*.js\" \"docs/**/*.js\"",
"lint-md": "eslint \"**/*.md\"",
- "lint-tsc": "tsc",
"lint-types": "eslint \"types/**/*.ts\" && npm run build && node types/tests/autogen.js && tsc -p types/tests/",
"lint": "concurrently \"npm:lint-*\"",
"test-size": "size-limit",
"@rollup/plugin-node-resolve": "^13.3.0",
"@simonbrunel/vuepress-plugin-versions": "^0.2.0",
"@size-limit/preset-big-lib": "^8.0.0",
+ "@swc/core": "^1.2.224",
"@types/estree": "^1.0.0",
"@types/offscreencanvas": "^2019.7.0",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"rollup": "^2.77.2",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-istanbul": "^3.0.0",
+ "rollup-plugin-swc3": "^0.3.0",
"rollup-plugin-terser": "^7.0.2",
"size-limit": "^8.0.0",
"typedoc": "^0.23.10",
import cleanup from 'rollup-plugin-cleanup';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
+import {swc} from 'rollup-plugin-swc3';
import {terser} from 'rollup-plugin-terser';
-import { readFileSync } from "fs";
+import {readFileSync} from 'fs';
const {version, homepage} = JSON.parse(readFileSync('./package.json'));
* (c) ${(new Date(process.env.SOURCE_DATE_EPOCH ? (process.env.SOURCE_DATE_EPOCH * 1000) : new Date().getTime())).getFullYear()} Chart.js Contributors
* Released under the MIT License
*/`;
+const extensions = ['.js', '.ts'];
+const plugins = (minify) =>
+ [
+ json(),
+ resolve({
+ extensions
+ }),
+ swc({
+ jsc: {
+ parser: {
+ syntax: 'typescript'
+ },
+ target: 'es2022'
+ },
+ module: {
+ type: 'es6'
+ },
+ sourceMaps: true
+ }),
+ minify
+ ? terser({
+ output: {
+ preamble: banner
+ }
+ })
+ : cleanup({
+ comments: ['some', /__PURE__/]
+ })
+ ];
export default [
// UMD build
// dist/chart.umd.js
{
- input: 'src/index.umd.js',
- plugins: [
- json(),
- resolve(),
- terser({
- output: {
- preamble: banner
- }
- }),
- ],
+ input: 'src/index.umd.ts',
+ plugins: plugins(true),
output: {
name: 'Chart',
file: 'dist/chart.umd.js',
// helpers/*.js
{
input: {
- 'dist/chart': 'src/index.js',
- 'dist/helpers': 'src/helpers/index.js'
+ 'dist/chart': 'src/index.ts',
+ 'dist/helpers': 'src/helpers/index.ts'
},
- plugins: [
- json(),
- resolve(),
- cleanup({
- comments: ['some', /__PURE__/],
- }),
- ],
+ plugins: plugins(),
output: {
dir: './',
chunkFileNames: 'dist/chunks/[name].js',
+++ /dev/null
-/**
- * @namespace Chart._adapters
- * @since 2.8.0
- * @private
- */
-
-/**
- * @typedef { import("../../types").ChartOptions } ChartOptions
- */
-
-/**
- * @return {*}
- */
-function abstract() {
- throw new Error('This method is not implemented: Check that a complete date adapter is provided.');
-}
-
-/**
- * Date adapter (current used by the time scale)
- * @namespace Chart._adapters._date
- * @memberof Chart._adapters
- * @private
- */
-
-/**
- * Currently supported unit string values.
- * @typedef {('millisecond'|'second'|'minute'|'hour'|'day'|'week'|'month'|'quarter'|'year')} Unit
- * @memberof Chart._adapters._date
- */
-
-export class DateAdapter {
-
- static override(members) {
- Object.assign(DateAdapter.prototype, members);
- }
-
- constructor(options) {
- this.options = options || {};
- }
-
- /**
- * Will called with chart options after adapter creation.
- * @param {ChartOptions} chartOptions
- */
- // eslint-disable-next-line no-unused-vars
- init(chartOptions) {}
-
- /**
- * Returns a map of time formats for the supported formatting units defined
- * in Unit as well as 'datetime' representing a detailed date/time string.
- * @returns {{string: string}}
- */
- formats() {
- return abstract();
- }
-
- /**
- * Parses the given `value` and return the associated timestamp.
- * @param {any} value - the value to parse (usually comes from the data)
- * @param {string} [format] - the expected data format
- * @returns {(number|null)}
- */
- parse(value, format) { // eslint-disable-line no-unused-vars
- return abstract();
- }
-
- /**
- * Returns the formatted date in the specified `format` for a given `timestamp`.
- * @param {number} timestamp - the timestamp to format
- * @param {string} format - the date/time token
- * @return {string}
- */
- format(timestamp, format) { // eslint-disable-line no-unused-vars
- return abstract();
- }
-
- /**
- * Adds the specified `amount` of `unit` to the given `timestamp`.
- * @param {number} timestamp - the input timestamp
- * @param {number} amount - the amount to add
- * @param {Unit} unit - the unit as string
- * @return {number}
- */
- add(timestamp, amount, unit) { // eslint-disable-line no-unused-vars
- return abstract();
- }
-
- /**
- * Returns the number of `unit` between the given timestamps.
- * @param {number} a - the input timestamp (reference)
- * @param {number} b - the timestamp to subtract
- * @param {Unit} unit - the unit as string
- * @return {number}
- */
- diff(a, b, unit) { // eslint-disable-line no-unused-vars
- return abstract();
- }
-
- /**
- * Returns start of `unit` for the given `timestamp`.
- * @param {number} timestamp - the input timestamp
- * @param {Unit|'isoWeek'} unit - the unit as string
- * @param {number} [weekday] - the ISO day of the week with 1 being Monday
- * and 7 being Sunday (only needed if param *unit* is `isoWeek`).
- * @return {number}
- */
- startOf(timestamp, unit, weekday) { // eslint-disable-line no-unused-vars
- return abstract();
- }
-
- /**
- * Returns end of `unit` for the given `timestamp`.
- * @param {number} timestamp - the input timestamp
- * @param {Unit|'isoWeek'} unit - the unit as string
- * @return {number}
- */
- endOf(timestamp, unit) { // eslint-disable-line no-unused-vars
- return abstract();
- }
-
-}
-
-export default {
- _date: DateAdapter
-};
--- /dev/null
+/**
+ * @namespace Chart._adapters
+ * @since 2.8.0
+ * @private
+ */
+
+import type {AnyObject} from '../../types/basic';
+import type {ChartOptions} from '../../types';
+
+export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
+
+export interface DateAdapter<T extends AnyObject = AnyObject> {
+ readonly options: T;
+ /**
+ * Will called with chart options after adapter creation.
+ */
+ init(this: DateAdapter<T>, chartOptions: ChartOptions): void;
+ /**
+ * Returns a map of time formats for the supported formatting units defined
+ * in Unit as well as 'datetime' representing a detailed date/time string.
+ */
+ formats(this: DateAdapter<T>): Record<string, string>;
+ /**
+ * Parses the given `value` and return the associated timestamp.
+ * @param value - the value to parse (usually comes from the data)
+ * @param [format] - the expected data format
+ */
+ parse(this: DateAdapter<T>, value: unknown, format?: TimeUnit): number | null;
+ /**
+ * Returns the formatted date in the specified `format` for a given `timestamp`.
+ * @param timestamp - the timestamp to format
+ * @param format - the date/time token
+ */
+ format(this: DateAdapter<T>, timestamp: number, format: TimeUnit): string;
+ /**
+ * Adds the specified `amount` of `unit` to the given `timestamp`.
+ * @param timestamp - the input timestamp
+ * @param amount - the amount to add
+ * @param unit - the unit as string
+ */
+ add(this: DateAdapter<T>, timestamp: number, amount: number, unit: TimeUnit): number;
+ /**
+ * Returns the number of `unit` between the given timestamps.
+ * @param a - the input timestamp (reference)
+ * @param b - the timestamp to subtract
+ * @param unit - the unit as string
+ */
+ diff(this: DateAdapter<T>, a: number, b: number, unit: TimeUnit): number;
+ /**
+ * Returns start of `unit` for the given `timestamp`.
+ * @param timestamp - the input timestamp
+ * @param unit - the unit as string
+ * @param [weekday] - the ISO day of the week with 1 being Monday
+ * and 7 being Sunday (only needed if param *unit* is `isoWeek`).
+ */
+ startOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number;
+ /**
+ * Returns end of `unit` for the given `timestamp`.
+ * @param timestamp - the input timestamp
+ * @param unit - the unit as string
+ */
+ endOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit | 'isoWeek'): number;
+}
+
+function abstract<T = void>(): T {
+ throw new Error('This method is not implemented: Check that a complete date adapter is provided.');
+}
+
+/**
+ * Date adapter (current used by the time scale)
+ * @namespace Chart._adapters._date
+ * @memberof Chart._adapters
+ * @private
+ */
+class DateAdapterBase implements DateAdapter {
+
+ /**
+ * Override default date adapter methods.
+ * Accepts type parameter to define options type.
+ * @example
+ * Chart._adapters._date.override<{myAdapterOption: string}>({
+ * init() {
+ * console.log(this.options.myAdapterOption);
+ * }
+ * })
+ */
+ static override<T extends AnyObject = AnyObject>(
+ members: Partial<Omit<DateAdapter<T>, 'options'>>
+ ) {
+ Object.assign(DateAdapterBase.prototype, members);
+ }
+
+ readonly options: AnyObject;
+
+ constructor(options: AnyObject) {
+ this.options = options || {};
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ init() {}
+
+ formats(): Record<string, string> {
+ return abstract();
+ }
+
+ parse(): number | null {
+ return abstract();
+ }
+
+ format(): string {
+ return abstract();
+ }
+
+ add(): number {
+ return abstract();
+ }
+
+ diff(): number {
+ return abstract();
+ }
+
+ startOf(): number {
+ return abstract();
+ }
+
+ endOf(): number {
+ return abstract();
+ }
+}
+
+export default {
+ _date: DateAdapterBase
+};
+++ /dev/null
-import {isNumber} from '../helpers/helpers.math';
-
-export default class Element {
-
- /**
- * @type any
- */
- static defaults = {};
-
- /**
- * @type any
- */
- static defaultRoutes = undefined;
-
- constructor() {
- this.x = undefined;
- this.y = undefined;
- this.active = false;
- this.options = undefined;
- this.$animations = undefined;
- }
-
- /**
- * @param {boolean} [useFinalPosition]
- */
- tooltipPosition(useFinalPosition) {
- const {x, y} = this.getProps(['x', 'y'], useFinalPosition);
- return {x, y};
- }
-
- hasValue() {
- return isNumber(this.x) && isNumber(this.y);
- }
-
- /**
- * Gets the current or final value of each prop. Can return extra properties (whole object).
- * @param {string[]} props - properties to get
- * @param {boolean} [final] - get the final value (animation target)
- * @return {object}
- */
- getProps(props, final) {
- const anims = this.$animations;
- if (!final || !anims) {
- // let's not create an object, if not needed
- return this;
- }
- const ret = {};
- props.forEach(prop => {
- ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : this[prop];
- });
- return ret;
- }
-}
--- /dev/null
+import type {AnyObject} from '../../types/basic';
+import type {Point} from '../../types/geometric';
+import type {Animation} from '../../types/animation';
+import {isNumber} from '../helpers/helpers.math';
+
+export default class Element<T extends AnyObject = AnyObject, O extends AnyObject = AnyObject> {
+
+ static defaults = {};
+ static defaultRoutes = undefined;
+
+ x: number;
+ y: number;
+ active = false;
+ options: O;
+ $animations: Record<keyof T, Animation>;
+
+ tooltipPosition(useFinalPosition: boolean): Point {
+ const {x, y} = this.getProps(['x', 'y'], useFinalPosition);
+ return {x, y} as Point;
+ }
+
+ hasValue() {
+ return isNumber(this.x) && isNumber(this.y);
+ }
+
+ /**
+ * Gets the current or final value of each prop. Can return extra properties (whole object).
+ * @param props - properties to get
+ * @param [final] - get the final value (animation target)
+ */
+ getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]> {
+ const anims = this.$animations;
+ if (!final || !anims) {
+ // let's not create an object, if not needed
+ return this as Pick<T, P[number]>;
+ }
+ const ret: Partial<Pick<T, P[number]>> = {};
+ props.forEach((prop) => {
+ ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : this[prop as string];
+ });
+ return ret as Pick<T, P[number]>;
+ }
+}
* @return {string|string[]} the label to display
*/
values(value) {
- return isArray(value) ? value : '' + value;
+ return isArray(value) ? /** @type {string[]} */ (value) : '' + value;
},
/**
+export type {DateAdapter, TimeUnit} from './core.adapters';
export {default as _adapters} from './core.adapters';
export {default as Animation} from './core.animation';
export {default as Animations} from './core.animations';
import {PI, _isBetween, _limitValue} from '../helpers/helpers.math';
import {_readValueToProps} from '../helpers/helpers.options';
+/** @typedef {{ x: number, y: number, startAngle: number, endAngle: number, innerRadius: number, outerRadius: number, circumference: number }} ArcProps */
+
function clipArc(ctx, element, endAngle) {
const {startAngle, pixelMargin, x, y, outerRadius, innerRadius} = element;
let angleMargin = pixelMargin / outerRadius;
inRange(chartX, chartY, useFinalPosition) {
const point = this.getProps(['x', 'y'], useFinalPosition);
const {angle, distance} = getAngleFromPoint(point, {x: chartX, y: chartY});
- const {startAngle, endAngle, innerRadius, outerRadius, circumference} = this.getProps([
+ const {startAngle, endAngle, innerRadius, outerRadius, circumference} = /** @type {ArcProps} */ (this.getProps([
'startAngle',
'endAngle',
'innerRadius',
'outerRadius',
'circumference'
- ], useFinalPosition);
+ ], useFinalPosition));
const rAdjust = this.options.spacing / 2;
const _circumference = valueOrDefault(circumference, endAngle - startAngle);
const betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle);
* @param {boolean} [useFinalPosition]
*/
getCenterPoint(useFinalPosition) {
- const {x, y, startAngle, endAngle, innerRadius, outerRadius} = this.getProps([
+ const {x, y, startAngle, endAngle, innerRadius, outerRadius} = /** @type {ArcProps} */ (this.getProps([
'x',
'y',
'startAngle',
'innerRadius',
'outerRadius',
'circumference',
- ], useFinalPosition);
+ ], useFinalPosition));
const {offset, spacing} = this.options;
const halfAngle = (startAngle + endAngle) / 2;
const halfRadius = (innerRadius + outerRadius + spacing + offset) / 2;
import {addRoundedRectPath} from '../helpers/helpers.canvas';
import {toTRBL, toTRBLCorners} from '../helpers/helpers.options';
+/** @typedef {{ x: number, y: number, base: number, horizontal: boolean, width: number, height: number }} BarProps */
+
/**
* Helper function to get the bounds of the bar regardless of the orientation
* @param {BarElement} bar the bar
* @private
*/
function getBarBounds(bar, useFinalPosition) {
- const {x, y, base, width, height} = bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition);
+ const {x, y, base, width, height} = /** @type {BarProps} */ (bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition));
let left, right, top, bottom, half;
}
getCenterPoint(useFinalPosition) {
- const {x, y, base, horizontal} = this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition);
+ const {x, y, base, horizontal} = /** @type {BarProps} */ (this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition));
return {
x: horizontal ? (x + base) / 2 : x,
y: horizontal ? y : (y + base) / 2
inRange(mouseX, mouseY, useFinalPosition) {
const options = this.options;
- const {x, y} = this.getProps(['x', 'y'], useFinalPosition);
+ const {x, y} = /** @type {{ x: number, y: number }} */ (this.getProps(['x', 'y'], useFinalPosition));
return ((Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2)) < Math.pow(options.hitRadius + options.radius, 2));
}
/**
* @namespace Chart.helpers
*/
+
+import type {AnyObject} from '../../types/basic';
+import type {ActiveDataPoint, ChartEvent} from '../../types';
+
/**
* An empty function that can be used, for example, for optional callback.
*/
-export function noop() {}
+export function noop() {
+ /* noop */
+}
/**
* Returns a unique id, sequentially generated from a global variable.
- * @returns {number}
- * @function
*/
-export const uid = (function() {
+export const uid = (() => {
let id = 0;
- return function() {
- return id++;
- };
-}());
+ return () => id++;
+})();
/**
* Returns true if `value` is neither null nor undefined, else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
+ * @param value - The value to test.
* @since 2.7.0
*/
-export function isNullOrUndef(value) {
+export function isNullOrUndef(value: unknown): value is null | undefined {
return value === null || typeof value === 'undefined';
}
/**
* Returns true if `value` is an array (including typed arrays), else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
+ * @param value - The value to test.
* @function
*/
-export function isArray(value) {
+export function isArray<T = unknown>(value: unknown): value is T[] {
if (Array.isArray && Array.isArray(value)) {
return true;
}
/**
* Returns true if `value` is an object (excluding null), else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
+ * @param value - The value to test.
* @since 2.7.0
*/
-export function isObject(value) {
+export function isObject(value: unknown): value is AnyObject {
return value !== null && Object.prototype.toString.call(value) === '[object Object]';
}
/**
* Returns true if `value` is a finite number, else returns false
- * @param {*} value - The value to test.
- * @returns {boolean}
+ * @param value - The value to test.
*/
-const isNumberFinite = (value) => (typeof value === 'number' || value instanceof Number) && isFinite(+value);
+function isNumberFinite(value: unknown): value is number {
+ return (typeof value === 'number' || value instanceof Number) && isFinite(+value);
+}
export {
isNumberFinite as isFinite,
};
/**
* Returns `value` if finite, else returns `defaultValue`.
- * @param {*} value - The value to return if defined.
- * @param {*} defaultValue - The value to return if `value` is not finite.
- * @returns {*}
+ * @param value - The value to return if defined.
+ * @param defaultValue - The value to return if `value` is not finite.
*/
-export function finiteOrDefault(value, defaultValue) {
+export function finiteOrDefault(value: unknown, defaultValue: number) {
return isNumberFinite(value) ? value : defaultValue;
}
/**
* Returns `value` if defined, else returns `defaultValue`.
- * @param {*} value - The value to return if defined.
- * @param {*} defaultValue - The value to return if `value` is undefined.
- * @returns {*}
+ * @param value - The value to return if defined.
+ * @param defaultValue - The value to return if `value` is undefined.
*/
-export function valueOrDefault(value, defaultValue) {
+export function valueOrDefault<T>(value: T | undefined, defaultValue: T) {
return typeof value === 'undefined' ? defaultValue : value;
}
-export const toPercentage = (value, dimension) =>
+export const toPercentage = (value: number | string, dimension: number) =>
typeof value === 'string' && value.endsWith('%') ?
parseFloat(value) / 100
- : value / dimension;
+ : +value / dimension;
-export const toDimension = (value, dimension) =>
+export const toDimension = (value: number | string, dimension: number) =>
typeof value === 'string' && value.endsWith('%') ?
parseFloat(value) / 100 * dimension
: +value;
/**
* Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
* value returned by `fn`. If `fn` is not a function, this method returns undefined.
- * @param {function} fn - The function to call.
- * @param {Array|undefined|null} args - The arguments with which `fn` should be called.
- * @param {object} [thisArg] - The value of `this` provided for the call to `fn`.
- * @returns {*}
+ * @param fn - The function to call.
+ * @param args - The arguments with which `fn` should be called.
+ * @param [thisArg] - The value of `this` provided for the call to `fn`.
*/
-export function callback(fn, args, thisArg) {
+export function callback<T extends (this: TA, ...restArgs: unknown[]) => R, TA, R>(
+ fn: T | undefined,
+ args: unknown[],
+ thisArg?: TA
+): R | undefined {
if (fn && typeof fn.call === 'function') {
return fn.apply(thisArg, args);
}
* Note(SB) for performance sake, this method should only be used when loopable type
* is unknown or in none intensive code (not called often and small loopable). Else
* it's preferable to use a regular for() loop and save extra function calls.
- * @param {object|Array} loopable - The object or array to be iterated.
- * @param {function} fn - The function to call for each item.
- * @param {object} [thisArg] - The value of `this` provided for the call to `fn`.
- * @param {boolean} [reverse] - If true, iterates backward on the loopable.
+ * @param loopable - The object or array to be iterated.
+ * @param fn - The function to call for each item.
+ * @param [thisArg] - The value of `this` provided for the call to `fn`.
+ * @param [reverse] - If true, iterates backward on the loopable.
*/
-export function each(loopable, fn, thisArg, reverse) {
- let i, len, keys;
+export function each<T, TA>(
+ loopable: Record<string, T>,
+ fn: (this: TA, v: T, i: string) => void,
+ thisArg?: TA,
+ reverse?: boolean
+): void;
+export function each<T, TA>(
+ loopable: T[],
+ fn: (this: TA, v: T, i: number) => void,
+ thisArg?: TA,
+ reverse?: boolean
+): void;
+export function each<T, TA>(
+ loopable: T[] | Record<string, T>,
+ fn: (this: TA, v: T, i: any) => void,
+ thisArg?: TA,
+ reverse?: boolean
+) {
+ let i: number, len: number, keys: string[];
if (isArray(loopable)) {
len = loopable.length;
if (reverse) {
/**
* Returns true if the `a0` and `a1` arrays have the same content, else returns false.
- * @param {Array} a0 - The array to compare
- * @param {Array} a1 - The array to compare
- * @returns {boolean}
+ * @param a0 - The array to compare
+ * @param a1 - The array to compare
* @private
*/
-export function _elementsEqual(a0, a1) {
- let i, ilen, v0, v1;
+export function _elementsEqual(a0: ActiveDataPoint[], a1: ActiveDataPoint[]) {
+ let i: number, ilen: number, v0: ActiveDataPoint, v1: ActiveDataPoint;
if (!a0 || !a1 || a0.length !== a1.length) {
return false;
/**
* Returns a deep copy of `source` without keeping references on objects and arrays.
- * @param {*} source - The value to clone.
- * @returns {*}
+ * @param source - The value to clone.
*/
-export function clone(source) {
+export function clone<T>(source: T): T {
if (isArray(source)) {
- return source.map(clone);
+ return source.map(clone) as unknown as T;
}
if (isObject(source)) {
return source;
}
-function isValidKey(key) {
+function isValidKey(key: string) {
return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1;
}
* Note(SB): also used by mergeConfig and mergeScaleConfig as fallback.
* @private
*/
-export function _merger(key, target, source, options) {
+export function _merger(key: string, target: AnyObject, source: AnyObject, options: AnyObject) {
if (!isValidKey(key)) {
return;
}
const sval = source[key];
if (isObject(tval) && isObject(sval)) {
- // eslint-disable-next-line no-use-before-define
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
merge(tval, sval, options);
} else {
target[key] = clone(sval);
}
}
+export interface MergeOptions {
+ merger?: (key: string, target: AnyObject, source: AnyObject, options?: AnyObject) => void;
+}
+
/**
* Recursively deep copies `source` properties into `target` with the given `options`.
* IMPORTANT: `target` is not cloned and will be updated with `source` properties.
- * @param {object} target - The target object in which all sources are merged into.
- * @param {object|object[]} source - Object(s) to merge into `target`.
- * @param {object} [options] - Merging options:
- * @param {function} [options.merger] - The merge method (key, target, source, options)
- * @returns {object} The `target` object.
+ * @param target - The target object in which all sources are merged into.
+ * @param source - Object(s) to merge into `target`.
+ * @param [options] - Merging options:
+ * @param [options.merger] - The merge method (key, target, source, options)
+ * @returns The `target` object.
*/
-export function merge(target, source, options) {
+export function merge<T>(target: T, source: [], options?: MergeOptions): T;
+export function merge<T, S1>(target: T, source: S1, options?: MergeOptions): T & S1;
+export function merge<T, S1>(target: T, source: [S1], options?: MergeOptions): T & S1;
+export function merge<T, S1, S2>(target: T, source: [S1, S2], options?: MergeOptions): T & S1 & S2;
+export function merge<T, S1, S2, S3>(target: T, source: [S1, S2, S3], options?: MergeOptions): T & S1 & S2 & S3;
+export function merge<T, S1, S2, S3, S4>(
+ target: T,
+ source: [S1, S2, S3, S4],
+ options?: MergeOptions
+): T & S1 & S2 & S3 & S4;
+export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject;
+export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject {
const sources = isArray(source) ? source : [source];
const ilen = sources.length;
if (!isObject(target)) {
- return target;
+ return target as AnyObject;
}
options = options || {};
const merger = options.merger || _merger;
+ let current: AnyObject;
for (let i = 0; i < ilen; ++i) {
- source = sources[i];
- if (!isObject(source)) {
+ current = sources[i];
+ if (!isObject(current)) {
continue;
}
- const keys = Object.keys(source);
+ const keys = Object.keys(current);
for (let k = 0, klen = keys.length; k < klen; ++k) {
- merger(keys[k], target, source, options);
+ merger(keys[k], target, current, options as AnyObject);
}
}
/**
* Recursively deep copies `source` properties into `target` *only* if not defined in target.
* IMPORTANT: `target` is not cloned and will be updated with `source` properties.
- * @param {object} target - The target object in which all sources are merged into.
- * @param {object|object[]} source - Object(s) to merge into `target`.
- * @returns {object} The `target` object.
+ * @param target - The target object in which all sources are merged into.
+ * @param source - Object(s) to merge into `target`.
+ * @returns The `target` object.
*/
-export function mergeIf(target, source) {
- // eslint-disable-next-line no-use-before-define
- return merge(target, source, {merger: _mergerIf});
+export function mergeIf<T>(target: T, source: []): T;
+export function mergeIf<T, S1>(target: T, source: S1): T & S1;
+export function mergeIf<T, S1>(target: T, source: [S1]): T & S1;
+export function mergeIf<T, S1, S2>(target: T, source: [S1, S2]): T & S1 & S2;
+export function mergeIf<T, S1, S2, S3>(target: T, source: [S1, S2, S3]): T & S1 & S2 & S3;
+export function mergeIf<T, S1, S2, S3, S4>(target: T, source: [S1, S2, S3, S4]): T & S1 & S2 & S3 & S4;
+export function mergeIf<T>(target: T, source: AnyObject[]): AnyObject;
+export function mergeIf<T>(target: T, source: AnyObject[]): AnyObject {
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
+ return merge<T>(target, source, {merger: _mergerIf});
}
/**
* Merges source[key] in target[key] only if target[key] is undefined.
* @private
*/
-export function _mergerIf(key, target, source) {
+export function _mergerIf(key: string, target: AnyObject, source: AnyObject) {
if (!isValidKey(key)) {
return;
}
/**
* @private
*/
-export function _deprecated(scope, value, previous, current) {
+export function _deprecated(scope: string, value: unknown, previous: string, current: string) {
if (value !== undefined) {
console.warn(scope + ': "' + previous +
- '" is deprecated. Please use "' + current + '" instead');
+ '" is deprecated. Please use "' + current + '" instead');
}
}
y: o => o.y
};
-export function resolveObjectKey(obj, key) {
- const resolver = keyResolvers[key] || (keyResolvers[key] = _getKeyResolver(key));
- return resolver(obj);
+/**
+ * @private
+ */
+export function _splitKey(key: string) {
+ const parts = key.split('.');
+ const keys: string[] = [];
+ let tmp = '';
+ for (const part of parts) {
+ tmp += part;
+ if (tmp.endsWith('\\')) {
+ tmp = tmp.slice(0, -1) + '.';
+ } else {
+ keys.push(tmp);
+ tmp = '';
+ }
+ }
+ return keys;
}
-function _getKeyResolver(key) {
+function _getKeyResolver(key: string) {
const keys = _splitKey(key);
return obj => {
for (const k of keys) {
};
}
-/**
- * @private
- */
-export function _splitKey(key) {
- const parts = key.split('.');
- const keys = [];
- let tmp = '';
- for (const part of parts) {
- tmp += part;
- if (tmp.endsWith('\\')) {
- tmp = tmp.slice(0, -1) + '.';
- } else {
- keys.push(tmp);
- tmp = '';
- }
- }
- return keys;
+export function resolveObjectKey(obj: AnyObject, key: string): AnyObject {
+ const resolver = keyResolvers[key] || (keyResolvers[key] = _getKeyResolver(key));
+ return resolver(obj);
}
/**
* @private
*/
-export function _capitalize(str) {
+export function _capitalize(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
-export const defined = (value) => typeof value !== 'undefined';
+export const defined = (value: unknown) => typeof value !== 'undefined';
-export const isFunction = (value) => typeof value === 'function';
+export const isFunction = (value: unknown) => typeof value === 'function';
// Adapted from https://stackoverflow.com/questions/31128855/comparing-ecma6-sets-for-equality#31129384
-export const setsEqual = (a, b) => {
+export const setsEqual = <T>(a: Set<T>, b: Set<T>) => {
if (a.size !== b.size) {
return false;
}
};
/**
- * @param {import('../../types').ChartEvent} e - The event
- * @returns {boolean}
+ * @param e - The event
* @private
*/
-export function _isClickEvent(e) {
+export function _isClickEvent(e: ChartEvent) {
return e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu';
}
const numberOrZero = v => +v || 0;
+/**
+ * @param {any} value
+ * @param {string[] | Record<string, string>} props
+ */
export function _readValueToProps(value, props) {
const ret = {};
const objProps = isObject(props);
--- /dev/null
+/**
+ * Temporary entry point of the types at the time of the transition.
+ * After transition done need to remove it in favor of index.ts
+ */
+
+// export * from '.';
+export * from './helpers.core';
+export * from '../../types/helpers';
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
/**
*/
import Chart from './core/core.controller';
-import * as helpers from './helpers/index';
+import * as helpers from './helpers';
import _adapters from './core/core.adapters';
import Animation from './core/core.animation';
import animator from './core/core.animator';
}
export default Chart;
+
* @param {number} count
*/
export function _decodeFill(line, index, count) {
+ /** @type {string | {value: number}} */
const fill = parseFillOption(line);
if (isObject(fill)) {
* @typedef { import("../platform/platform.base").Chart } Chart
* @typedef { import("../../types").ChartEvent } ChartEvent
* @typedef { import("../../types").ActiveElement } ActiveElement
+ * @typedef { import("../core/core.interaction").InteractionItem } InteractionItem
*/
const positioners = {
/**
* Helper for determining the active elements for event
* @param {ChartEvent} e - The event to handle
- * @param {Element[]} lastActive - Previously active elements
+ * @param {InteractionItem[]} lastActive - Previously active elements
* @param {boolean} [replay] - This is a replayed event (from update)
* @param {boolean} [inChartArea] - The event is inside chartArea
- * @returns {Element[]} - Active elements
+ * @returns {InteractionItem[]} - Active elements
* @private
*/
_getActiveElements(e, lastActive, replay, inChartArea) {
import {_arrayUnique, _filterBetween, _lookup} from '../helpers/helpers.collection';
/**
- * @typedef { import("../core/core.adapters").Unit } Unit
+ * @typedef { import("../core/core.adapters").TimeUnit } Unit
* @typedef {{common: boolean, size: number, steps?: number}} Interval
+ * @typedef { import("../core/core.adapters").DateAdapter } DateAdapter
*/
/**
// Only parse if its not a timestamp already
if (!isFinite(value)) {
value = typeof parser === 'string'
- ? adapter.parse(value, parser)
+ ? adapter.parse(value, /** @type {Unit} */ (parser))
: adapter.parse(value);
}
init(scaleOpts, opts) {
const time = scaleOpts.time || (scaleOpts.time = {});
+ /** @type {DateAdapter} */
const adapter = this._adapter = new adapters._date(scaleOpts.adapters.date);
adapter.init(opts);
--- /dev/null
+/**
+ * Temporary entry point of the types at the time of the transition.
+ * After transition done need to remove it in favor of index.ts
+ */
+
+export * from '.';
+/**
+ * Explicitly re-exporting to resolve the ambiguity.
+ */
+export {
+ BarController,
+ BubbleController,
+ DoughnutController,
+ LineController,
+ PieController,
+ PolarAreaController,
+ RadarController,
+ ScatterController,
+ Animation,
+ Animations,
+ Chart,
+ DatasetController,
+ Interaction,
+ Scale,
+ Ticks,
+ defaults,
+ layouts,
+ registry,
+ ArcElement,
+ BarElement,
+ LineElement,
+ PointElement,
+ BasePlatform,
+ BasicPlatform,
+ DomPlatform,
+ Decimation,
+ Filler,
+ Legend,
+ SubTitle,
+ Title,
+ Tooltip,
+ CategoryScale,
+ LinearScale,
+ LogarithmicScale,
+ RadialLinearScale,
+ TimeScale,
+ TimeSeriesScale,
+ registerables
+} from '../types';
+export * from '../types';
{
"compilerOptions": {
- "target": "ES6",
- "moduleResolution": "Node",
- "allowSyntheticDefaultImports": true,
- "allowJs": true,
- "checkJs": true,
- "noEmit": true,
+ /* Type Checking */
"alwaysStrict": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
+ /* todo: uncomment after transition to TS */
+ // "noFallthroughCasesInSwitch": true,
+ // "noImplicitOverride": true,
+ // "noImplicitReturns": true,
+ // "noUnusedLocals": true,
+ // "noUnusedParameters": true,
+ /* Modules */
+ "moduleResolution": "Node",
"types": ["offscreencanvas"],
- "lib": ["es2018", "DOM"]
+ /* Emit */
+ "declaration": true,
+ "outDir": "dist",
+ /* JavaScript Support */
+ "allowJs": true,
+ "checkJs": true,
+ /* Interop Constraints */
+ "allowSyntheticDefaultImports": true,
+ /* Language and Environment */
+ "target": "ES6",
+ "lib": ["es2018", "DOM"],
+ /* Completeness */
+ "skipLibCheck": true
},
"typedocOptions": {
"name": "Chart.js",
"out": "./dist/docs/typedoc"
},
"include": [
- "./src/**/*.js",
+ "./src/**/*",
"./types"
],
"exclude": [
-parser: '@typescript-eslint/parser'
-
-plugins:
- - '@typescript-eslint'
-
-extends:
- - chartjs
- - plugin:@typescript-eslint/recommended
-
rules:
- # Replace stock eslint rules with typescript-eslint equivalents for proper
- # TypeScript support.
- indent: "off"
- "@typescript-eslint/indent": ["error", 2]
- no-use-before-define: "off"
- '@typescript-eslint/no-use-before-define': "error"
- no-shadow: "off"
- '@typescript-eslint/no-shadow': "error"
-
# These rules were set to warning to make the linting pass initially,
# without making any major changes to types.
object-curly-spacing: ["warn", "always"]
+++ /dev/null
-import type { ChartOptions } from '.';
-
-export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
-
-export interface DateAdapter {
- // Override one or multiple of the methods to adjust to the logic of the current date library.
- override(members: Partial<DateAdapter>): void;
- readonly options: unknown;
-
- /**
- * Will called with chart options after adapter creation.
- * @param {ChartOptions} chartOptions
- */
- init(chartOptions: ChartOptions): void;
- /**
- * Returns a map of time formats for the supported formatting units defined
- * in Unit as well as 'datetime' representing a detailed date/time string.
- * @returns {{string: string}}
- */
- formats(): { [key: string]: string };
- /**
- * Parses the given `value` and return the associated timestamp.
- * @param {unknown} value - the value to parse (usually comes from the data)
- * @param {string} [format] - the expected data format
- */
- parse(value: unknown, format?: TimeUnit): number | null;
- /**
- * Returns the formatted date in the specified `format` for a given `timestamp`.
- * @param {number} timestamp - the timestamp to format
- * @param {string} format - the date/time token
- * @return {string}
- */
- format(timestamp: number, format: TimeUnit): string;
- /**
- * Adds the specified `amount` of `unit` to the given `timestamp`.
- * @param {number} timestamp - the input timestamp
- * @param {number} amount - the amount to add
- * @param {Unit} unit - the unit as string
- * @return {number}
- */
- add(timestamp: number, amount: number, unit: TimeUnit): number;
- /**
- * Returns the number of `unit` between the given timestamps.
- * @param {number} a - the input timestamp (reference)
- * @param {number} b - the timestamp to subtract
- * @param {Unit} unit - the unit as string
- * @return {number}
- */
- diff(a: number, b: number, unit: TimeUnit): number;
- /**
- * Returns start of `unit` for the given `timestamp`.
- * @param {number} timestamp - the input timestamp
- * @param {Unit|'isoWeek'} unit - the unit as string
- * @param {number} [weekday] - the ISO day of the week with 1 being Monday
- * and 7 being Sunday (only needed if param *unit* is `isoWeek`).
- * @return {number}
- */
- startOf(timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number;
- /**
- * Returns end of `unit` for the given `timestamp`.
- * @param {number} timestamp - the input timestamp
- * @param {Unit|'isoWeek'} unit - the unit as string
- * @return {number}
- */
- endOf(timestamp: number, unit: TimeUnit | 'isoWeek'): number;
-}
-
-export const _adapters: {
- _date: DateAdapter;
-};
import { Chart } from '.';
import { AnyObject } from './basic';
-export class Animation {
+export declare class Animation {
constructor(cfg: AnyObject, target: AnyObject, prop: string, to?: unknown);
active(): boolean;
update(cfg: AnyObject, to: unknown, date: number): void;
cancel(): void;
tick(date: number): void;
+ readonly _to: unknown;
}
export interface AnimationEvent {
currentStep: number;
}
-export class Animator {
+export declare class Animator {
listen(chart: Chart, event: 'complete' | 'progress', cb: (event: AnimationEvent) => void): void;
add(chart: Chart, items: readonly Animation[]): void;
has(chart: Chart): boolean;
remove(chart: Chart): boolean;
}
-export class Animations {
+export declare class Animations {
constructor(chart: Chart, animations: AnyObject);
configure(animations: AnyObject): void;
update(target: AnyObject, values: AnyObject): undefined | boolean;
+++ /dev/null
-import { AnyObject } from './basic';
-import { Point } from './geometric';
-
-export interface Element<T = AnyObject, O = AnyObject> {
- readonly x: number;
- readonly y: number;
- readonly active: boolean;
- readonly options: O;
-
- tooltipPosition(useFinalPosition?: boolean): Point;
- hasValue(): boolean;
- getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]>;
-}
-export const Element: {
- prototype: Element;
- new <T = AnyObject, O = AnyObject>(): Element<T, O>;
-};
+++ /dev/null
-import { AnyObject } from '../basic';
-
-/**
- * An empty function that can be used, for example, for optional callback.
- */
-export function noop(): void;
-
-/**
- * Returns a unique id, sequentially generated from a global variable.
- * @returns {number}
- * @function
- */
-export function uid(): number;
-/**
- * Returns true if `value` is neither null nor undefined, else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
- * @since 2.7.0
- */
-export function isNullOrUndef(value: unknown): value is null | undefined;
-/**
- * Returns true if `value` is an array (including typed arrays), else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
- * @function
- */
-export function isArray<T = unknown>(value: unknown): value is ArrayLike<T>;
-/**
- * Returns true if `value` is an object (excluding null), else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
- * @since 2.7.0
- */
-export function isObject(value: unknown): value is AnyObject;
-/**
- * Returns true if `value` is a finite number, else returns false
- * @param {*} value - The value to test.
- * @returns {boolean}
- */
-export function isFinite(value: unknown): value is number;
-
-/**
- * Returns `value` if finite, else returns `defaultValue`.
- * @param {*} value - The value to return if defined.
- * @param {*} defaultValue - The value to return if `value` is not finite.
- * @returns {*}
- */
-export function finiteOrDefault(value: unknown, defaultValue: number): number;
-
-/**
- * Returns `value` if defined, else returns `defaultValue`.
- * @param {*} value - The value to return if defined.
- * @param {*} defaultValue - The value to return if `value` is undefined.
- * @returns {*}
- */
-export function valueOrDefault<T>(value: T | undefined, defaultValue: T): T;
-
-export function toPercentage(value: number | string, dimesion: number): number;
-export function toDimension(value: number | string, dimension: number): number;
-
-/**
- * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
- * value returned by `fn`. If `fn` is not a function, this method returns undefined.
- * @param fn - The function to call.
- * @param args - The arguments with which `fn` should be called.
- * @param [thisArg] - The value of `this` provided for the call to `fn`.
- * @returns {*}
- */
-export function callback<T extends (this: TA, ...args: unknown[]) => R, TA, R>(
- fn: T | undefined,
- args: unknown[],
- thisArg?: TA
-): R | undefined;
-
-/**
- * Note(SB) for performance sake, this method should only be used when loopable type
- * is unknown or in none intensive code (not called often and small loopable). Else
- * it's preferable to use a regular for() loop and save extra function calls.
- * @param loopable - The object or array to be iterated.
- * @param fn - The function to call for each item.
- * @param [thisArg] - The value of `this` provided for the call to `fn`.
- * @param [reverse] - If true, iterates backward on the loopable.
- */
-export function each<T, TA>(
- loopable: T[],
- fn: (this: TA, v: T, i: number) => void,
- thisArg?: TA,
- reverse?: boolean
-): void;
-/**
- * Note(SB) for performance sake, this method should only be used when loopable type
- * is unknown or in none intensive code (not called often and small loopable). Else
- * it's preferable to use a regular for() loop and save extra function calls.
- * @param loopable - The object or array to be iterated.
- * @param fn - The function to call for each item.
- * @param [thisArg] - The value of `this` provided for the call to `fn`.
- * @param [reverse] - If true, iterates backward on the loopable.
- */
-export function each<T, TA>(
- loopable: { [key: string]: T },
- fn: (this: TA, v: T, k: string) => void,
- thisArg?: TA,
- reverse?: boolean
-): void;
-
-/**
- * Returns a deep copy of `source` without keeping references on objects and arrays.
- * @param source - The value to clone.
- */
-export function clone<T>(source: T): T;
-
-export interface MergeOptions {
- merger?: (key: string, target: AnyObject, source: AnyObject, options: AnyObject) => AnyObject;
-}
-/**
- * Recursively deep copies `source` properties into `target` with the given `options`.
- * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
- * @param target - The target object in which all sources are merged into.
- * @param source - Object(s) to merge into `target`.
- * @param {object} [options] - Merging options:
- * @param {function} [options.merger] - The merge method (key, target, source, options)
- * @returns {object} The `target` object.
- */
-export function merge<T>(target: T, source: [], options?: MergeOptions): T;
-export function merge<T, S1>(target: T, source: S1, options?: MergeOptions): T & S1;
-export function merge<T, S1>(target: T, source: [S1], options?: MergeOptions): T & S1;
-export function merge<T, S1, S2>(target: T, source: [S1, S2], options?: MergeOptions): T & S1 & S2;
-export function merge<T, S1, S2, S3>(target: T, source: [S1, S2, S3], options?: MergeOptions): T & S1 & S2 & S3;
-export function merge<T, S1, S2, S3, S4>(
- target: T,
- source: [S1, S2, S3, S4],
- options?: MergeOptions
-): T & S1 & S2 & S3 & S4;
-export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject;
-
-/**
- * Recursively deep copies `source` properties into `target` *only* if not defined in target.
- * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
- * @param target - The target object in which all sources are merged into.
- * @param source - Object(s) to merge into `target`.
- * @returns The `target` object.
- */
-export function mergeIf<T>(target: T, source: []): T;
-export function mergeIf<T, S1>(target: T, source: S1): T & S1;
-export function mergeIf<T, S1>(target: T, source: [S1]): T & S1;
-export function mergeIf<T, S1, S2>(target: T, source: [S1, S2]): T & S1 & S2;
-export function mergeIf<T, S1, S2, S3>(target: T, source: [S1, S2, S3]): T & S1 & S2 & S3;
-export function mergeIf<T, S1, S2, S3, S4>(target: T, source: [S1, S2, S3, S4]): T & S1 & S2 & S3 & S4;
-export function mergeIf<T>(target: T, source: AnyObject[]): AnyObject;
-
-export function resolveObjectKey(obj: AnyObject, key: string): AnyObject;
-
-export function defined(value: unknown): boolean;
-
-export function isFunction(value: unknown): boolean;
-
-export function setsEqual(a: Set<unknown>, b: Set<unknown>): boolean;
export type EasingFunctionSignature = (t: number) => number;
-export const easingEffects: Record<EasingFunction, EasingFunctionSignature>;
+export declare const easingEffects: Record<EasingFunction, EasingFunctionSignature>;
export * from './helpers.canvas';
export * from './helpers.collection';
export * from './helpers.color';
-export * from './helpers.core';
export * from './helpers.curve';
export * from './helpers.dom';
export * from './helpers.easing';
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils';
-import { TimeUnit } from './adapters';
+import { TimeUnit } from '../src/core/core.adapters';
import { AnimationEvent } from './animation';
import { AnyObject, EmptyObject } from './basic';
import { Color } from './color';
-import { Element } from './element';
+import Element from '../src/core/core.element';
import { ChartArea, Padding, Point } from './geometric';
import { LayoutItem, LayoutPosition } from './layout';
-export { DateAdapter, TimeUnit, _adapters } from './adapters';
export { Animation, Animations, Animator, AnimationEvent } from './animation';
export { Color } from './color';
-export { Element } from './element';
export { ChartArea, Point } from './geometric';
export { LayoutItem, LayoutPosition } from './layout';
}
export type BarController = DatasetController
-export const BarController: ChartComponent & {
+export declare const BarController: ChartComponent & {
prototype: BarController;
new (chart: Chart, datasetIndex: number): BarController;
};
}
export type BubbleController = DatasetController
-export const BubbleController: ChartComponent & {
+export declare const BubbleController: ChartComponent & {
prototype: BubbleController;
new (chart: Chart, datasetIndex: number): BubbleController;
};
}
export type LineController = DatasetController
-export const LineController: ChartComponent & {
+export declare const LineController: ChartComponent & {
prototype: LineController;
new (chart: Chart, datasetIndex: number): LineController;
};
export type ScatterControllerChartOptions = LineControllerChartOptions;
export type ScatterController = LineController
-export const ScatterController: ChartComponent & {
+export declare const ScatterController: ChartComponent & {
prototype: ScatterController;
new (chart: Chart, datasetIndex: number): ScatterController;
};
calculateCircumference(value: number): number;
}
-export const DoughnutController: ChartComponent & {
+export declare const DoughnutController: ChartComponent & {
prototype: DoughnutController;
new (chart: Chart, datasetIndex: number): DoughnutController;
};
export type PieMetaExtensions = DoughnutMetaExtensions;
export type PieController = DoughnutController
-export const PieController: ChartComponent & {
+export declare const PieController: ChartComponent & {
prototype: PieController;
new (chart: Chart, datasetIndex: number): PieController;
};
export interface PolarAreaController extends DoughnutController {
countVisibleElements(): number;
}
-export const PolarAreaController: ChartComponent & {
+export declare const PolarAreaController: ChartComponent & {
prototype: PolarAreaController;
new (chart: Chart, datasetIndex: number): PolarAreaController;
};
export type RadarControllerChartOptions = LineControllerChartOptions;
export type RadarController = DatasetController
-export const RadarController: ChartComponent & {
+export declare const RadarController: ChartComponent & {
prototype: RadarController;
new (chart: Chart, datasetIndex: number): RadarController;
};
static unregister(...items: ChartComponentLike[]): void;
}
-export const registerables: readonly ChartComponentLike[];
+export declare const registerables: readonly ChartComponentLike[];
export declare type ChartItem =
| string
export type UpdateMode = keyof typeof UpdateModeEnum;
-export class DatasetController<
+export declare class DatasetController<
TType extends ChartType = ChartType,
TElement extends Element = Element,
TDatasetElement extends Element = Element,
ChartTypeRegistry[key]['chartOptions'];
}
-export const defaults: Defaults;
+export declare const defaults: Defaults;
export interface InteractionOptions {
axis?: string;
intersect?: boolean;
export type InteractionMode = keyof InteractionModeMap;
-export const Interaction: {
+export declare const Interaction: {
modes: InteractionModeMap;
/**
): InteractionItem[];
};
-export const layouts: {
+export declare const layouts: {
/**
* Register a box to a chart.
* A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title.
getScale(id: string): Scale | undefined;
}
-export const registry: Registry;
+export declare const registry: Registry;
export interface Tick {
value: number;
}
-export const Ticks: {
+export declare const Ticks: {
formatters: {
/**
* Formatter for value labels
extends Element<T, O>,
VisualElement {}
-export const ArcElement: ChartComponent & {
+export declare const ArcElement: ChartComponent & {
prototype: ArcElement;
new (cfg: AnyObject): ArcElement;
};
path(ctx: CanvasRenderingContext2D): boolean;
}
-export const LineElement: ChartComponent & {
+export declare const LineElement: ChartComponent & {
prototype: LineElement;
new (cfg: AnyObject): LineElement;
};
readonly parsed: CartesianParsedData;
}
-export const PointElement: ChartComponent & {
+export declare const PointElement: ChartComponent & {
prototype: PointElement;
new (cfg: AnyObject): PointElement;
};
O extends BarOptions = BarOptions
> extends Element<T, O>, VisualElement {}
-export const BarElement: ChartComponent & {
+export declare const BarElement: ChartComponent & {
prototype: BarElement;
new (cfg: AnyObject): BarElement;
};
elements: ElementOptionsByType<TType>
};
-export class BasePlatform {
+export declare class BasePlatform {
/**
* Called at chart construction time, returns a context2d instance implementing
* the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
updateConfig(config: ChartConfiguration | ChartConfigurationCustomTypesPerDataset): void;
}
-export class BasicPlatform extends BasePlatform {}
-export class DomPlatform extends BasePlatform {}
+export declare class BasicPlatform extends BasePlatform {}
+export declare class DomPlatform extends BasePlatform {}
-export const Decimation: Plugin;
+export declare const Decimation: Plugin;
-export const enum DecimationAlgorithm {
+export declare const enum DecimationAlgorithm {
lttb = 'lttb',
minmax = 'min-max',
}
export type DecimationOptions = LttbDecimationOptions | MinMaxDecimationOptions;
-export const Filler: Plugin;
+export declare const Filler: Plugin;
export interface FillerOptions {
drawTime: 'beforeDatasetDraw' | 'beforeDatasetsDraw';
propagate: boolean;
fill: FillTarget | ComplexFillTarget;
}
-export const Legend: Plugin;
+export declare const Legend: Plugin;
export interface LegendItem {
/**
};
}
-export const SubTitle: Plugin;
-export const Title: Plugin;
+export declare const SubTitle: Plugin;
+export declare const Title: Plugin;
export interface TitleOptions {
/**
readonly positioners: TooltipPositionerMap;
}
-export const Tooltip: Tooltip;
+export declare const Tooltip: Tooltip;
export interface TooltipCallbacks<
TType extends ChartType,
};
export type CategoryScale<O extends CategoryScaleOptions = CategoryScaleOptions> = Scale<O>
-export const CategoryScale: ChartComponent & {
+export declare const CategoryScale: ChartComponent & {
prototype: CategoryScale;
new <O extends CategoryScaleOptions = CategoryScaleOptions>(cfg: AnyObject): CategoryScale<O>;
};
};
export type LinearScale<O extends LinearScaleOptions = LinearScaleOptions> = Scale<O>
-export const LinearScale: ChartComponent & {
+export declare const LinearScale: ChartComponent & {
prototype: LinearScale;
new <O extends LinearScaleOptions = LinearScaleOptions>(cfg: AnyObject): LinearScale<O>;
};
};
export type LogarithmicScale<O extends LogarithmicScaleOptions = LogarithmicScaleOptions> = Scale<O>
-export const LogarithmicScale: ChartComponent & {
+export declare const LogarithmicScale: ChartComponent & {
prototype: LogarithmicScale;
new <O extends LogarithmicScaleOptions = LogarithmicScaleOptions>(cfg: AnyObject): LogarithmicScale<O>;
};
normalize(values: number[]): number[];
}
-export const TimeScale: ChartComponent & {
+export declare const TimeScale: ChartComponent & {
prototype: TimeScale;
new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: AnyObject): TimeScale<O>;
};
export type TimeSeriesScale<O extends TimeScaleOptions = TimeScaleOptions> = TimeScale<O>
-export const TimeSeriesScale: ChartComponent & {
+export declare const TimeSeriesScale: ChartComponent & {
prototype: TimeSeriesScale;
new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: AnyObject): TimeSeriesScale<O>;
};
getPointLabelPosition(index: number): ChartArea;
getBasePosition(index: number): { x: number; y: number; angle: number };
}
-export const RadialLinearScale: ChartComponent & {
+export declare const RadialLinearScale: ChartComponent & {
prototype: RadialLinearScale;
new <O extends RadialLinearScaleOptions = RadialLinearScaleOptions>(cfg: AnyObject): RadialLinearScale<O>;
};
-import { Chart } from '..';
+import { Chart } from '../../src/types';
const chart = new Chart('id', {
type: 'bar',
try {
const fn = path.resolve(__dirname, 'autogen_helpers.ts');
fd = fs.openSync(fn, 'w+');
- fs.writeSync(fd, 'import * as helpers from \'../helpers\';\n\n');
+ fs.writeSync(fd, 'import * as helpers from \'../../src/helpers/types\';\n\n');
- fs.writeSync(fd, 'const testKeys = [];\n');
+ fs.writeSync(fd, 'const testKeys: unknown[] = [];\n');
for (const key of Object.keys(helpers)) {
if (key[0] !== '_' && typeof helpers[key] === 'function') {
fs.writeSync(fd, `testKeys.push(helpers.${key});\n`);
-import { Chart } from '..';
+import { Chart } from '../../src/types';
const chart = new Chart('chart', {
type: 'bar',
-import { Chart, ChartOptions } from '../..';
+import { Chart, ChartOptions } from '../../../src/types';
const chart = new Chart('test', {
type: 'bubble',
-import { Chart, ChartMeta, Element } from '../..';
+import { Chart, ChartMeta, Element } from '../../../src/types';
const chart = new Chart('id', {
type: 'doughnut',
-import { Chart, ChartMeta, Element } from '../..';
+import { Chart, ChartMeta, Element } from '../../../src/types';
const chart = new Chart('id', {
type: 'doughnut',
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
const chart = new Chart('id', {
type: 'doughnut',
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
const chart = new Chart('id', {
type: 'line',
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
const chart = new Chart('id', {
type: 'line',
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
const chart = new Chart('id', {
type: 'line',
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
const chart = new Chart('id', {
type: 'line',
-import { Chart, ChartOptions } from '../..';
+import { Chart, ChartOptions } from '../../../src/types';
const chart = new Chart('test', {
type: 'radar',
-import { Chart } from '..';
+import { Chart } from '../../src/types';
const chart = new Chart('chart', {
type: 'bar',
-import { ChartDataset } from '..';
+import { ChartDataset } from '../../src/types';
const dataset: ChartDataset = {
data: [10, null, 20],
--- /dev/null
+import { _adapters } from '../../src/types';
+
+_adapters._date.override<{myOption: boolean}>({
+ init() {
+ const booleanOption: boolean = this.options.myOption;
+
+ // @ts-expect-error Options is readonly.
+ this.options = {};
+ },
+ // @ts-expect-error Should return string.
+ format(timestamp) {
+ const numberArg: number = timestamp;
+ }
+});
-import { Chart } from '..';
+import { Chart } from '../../src/types';
Chart.defaults.scales.time.time.minUnit = 'day';
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
const chart = new Chart('id', {
type: 'line',
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
Chart.register({
id: 'my-plugin',
import { AnyObject } from '../../basic';
-import { CartesianScaleOptions, Chart, Scale } from '../..';
+import { CartesianScaleOptions, Chart, Scale } from '../../../src/types';
export type TestScaleOptions = CartesianScaleOptions & {
testOption?: boolean
import {
Chart, ChartData, ChartConfiguration, Element
-} from '..';
+} from '../../src/types';
const data: ChartData<'line'> = { datasets: [] };
const chartItem = 'item';
-import { LayoutPosition } from '../..';
+import { LayoutPosition } from '../../../src/types';
const left: LayoutPosition = 'left';
const right: LayoutPosition = 'right';
-import { Chart } from '..';
+import { Chart } from '../../src/types';
const chart = new Chart('test', {
type: 'bar',
-import { Chart } from '..';
+import { Chart } from '../../src/types';
Chart.overrides.bar.scales.x.type = 'time';
-import { ParsedDataType } from '..';
+import { ParsedDataType } from '../../src/types';
interface test {
pie: ParsedDataType<'pie'>,
-import { defaults } from '../..';
+import { defaults } from '../../../src/types';
// https://github.com/chartjs/Chart.js/issues/8711
const original = defaults.plugins.legend.labels.generateLabels;
-import { Chart, DecimationAlgorithm } from '../../..';
+import { Chart, DecimationAlgorithm } from '../../../../src/types';
const chart = new Chart('id', {
type: 'bubble',
-import { ChartDataset } from '../../..';
+import { ChartDataset } from '../../../../src/types';
const dataset: ChartDataset = {
data: [],
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
const chart = new Chart('id', {
type: 'line',
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
const chart = new Chart('id', {
type: 'line',
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
const chart = new Chart('id', {
type: 'bar',
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
Chart.overrides.bubble.plugins.tooltip.callbacks.label = (item) => {
const { x, y, _custom: r } = item.parsed;
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
const chart = new Chart('id', {
type: 'bar',
Title,
SubTitle,
Tooltip
-} from '..';
+} from '../../src/types';
Chart.register(
ArcElement,
-import { ChartOptions } from '../..';
+import { ChartOptions } from '../../../src/types';
const chartOptions: ChartOptions<'line'> = {
scales: {
-import { Chart, ScaleOptions } from '../..';
+import { Chart, ScaleOptions } from '../../../src/types';
const chart = new Chart('test', {
type: 'bar',
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
const chart = new Chart('id', {
type: 'line',
-import { ChartType, Scriptable, ScriptableContext } from '..';
+import { ChartType, Scriptable, ScriptableContext } from '../../src/types';
interface test {
pie?: Scriptable<number, ScriptableContext<'pie'>>,
-import { ChartConfiguration } from '..';
+import { ChartConfiguration } from '../../src/types';
const getConfig = (): ChartConfiguration<'bar'> => {
return {
-import { Chart } from '..';
+import { Chart } from '../../src/types';
const chart = new Chart('id', {
type: 'scatter',
{
+ "extends": "../../tsconfig.json",
"compilerOptions": {
- "target": "ES6",
- "moduleResolution": "Node",
- "alwaysStrict": true,
- "strict": true,
"noEmit": true
},
"include": [
- "./**/*.ts",
- "../index.d.ts"
+ "../",
+ "../../src/"
]
}
// https://stackoverflow.com/a/50375286
export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
-