mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-05 16:04:03 +01:00
Type fixes (#7759)
* Some type fixes * Fix missing property on tooltip option type
This commit is contained in:
7
types/core/index.d.ts
vendored
7
types/core/index.d.ts
vendored
@@ -233,7 +233,7 @@ export interface IParsingOptions {
|
||||
}
|
||||
|
||||
export interface Chart<
|
||||
T = number,
|
||||
T = unknown,
|
||||
L = string,
|
||||
C extends IChartConfiguration<string, T, L> = IChartConfiguration<string, T, L>
|
||||
> {
|
||||
@@ -245,7 +245,6 @@ export interface Chart<
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
readonly aspectRatio: number;
|
||||
readonly options: ConfigurationOptions<C>;
|
||||
readonly boxes: ILayoutItem[];
|
||||
readonly currentDevicePixelRatio: number;
|
||||
readonly chartArea: IChartArea;
|
||||
@@ -254,6 +253,8 @@ export interface Chart<
|
||||
readonly scale: Scale | undefined;
|
||||
readonly attached: boolean;
|
||||
|
||||
options: ConfigurationOptions<C>;
|
||||
|
||||
clear(): this;
|
||||
stop(): this;
|
||||
|
||||
@@ -300,7 +301,7 @@ export declare type ChartItem =
|
||||
|
||||
export const Chart: {
|
||||
prototype: Chart;
|
||||
new <T = number, L = string, C extends IChartConfiguration<string, T, L> = IChartConfiguration<string, T, L>>(
|
||||
new <T = unknown, L = string, C extends IChartConfiguration<string, T, L> = IChartConfiguration<string, T, L>>(
|
||||
item: ChartItem,
|
||||
config: C
|
||||
): Chart<T, L, C>;
|
||||
|
||||
7
types/interfaces.d.ts
vendored
7
types/interfaces.d.ts
vendored
@@ -37,7 +37,7 @@ export type DeepPartial<T> = T extends {}
|
||||
}
|
||||
: T;
|
||||
|
||||
export type IChartDataset<T = number, O = {}> = DeepPartial<IControllerDatasetOptions & IParsingOptions & O> & {
|
||||
export type IChartDataset<T = unknown, O = {}> = DeepPartial<IControllerDatasetOptions & IParsingOptions & O> & {
|
||||
data: T[];
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ export type IDoughnutControllerDataset<T = IDoughnutDataPoint> = IChartDataset<T
|
||||
export type IPolarAreaControllerDataset<T = number> = IChartDataset<T, IPolarAreaControllerDatasetOptions>;
|
||||
export type IRadarControllerDataset<T = number> = IChartDataset<T, IRadarControllerDatasetOptions>;
|
||||
|
||||
export interface IChartData<T = number, L = string, DS extends IChartDataset<T> = IChartDataset<T>>
|
||||
export interface IChartData<T = unknown, L = string, DS extends IChartDataset<T> = IChartDataset<T>>
|
||||
extends DeepPartial<IParsingOptions> {
|
||||
labels: L[];
|
||||
datasets: DS[];
|
||||
@@ -61,6 +61,7 @@ export interface IChartData<T = number, L = string, DS extends IChartDataset<T>
|
||||
|
||||
export type IChartOptions<O = {}> = DeepPartial<
|
||||
ICoreChartOptions &
|
||||
IParsingOptions &
|
||||
ITooltipChartOptions &
|
||||
ILegendChartOptions &
|
||||
ITitleChartOptions &
|
||||
@@ -72,7 +73,7 @@ export type IChartOptions<O = {}> = DeepPartial<
|
||||
|
||||
export interface IChartConfiguration<
|
||||
TYPE = string,
|
||||
T = number,
|
||||
T = unknown,
|
||||
L = string,
|
||||
DS extends IChartDataset<T> = IChartDataset<T>,
|
||||
O = {}
|
||||
|
||||
16
types/plugins/index.d.ts
vendored
16
types/plugins/index.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
import { Chart, Element, IAnimationSpecContainer, InteractionMode, LayoutPosition, IPlugin } from '../core';
|
||||
import { Color, IChartArea, IFontSpec, Scriptable, TextAlign, IEvent } from '../core/interfaces';
|
||||
import { Color, IChartArea, IFontSpec, Scriptable, TextAlign, IEvent, IHoverInteractionOptions } from '../core/interfaces';
|
||||
import { PointStyle } from '../elements';
|
||||
import { IChartData } from '../interfaces';
|
||||
import { IChartData, IChartDataset } from '../interfaces';
|
||||
|
||||
export const Filler: IPlugin;
|
||||
|
||||
@@ -325,7 +325,7 @@ export interface ITooltipPlugin<O = {}> {
|
||||
afterTooltipDraw?(chart: Chart, args: { tooltip: TooltipModel }, options: O): void;
|
||||
}
|
||||
|
||||
export interface ITooltipOptions {
|
||||
export interface ITooltipOptions extends IHoverInteractionOptions {
|
||||
/**
|
||||
* Are on-canvas tooltips enabled?
|
||||
* @default true
|
||||
@@ -335,18 +335,10 @@ export interface ITooltipOptions {
|
||||
* See custom tooltip section.
|
||||
*/
|
||||
custom(this: TooltipModel, args: { chart: Chart; tooltip: TooltipModel }): void;
|
||||
/**
|
||||
* Sets which elements appear in the tooltip.
|
||||
*/
|
||||
mode: InteractionMode;
|
||||
/**
|
||||
* The mode for positioning the tooltip
|
||||
*/
|
||||
position: 'average' | 'nearest';
|
||||
/**
|
||||
* If true, the tooltip mode applies only when the mouse position intersects with an element. If false, the mode will be applied at all times.
|
||||
*/
|
||||
intersect: boolean;
|
||||
|
||||
/**
|
||||
* Sort tooltip items.
|
||||
@@ -514,7 +506,7 @@ export interface ITooltipItem {
|
||||
/**
|
||||
* The dataset the item comes from
|
||||
*/
|
||||
dataset: object;
|
||||
dataset: IChartDataset;
|
||||
|
||||
/**
|
||||
* Index of the dataset the item comes from
|
||||
|
||||
8
types/scales/index.d.ts
vendored
8
types/scales/index.d.ts
vendored
@@ -180,7 +180,7 @@ export const CategoryScale: IChartComponent & {
|
||||
new <O extends ICategoryScaleOptions = ICategoryScaleOptions>(cfg: any): CategoryScale<O>;
|
||||
};
|
||||
|
||||
export type ILinearScaleOptions = IScaleOptions & {
|
||||
export type ILinearScaleOptions = ICartesianScaleOptions & {
|
||||
stacked?: boolean;
|
||||
|
||||
/**
|
||||
@@ -281,12 +281,16 @@ export type ITimeScaleOptions = ICartesianScaleOptions & {
|
||||
*/
|
||||
isoWeekday: false | string;
|
||||
/**
|
||||
* Sets how different time units are displayed.
|
||||
* Sets how different time units are displayed.
|
||||
* @see https://www.chartjs.org/docs/next/axes/cartesian/time#display-formats
|
||||
*/
|
||||
displayFormats: {
|
||||
[key: string]: string;
|
||||
};
|
||||
/**
|
||||
* The format string to use for the tooltip.
|
||||
*/
|
||||
tooltipFormat: string;
|
||||
/**
|
||||
* If defined, will force the unit to be a certain type. See Time Units section below for details.
|
||||
* @default false
|
||||
|
||||
Reference in New Issue
Block a user