- 'karma.conf.js'
- 'package.json'
types:
- - 'types/**'
- 'package.json'
- 'tsconfig.json'
- name: Install
- name: Test
if: |
(steps.changes.outputs.src == 'true' ||
- steps.changes.outputs.test == 'true') &&
+ steps.changes.outputs.test == 'true') &&
runner.os != 'Windows'
run: |
pnpm run build
*.stackdump
# Generated
-/types/tests/autogen*.ts
+/test/types/autogen*.ts
# Eslint
.eslintcache
}],
['vuepress-plugin-code-copy', true],
['vuepress-plugin-typedoc', {
- entryPoints: ['../../types/index.d.ts'],
+ entryPoints: ['../../src/types/index.d.ts'],
hideInPageTOC: true,
tsconfig: path.resolve(__dirname, '../../tsconfig.json'),
},
"auto/**",
"dist/**",
"!dist/docs/**",
- "helpers/**",
- "types/**/*.ts",
- "!types/tests/**"
+ "helpers/**"
],
"scripts": {
"autobuild": "rollup -c -w",
- "emitDeclarations": "tsc --emitDeclarationOnly",
+ "emitDeclarations": "tsc --emitDeclarationOnly && cp -R ./src/types/ ./dist/types/",
"build": "rollup -c && pnpm 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:dev": "pnpm run build && pnpm --filter \"./docs/**\" dev",
"lint-js": "eslint \"src/**/*.{js,ts}\" \"test/**/*.js\" \"docs/**/*.js\" --cache",
"lint-md": "eslint \"**/*.md\" --cache",
- "lint-types": "eslint \"types/**/*.ts\" --cache && pnpm build && node types/tests/autogen.js && tsc -p types/tests/",
+ "lint-types": "pnpm build && node test/types/autogen.js && tsc -p test/types",
"lint": "concurrently \"pnpm:lint-*\"",
"test-size": "size-limit",
"test": "pnpm lint && pnpm test-ci",
* @private
*/
-import type {AnyObject} from '../../types/basic.js';
-import type {ChartOptions} from '../../types/index.js';
+import type {AnyObject} from '../types/basic.js';
+import type {ChartOptions} from '../types/index.js';
export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
import {debounce} from '../helpers/helpers.extras.js';
/**
- * @typedef { import('../../types/index.js').ChartEvent } ChartEvent
- * @typedef { import('../../types/index.js').Point } Point
+ * @typedef { import('../types/index.js').ChartEvent } ChartEvent
+ * @typedef { import('../types/index.js').Point } Point
*/
const KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];
/**
* @param {ChartEvent} e - The event
- * @param {import('../../types/index.js').ActiveElement[]} lastActive - Previously active elements
+ * @param {import('../types/index.js').ActiveElement[]} lastActive - Previously active elements
* @param {boolean} inChartArea - Is the envent inside chartArea
* @param {boolean} useFinalPosition - Should the evaluation be done with current or final (after animation) element positions
- * @returns {import('../../types/index.js').ActiveElement[]} - The active elements
+ * @returns {import('../types/index.js').ActiveElement[]} - The active elements
* @pravate
*/
_getActiveElements(e, lastActive, inChartArea, useFinalPosition) {
-import type {AnyObject} from '../../types/basic.js';
-import type {Point} from '../../types/geometric.js';
-import type {Animation} from '../../types/animation.js';
+import type {AnyObject} from '../types/basic.js';
+import type {Point} from '../types/geometric.js';
+import type {Animation} from '../types/animation.js';
import {isNumber} from '../helpers/helpers.math.js';
export default class Element<T = AnyObject, O = AnyObject> {
/**
* @typedef { import('./core.controller.js').default } Chart
- * @typedef { import('../../types/index.js').ChartEvent } ChartEvent
+ * @typedef { import('../types/index.js').ChartEvent } ChartEvent
* @typedef {{axis?: string, intersect?: boolean, includeInvisible?: boolean}} InteractionOptions
* @typedef {{datasetIndex: number, index: number, element: import('./core.element.js').default}} InteractionItem
- * @typedef { import('../../types/index.js').Point } Point
+ * @typedef { import('../types/index.js').Point } Point
*/
/**
/**
* @typedef { import('./core.controller.js').default } Chart
- * @typedef { import('../../types/index.js').ChartEvent } ChartEvent
+ * @typedef { import('../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../plugins/plugin.tooltip.js').default } Tooltip
*/
import {_angleBetween, getAngleFromPoint, TAU, HALF_PI, valueOrDefault} from '../helpers/index.js';
import {PI, _isBetween, _limitValue} from '../helpers/helpers.math.js';
import {_readValueToProps} from '../helpers/helpers.options.js';
-import type {ArcOptions, Point} from '../../types/index.js';
+import type {ArcOptions, Point} from '../types/index.js';
function clipArc(ctx: CanvasRenderingContext2D, element: ArcElement, endAngle: number) {
Point,
PointHoverOptions,
PointOptions,
-} from '../../types/index.js';
+} from '../types/index.js';
function inRange(el: PointElement, pos: number, axis: 'x' | 'y', useFinalPosition?: boolean) {
const options = el.options;
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
* @typedef { import('../core/core.controller.js').default } canvas.Chart
- * @typedef { import('../../types/index.js').Point } Point
+ * @typedef { import('../types/index.js').Point } Point
*/
/**
* @namespace Chart.helpers
*/
-import type {AnyObject} from '../../types/basic.js';
-import type {ActiveDataPoint, ChartEvent} from '../../types/index.js';
+import type {AnyObject} from '../types/basic.js';
+import type {ActiveDataPoint, ChartEvent} from '../types/index.js';
/**
* An empty function that can be used, for example, for optional callback.
import {almostEquals, distanceBetweenPoints, sign} from './helpers.math.js';
import {_isPointInArea} from './helpers.canvas.js';
-import type {ChartArea} from '../../types/index.js';
+import type {ChartArea} from '../types/index.js';
export interface SplinePoint {
x: number;
-import type {ChartArea, Scale} from '../../types/index.js';
+import type {ChartArea, Scale} from '../types/index.js';
import type Chart from '../core/core.controller.js';
import type {ChartEvent} from '../types.js';
import {INFINITY} from './helpers.math.js';
-import type {ChartMeta, PointElement} from '../../types/index.js';
+import type {ChartMeta, PointElement} from '../types/index.js';
import {_limitValue} from './helpers.math.js';
import {_lookupByKey} from './helpers.collection.js';
-import type {Point} from '../../types/geometric.js';
+import type {Point} from '../types/geometric.js';
import type {SplinePoint} from './helpers.curve.js';
/**
-import type {Point} from '../../types/geometric.js';
+import type {Point} from '../types/geometric.js';
import {isFinite as isFiniteNumber} from './helpers.core.js';
/**
import defaults from '../core/core.defaults.js';
import {isArray, isObject, toDimension, valueOrDefault} from './helpers.core.js';
import {Point, toFontString} from './helpers.canvas.js';
-import type {ChartArea, FontSpec} from '../../types/index.js';
-import type {TRBL, TRBLCorners} from '../../types/geometric.js';
+import type {ChartArea, FontSpec} from '../types/index.js';
+import type {TRBL, TRBLCorners} from '../types/geometric.js';
const LINE_HEIGHT = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/;
const FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;
export * from './helpers.math.js';
export * from './helpers.options.js';
export * from './helpers.rtl.js';
-export * from '../../types/helpers/index.js';
+export * from '../types/helpers/index.js';
/**
* @typedef { import('../../core/core.scale.js').default } Scale
* @typedef { import('../../elements/element.line.js').default } LineElement
- * @typedef { import('../../../types/index.js').FillTarget } FillTarget
- * @typedef { import('../../../types/index.js').ComplexFillTarget } ComplexFillTarget
+ * @typedef { import('../../types/index.js').FillTarget } FillTarget
+ * @typedef { import('../../types/index.js').ComplexFillTarget } ComplexFillTarget
*/
export function _resolveTarget(sources, index, propagate) {
import {toTRBLCorners} from '../helpers/helpers.options.js';
/**
- * @typedef { import('../../types/index.js').ChartEvent } ChartEvent
+ * @typedef { import('../types/index.js').ChartEvent } ChartEvent
*/
const getBoxSize = (labelOpts, fontSize) => {
/**
* @typedef { import('../platform/platform.base.js').Chart } Chart
- * @typedef { import('../../types/index.js').ChartEvent } ChartEvent
- * @typedef { import('../../types/index.js').ActiveElement } ActiveElement
+ * @typedef { import('../types/index.js').ChartEvent } ChartEvent
+ * @typedef { import('../types/index.js').ActiveElement } ActiveElement
* @typedef { import('../core/core.interaction.js').InteractionItem } InteractionItem
*/
TimeScale,
TimeSeriesScale,
registerables
-} from '../types/index.js';
-export * from '../types/index.js';
+} from './types/index.js';
+export * from './types/index.js';
-import { Chart } from './index.js';
-import { AnyObject } from './basic.js';
+import {Chart} from './index.js';
+import {AnyObject} from './basic.js';
export declare class Animation {
constructor(cfg: AnyObject, target: AnyObject, prop: string, to?: unknown);
-import { PointStyle, Scriptable, ScriptableScaleContext } from '../index.js';
-import { Color } from '../color.js';
-import { ChartArea, RoundedRect } from '../geometric.js';
-import { CanvasFontSpec } from '../../src/helpers/helpers.options.js';
+import {PointStyle, Scriptable, ScriptableScaleContext} from '../index.js';
+import {Color} from '../color.js';
+import {ChartArea, RoundedRect} from '../geometric.js';
+import {CanvasFontSpec} from '../../helpers/helpers.options.js';
export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
-import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils.js';
-
-import { TimeUnit } from '../src/core/core.adapters.js';
-import PointElement from '../src/elements/element.point.js';
-import { EasingFunction } from '../src/helpers/helpers.easing.js';
-import { AnimationEvent } from './animation.js';
-import { AnyObject, EmptyObject } from './basic.js';
-import { Color } from './color.js';
-import Element from '../src/core/core.element.js';
-import { ChartArea, Padding, Point } from './geometric.js';
-import { LayoutItem, LayoutPosition } from './layout.js';
-import { RenderTextOpts } from './helpers/helpers.canvas.js';
-import { CanvasFontSpec } from '../src/helpers/helpers.options.js';
-
-export { EasingFunction } from '../src/helpers/helpers.easing.js';
-export { default as ArcElement, ArcProps } from '../src/elements/element.arc.js';
-export { default as PointElement, PointProps } from '../src/elements/element.point.js';
-export { Animation, Animations, Animator, AnimationEvent } from './animation.js';
-export { Color } from './color.js';
-export { ChartArea, Point } from './geometric.js';
-export { LayoutItem, LayoutPosition } from './layout.js';
+/* eslint-disable @typescript-eslint/ban-types */
+import {DeepPartial, DistributiveArray, UnionToIntersection} from './utils.js';
+
+import {TimeUnit} from '../core/core.adapters.js';
+import PointElement from '../elements/element.point.js';
+import {EasingFunction} from '../helpers/helpers.easing.js';
+import {AnimationEvent} from './animation.js';
+import {AnyObject, EmptyObject} from './basic.js';
+import {Color} from './color.js';
+import Element from '../core/core.element.js';
+import {ChartArea, Padding, Point} from './geometric.js';
+import {LayoutItem, LayoutPosition} from './layout.js';
+import {RenderTextOpts} from './helpers/helpers.canvas.js';
+import {CanvasFontSpec} from '../helpers/helpers.options.js';
+
+export {EasingFunction} from '../helpers/helpers.easing.js';
+export {default as ArcElement, ArcProps} from '../elements/element.arc.js';
+export {default as PointElement, PointProps} from '../elements/element.point.js';
+export {Animation, Animations, Animator, AnimationEvent} from './animation.js';
+export {Color} from './color.js';
+export {ChartArea, Point} from './geometric.js';
+export {LayoutItem, LayoutPosition} from './layout.js';
export interface ScriptableContext<TType extends ChartType> {
active: boolean;
export type ScatterControllerDatasetOptions = LineControllerDatasetOptions;
-export interface ScatterDataPoint extends Point {}
+export type ScatterDataPoint = Point
export type ScatterControllerChartOptions = LineControllerChartOptions;
-import { ChartArea } from './geometric.js';
+import {ChartArea} from './geometric.js';
export type LayoutPosition = 'left' | 'top' | 'right' | 'bottom' | 'center' | 'chartArea' | {[scaleId: string]: number};
rules:
- # These rules were set to warning to make the linting pass initially,
- # without making any major changes to types.
+ '@typescript-eslint/no-unused-vars': 'off'
object-curly-spacing: ["warn", "always"]
'@typescript-eslint/no-empty-interface': "warn"
'@typescript-eslint/ban-types': "warn"
-import { AnyObject } from '../../basic.js';
+import { AnyObject } from '../../../src/types/basic.js';
import { CartesianScaleOptions, Chart, Scale } from '../../../src/types.js';
export type TestScaleOptions = CartesianScaleOptions & {
}
}
-declare module '../../index.js' {
+declare module '../../../src/types/index.js' {
interface CartesianScaleTypeRegistry {
test: {
options: TestScaleOptions
"rootDir": "../../"
},
"include": [
- "../",
+ "./",
"../../src/",
"../../dist/**/*.d.ts"
],
},
"typedocOptions": {
"name": "Chart.js",
- "entryPoints": ["types/index.d.ts"],
+ "entryPoints": ["src/types/index.d.ts"],
"readme": "none",
"excludeExternals": true,
"includeVersion": true,
"out": "./dist/docs/typedoc"
},
"include": [
- "./src/**/*",
- "./types"
+ "./src/**/*"
],
"exclude": [
- "./types/tests",
"./dist/**"
]
}
+++ /dev/null
-rules:
- '@typescript-eslint/no-unused-vars': 'off'