Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions types/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ extends:
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"
Expand Down
110 changes: 55 additions & 55 deletions types/adapters.d.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
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;
// 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;

/**
* 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;
/**
* 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;
_date: DateAdapter;
};
8 changes: 4 additions & 4 deletions types/animation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export class Animation {
}

export interface AnimationEvent {
chart: Chart;
numSteps: number;
initial: boolean;
currentStep: number;
chart: Chart;
numSteps: number;
initial: boolean;
currentStep: number;
}

export class Animator {
Expand Down
18 changes: 9 additions & 9 deletions types/element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ 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;
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]>;
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>;
prototype: Element;
new <T = AnyObject, O = AnyObject>(): Element<T, O>;
};
142 changes: 71 additions & 71 deletions types/helpers/helpers.canvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export function clipArea(ctx: CanvasRenderingContext2D, area: ChartArea): void;
export function unclipArea(ctx: CanvasRenderingContext2D): void;

export interface DrawPointOptions {
pointStyle: PointStyle;
rotation?: number;
radius: number;
borderWidth: number;
pointStyle: PointStyle;
rotation?: number;
radius: number;
borderWidth: number;
}

export function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number): void;
Expand All @@ -26,76 +26,76 @@ export function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptio
export function toFontString(font: { size: number; family: string; style?: string; weight?: string }): string | null;

export interface RenderTextOpts {
/**
* The fill color of the text. If unset, the existing
* fillStyle property of the canvas is unchanged.
*/
color?: Color;

/**
* The width of the strikethrough / underline
* @default 2
*/
decorationWidth?: number;

/**
* The max width of the text in pixels
*/
maxWidth?: number;

/**
* A rotation to be applied to the canvas
* This is applied after the translation is applied
*/
rotation?: number;

/**
* Apply a strikethrough effect to the text
*/
strikethrough?: boolean;

/**
* The color of the text stroke. If unset, the existing
* strokeStyle property of the context is unchanged
*/
strokeColor?: Color;

/**
* The text stroke width. If unset, the existing
* lineWidth property of the context is unchanged
*/
strokeWidth?: number;

/**
* The text alignment to use. If unset, the existing
* textAlign property of the context is unchanged
*/
textAlign: CanvasTextAlign;

/**
* The text baseline to use. If unset, the existing
* textBaseline property of the context is unchanged
*/
textBaseline: CanvasTextBaseline;

/**
* If specified, a translation to apply to the context
*/
translation?: [number, number];

/**
* Underline the text
*/
underline?: boolean;
/**
* The fill color of the text. If unset, the existing
* fillStyle property of the canvas is unchanged.
*/
color?: Color;

/**
* The width of the strikethrough / underline
* @default 2
*/
decorationWidth?: number;

/**
* The max width of the text in pixels
*/
maxWidth?: number;

/**
* A rotation to be applied to the canvas
* This is applied after the translation is applied
*/
rotation?: number;

/**
* Apply a strikethrough effect to the text
*/
strikethrough?: boolean;

/**
* The color of the text stroke. If unset, the existing
* strokeStyle property of the context is unchanged
*/
strokeColor?: Color;

/**
* The text stroke width. If unset, the existing
* lineWidth property of the context is unchanged
*/
strokeWidth?: number;

/**
* The text alignment to use. If unset, the existing
* textAlign property of the context is unchanged
*/
textAlign: CanvasTextAlign;

/**
* The text baseline to use. If unset, the existing
* textBaseline property of the context is unchanged
*/
textBaseline: CanvasTextBaseline;

/**
* If specified, a translation to apply to the context
*/
translation?: [number, number];

/**
* Underline the text
*/
underline?: boolean;
}

export function renderText(
ctx: CanvasRenderingContext2D,
text: string | string[],
x: number,
y: number,
font: CanvasFontSpec,
opts?: RenderTextOpts
ctx: CanvasRenderingContext2D,
text: string | string[],
x: number,
y: number,
font: CanvasFontSpec,
opts?: RenderTextOpts
): void;

export function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: RoundedRect): void;
10 changes: 5 additions & 5 deletions types/helpers/helpers.collection.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export interface ArrayListener<T> {
_onDataPush?(...item: T[]): void;
_onDataPop?(): void;
_onDataShift?(): void;
_onDataSplice?(index: number, deleteCount: number, ...items: T[]): void;
_onDataUnshift?(...item: T[]): void;
_onDataPush?(...item: T[]): void;
_onDataPop?(): void;
_onDataShift?(): void;
_onDataSplice?(index: number, deleteCount: number, ...items: T[]): void;
_onDataUnshift?(...item: T[]): void;
}

/**
Expand Down
44 changes: 22 additions & 22 deletions types/helpers/helpers.color.d.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
export function color(value: CanvasGradient): CanvasGradient;
export function color(value: CanvasPattern): CanvasPattern;
export function color(
value:
| string
| { r: number; g: number; b: number; a: number }
| [number, number, number]
| [number, number, number, number]
value:
| string
| { r: number; g: number; b: number; a: number }
| [number, number, number]
| [number, number, number, number]
): ColorModel;

export interface ColorModel {
rgbString(): string;
hexString(): string;
hslString(): string;
rgb: { r: number; g: number; b: number; a: number };
valid: boolean;
mix(color: ColorModel, weight: number): this;
clone(): ColorModel;
alpha(a: number): ColorModel;
clearer(ration: number): ColorModel;
greyscale(): ColorModel;
opaquer(ratio: number): ColorModel;
negate(): ColorModel;
lighten(ratio: number): ColorModel;
darken(ratio: number): ColorModel;
saturate(ratio: number): ColorModel;
desaturate(ratio: number): ColorModel;
rotate(deg: number): this;
rgbString(): string;
hexString(): string;
hslString(): string;
rgb: { r: number; g: number; b: number; a: number };
valid: boolean;
mix(color: ColorModel, weight: number): this;
clone(): ColorModel;
alpha(a: number): ColorModel;
clearer(ration: number): ColorModel;
greyscale(): ColorModel;
opaquer(ratio: number): ColorModel;
negate(): ColorModel;
lighten(ratio: number): ColorModel;
darken(ratio: number): ColorModel;
saturate(ratio: number): ColorModel;
desaturate(ratio: number): ColorModel;
rotate(deg: number): this;
}

export function getHoverColor(value: CanvasGradient): CanvasGradient;
Expand Down
Loading