Class: Chart<TType, TData, TLabel>

Type parameters

NameType
TTypeextends ChartType = ChartType
TDataDefaultDataPoint<TType>
TLabelunknown

Constructors

constructor

new Chart<TType, TData, TLabel>(item, config)

Type parameters

NameType
TTypeextends keyof ChartTypeRegistry = keyof ChartTypeRegistry
TDataDistributiveArray<ChartTypeRegistry[TType][“defaultDataPoint”]>
TLabelunknown

Parameters

NameType
itemChartItem
configChartConfiguration<TType, TData, TLabel> | ChartConfigurationCustomTypesPerDataset<TType, TData, TLabel>

Defined in

types/index.d.ts:509Chart - 图1 (opens new window)

Properties

aspectRatio

Readonly aspectRatio: number

Defined in

types/index.d.ts:496Chart - 图2 (opens new window)


attached

Readonly attached: boolean

Defined in

types/index.d.ts:501Chart - 图3 (opens new window)


boxes

Readonly boxes: LayoutItem[]

Defined in

types/index.d.ts:497Chart - 图4 (opens new window)


canvas

Readonly canvas: HTMLCanvasElement

Defined in

types/index.d.ts:491Chart - 图5 (opens new window)


chartArea

Readonly chartArea: ChartArea

Defined in

types/index.d.ts:499Chart - 图6 (opens new window)


config

Readonly config: ChartConfiguration<TType, TData, TLabel> | ChartConfigurationCustomTypesPerDataset<TType, TData, TLabel>

Defined in

types/index.d.ts:493Chart - 图7 (opens new window)


ctx

Readonly ctx: CanvasRenderingContext2D

Defined in

types/index.d.ts:492Chart - 图8 (opens new window)


currentDevicePixelRatio

Readonly currentDevicePixelRatio: number

Defined in

types/index.d.ts:498Chart - 图9 (opens new window)


data

data: ChartData<TType, TData, TLabel>

Defined in

types/index.d.ts:506Chart - 图10 (opens new window)


height

Readonly height: number

Defined in

types/index.d.ts:495Chart - 图11 (opens new window)


id

Readonly id: string

Defined in

types/index.d.ts:490Chart - 图12 (opens new window)


legend

Optional Readonly legend: LegendElement<TType>

Defined in

types/index.d.ts:503Chart - 图13 (opens new window)


options

options: DeepPartial<CoreChartOptions<TType> & ElementChartOptions<TType> & PluginChartOptions<TType> & DatasetChartOptions<TType> & ScaleChartOptions<TType> & ChartTypeRegistry[TType]["chartOptions"]>

Defined in

types/index.d.ts:507Chart - 图14 (opens new window)


platform

Readonly platform: BasePlatform

Defined in

types/index.d.ts:489Chart - 图15 (opens new window)


scales

Readonly scales: Object

Index signature

▪ [key: string]: Scale

Defined in

types/index.d.ts:500Chart - 图16 (opens new window)


tooltip

Optional Readonly tooltip: TooltipModel<TType>

Defined in

types/index.d.ts:504Chart - 图17 (opens new window)


width

Readonly width: number

Defined in

types/index.d.ts:494Chart - 图18 (opens new window)


defaults

Static Readonly defaults: Defaults

Defined in

types/index.d.ts:551Chart - 图19 (opens new window)


instances

Static Readonly instances: Object

Index signature

▪ [key: string]: Chart

Defined in

types/index.d.ts:554Chart - 图20 (opens new window)


overrides

Static Readonly overrides: Overrides

Defined in

types/index.d.ts:552Chart - 图21 (opens new window)


registry

Static Readonly registry: Registry

Defined in

types/index.d.ts:555Chart - 图22 (opens new window)


version

Static Readonly version: string

Defined in

types/index.d.ts:553Chart - 图23 (opens new window)

Methods

bindEvents

bindEvents(): void

Returns

void

Defined in

types/index.d.ts:541Chart - 图24 (opens new window)


buildOrUpdateControllers

buildOrUpdateControllers(): void

Returns

void

Defined in

types/index.d.ts:517Chart - 图25 (opens new window)


buildOrUpdateScales

buildOrUpdateScales(): void

Returns

void

Defined in

types/index.d.ts:516Chart - 图26 (opens new window)


clear

clear(): Chart<TType, TData, TLabel>

Returns

Chart<TType, TData, TLabel>

Defined in

types/index.d.ts:511Chart - 图27 (opens new window)


destroy

destroy(): void

Returns

void

Defined in

types/index.d.ts:539Chart - 图28 (opens new window)


draw

draw(): void

Returns

void

Defined in

types/index.d.ts:521Chart - 图29 (opens new window)


ensureScalesHaveIDs

ensureScalesHaveIDs(): void

Returns

void

Defined in

types/index.d.ts:515Chart - 图30 (opens new window)


getActiveElements

getActiveElements(): ActiveElement[]

Returns

ActiveElement[]

Defined in

types/index.d.ts:536Chart - 图31 (opens new window)


getContext

getContext(): Object

Returns

Object

NameType
chartChart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>
typestring

Defined in

types/index.d.ts:549Chart - 图32 (opens new window)


getDataVisibility

getDataVisibility(index): boolean

Parameters

NameType
indexnumber

Returns

boolean

Defined in

types/index.d.ts:532Chart - 图33 (opens new window)


getDatasetMeta

getDatasetMeta(datasetIndex): ChartMeta<keyof ChartTypeRegistry, default<AnyObject, AnyObject>, default<AnyObject, AnyObject>>

Parameters

NameType
datasetIndexnumber

Returns

ChartMeta<keyof ChartTypeRegistry, default<AnyObject, AnyObject>, default<AnyObject, AnyObject>>

Defined in

types/index.d.ts:527Chart - 图34 (opens new window)


getElementsAtEventForMode

getElementsAtEventForMode(e, mode, options, useFinalPosition): InteractionItem[]

Parameters

NameType
eEvent
modestring
optionsInteractionOptions
useFinalPositionboolean

Returns

InteractionItem[]

Defined in

types/index.d.ts:524Chart - 图35 (opens new window)


getSortedVisibleDatasetMetas

getSortedVisibleDatasetMetas(): ChartMeta<keyof ChartTypeRegistry, default<AnyObject, AnyObject>, default<AnyObject, AnyObject>>[]

Returns

ChartMeta<keyof ChartTypeRegistry, default<AnyObject, AnyObject>, default<AnyObject, AnyObject>>[]

Defined in

types/index.d.ts:526Chart - 图36 (opens new window)


getVisibleDatasetCount

getVisibleDatasetCount(): number

Returns

number

Defined in

types/index.d.ts:528Chart - 图37 (opens new window)


hide

hide(datasetIndex, dataIndex?): void

Parameters

NameType
datasetIndexnumber
dataIndex?number

Returns

void

Defined in

types/index.d.ts:533Chart - 图38 (opens new window)


isDatasetVisible

isDatasetVisible(datasetIndex): boolean

Parameters

NameType
datasetIndexnumber

Returns

boolean

Defined in

types/index.d.ts:529Chart - 图39 (opens new window)


isPluginEnabled

isPluginEnabled(pluginId): boolean

Parameters

NameType
pluginIdstring

Returns

boolean

Defined in

types/index.d.ts:547Chart - 图40 (opens new window)


isPointInArea

isPointInArea(point): boolean

Parameters

NameType
pointPoint

Returns

boolean

Defined in

types/index.d.ts:523Chart - 图41 (opens new window)


notifyPlugins

notifyPlugins(hook, args?): boolean | void

Parameters

NameType
hookstring
args?AnyObject

Returns

boolean | void

Defined in

types/index.d.ts:545Chart - 图42 (opens new window)


render

render(): void

Returns

void

Defined in

types/index.d.ts:520Chart - 图43 (opens new window)


reset

reset(): void

Returns

void

Defined in

types/index.d.ts:518Chart - 图44 (opens new window)


resize

resize(width?, height?): void

Parameters

NameType
width?number
height?number

Returns

void

Defined in

types/index.d.ts:514Chart - 图45 (opens new window)


setActiveElements

setActiveElements(active): void

Parameters

NameType
activeActiveDataPoint[]

Returns

void

Defined in

types/index.d.ts:537Chart - 图46 (opens new window)


setDatasetVisibility

setDatasetVisibility(datasetIndex, visible): void

Parameters

NameType
datasetIndexnumber
visibleboolean

Returns

void

Defined in

types/index.d.ts:530Chart - 图47 (opens new window)


show

show(datasetIndex, dataIndex?): void

Parameters

NameType
datasetIndexnumber
dataIndex?number

Returns

void

Defined in

types/index.d.ts:534Chart - 图48 (opens new window)


stop

stop(): Chart<TType, TData, TLabel>

Returns

Chart<TType, TData, TLabel>

Defined in

types/index.d.ts:512Chart - 图49 (opens new window)


toBase64Image

toBase64Image(type?, quality?): string

Parameters

NameType
type?string
quality?unknown

Returns

string

Defined in

types/index.d.ts:540Chart - 图50 (opens new window)


toggleDataVisibility

toggleDataVisibility(index): void

Parameters

NameType
indexnumber

Returns

void

Defined in

types/index.d.ts:531Chart - 图51 (opens new window)


unbindEvents

unbindEvents(): void

Returns

void

Defined in

types/index.d.ts:542Chart - 图52 (opens new window)


update

update(mode?): void

Parameters

NameType
mode?“none” | “hide” | “show” | “default” | “active” | “resize” | “reset”

Returns

void

Defined in

types/index.d.ts:519Chart - 图53 (opens new window)


updateHoverStyle

updateHoverStyle(items, mode, enabled): void

Parameters

NameType
itemsInteractionItem[]
mode“dataset”
enabledboolean

Returns

void

Defined in

types/index.d.ts:543Chart - 图54 (opens new window)


getChart

Static getChart(key): Chart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>

Parameters

NameType
keystring | HTMLCanvasElement | CanvasRenderingContext2D

Returns

Chart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>

Defined in

types/index.d.ts:556Chart - 图55 (opens new window)


register

Static register(...items): void

Parameters

NameType
…itemsChartComponentLike[]

Returns

void

Defined in

types/index.d.ts:557Chart - 图56 (opens new window)


unregister

Static unregister(...items): void

Parameters

NameType
…itemsChartComponentLike[]

Returns

void

Defined in

types/index.d.ts:558Chart - 图57 (opens new window)