Class: Chart | Chart.js
Description: Open source HTML5 Charts for your website

# # Class: Chart<TType, TData, TLabel>

## # Type parameters

Name | Type
--- | ---
`TType` | extends `ChartType` = `ChartType`
`TData` | `DefaultDataPoint`<`TType`>
`TLabel` | `unknown`

## # Constructors

### # constructor

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

#### # Type parameters

Name | Type
--- | ---
`TType` | extends keyof `ChartTypeRegistry` = keyof `ChartTypeRegistry`
`TData` | `DistributiveArray`<`ChartTypeRegistry`[`TType`][`"defaultDataPoint"`]>
`TLabel` | `unknown`

#### # Parameters

Name | Type
--- | ---
`item` | `ChartItem`
`config` | `ChartConfiguration`<`TType`, `TData`, `TLabel`> | `ChartConfigurationCustomTypesPerDataset`<`TType`, `TData`, `TLabel`>

#### # Defined in

index.esm.d.ts:504
(opens new window)

## # Properties

### # aspectRatio

• `Readonly` aspectRatio: `number`

#### # Defined in

index.esm.d.ts:491
(opens new window)

### # attached

• `Readonly` attached: `boolean`

#### # Defined in

index.esm.d.ts:496
(opens new window)

### # boxes

• `Readonly` boxes: `LayoutItem`[]

#### # Defined in

index.esm.d.ts:492
(opens new window)

### # canvas

• `Readonly` canvas: `HTMLCanvasElement`

#### # Defined in

index.esm.d.ts:486
(opens new window)

### # chartArea

• `Readonly` chartArea: `ChartArea`

#### # Defined in

index.esm.d.ts:494
(opens new window)

### # config

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

#### # Defined in

index.esm.d.ts:488
(opens new window)

### # ctx

• `Readonly` ctx: `CanvasRenderingContext2D`

#### # Defined in

index.esm.d.ts:487
(opens new window)

### # currentDevicePixelRatio

• `Readonly` currentDevicePixelRatio: `number`

#### # Defined in

index.esm.d.ts:493
(opens new window)

### # data

• data: `ChartData`<`TType`, `TData`, `TLabel`>

#### # Defined in

index.esm.d.ts:501
(opens new window)

### # height

• `Readonly` height: `number`

#### # Defined in

index.esm.d.ts:490
(opens new window)

### # id

• `Readonly` id: `string`

#### # Defined in

index.esm.d.ts:485
(opens new window)

### # legend

• `Optional` `Readonly` legend: `LegendElement`<`TType`>

#### # Defined in

index.esm.d.ts:498
(opens new window)

### # options

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

#### # Defined in

index.esm.d.ts:502
(opens new window)

### # platform

• `Readonly` platform: `BasePlatform`

#### # Defined in

index.esm.d.ts:484
(opens new window)

### # scales

• `Readonly` scales: `Object`

#### # Index signature

▪ [key: `string`]: `Scale`

#### # Defined in

index.esm.d.ts:495
(opens new window)

### # tooltip

• `Optional` `Readonly` tooltip: `TooltipModel`<`TType`>

#### # Defined in

index.esm.d.ts:499
(opens new window)

### # width

• `Readonly` width: `number`

#### # Defined in

index.esm.d.ts:489
(opens new window)

### # defaults

▪ `Static` `Readonly` defaults: `Defaults`

#### # Defined in

index.esm.d.ts:542
(opens new window)

### # instances

▪ `Static` `Readonly` instances: `Object`

#### # Index signature

▪ [key: `string`]: `Chart`

#### # Defined in

index.esm.d.ts:545
(opens new window)

### # overrides

▪ `Static` `Readonly` overrides: `Overrides`

#### # Defined in

index.esm.d.ts:543
(opens new window)

### # registry

▪ `Static` `Readonly` registry: `Registry`

#### # Defined in

index.esm.d.ts:546
(opens new window)

### # version

▪ `Static` `Readonly` version: `string`

#### # Defined in

index.esm.d.ts:544
(opens new window)

## # Methods

### # bindEvents

▸ bindEvents(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:536
(opens new window)

### # buildOrUpdateControllers

▸ buildOrUpdateControllers(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:512
(opens new window)

### # buildOrUpdateScales

▸ buildOrUpdateScales(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:511
(opens new window)

### # clear

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

#### # Returns

`Chart`<`TType`, `TData`, `TLabel`>

#### # Defined in

index.esm.d.ts:506
(opens new window)

### # destroy

▸ destroy(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:534
(opens new window)

### # draw

▸ draw(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:516
(opens new window)

### # ensureScalesHaveIDs

▸ ensureScalesHaveIDs(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:510
(opens new window)

### # getActiveElements

▸ getActiveElements(): `ActiveElement`[]

#### # Returns

`ActiveElement`[]

#### # Defined in

index.esm.d.ts:531
(opens new window)

### # getDataVisibility

▸ getDataVisibility(`index`): `boolean`

#### # Parameters

Name | Type
--- | ---
`index` | `number`

#### # Returns

`boolean`

#### # Defined in

index.esm.d.ts:527
(opens new window)

### # getDatasetMeta

▸ getDatasetMeta(`datasetIndex`): `ChartMeta`<`Element`<`AnyObject`, `AnyObject`>, `Element`<`AnyObject`, `AnyObject`>, keyof `ChartTypeRegistry`>

#### # Parameters

Name | Type
--- | ---
`datasetIndex` | `number`

#### # Returns

`ChartMeta`<`Element`<`AnyObject`, `AnyObject`>, `Element`<`AnyObject`, `AnyObject`>, keyof `ChartTypeRegistry`>

#### # Defined in

index.esm.d.ts:522
(opens new window)

### # getElementsAtEventForMode

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

#### # Parameters

Name | Type
--- | ---
`e` | `Event`
`mode` | `string`
`options` | `InteractionOptions`
`useFinalPosition` | `boolean`

#### # Returns

`InteractionItem`[]

#### # Defined in

index.esm.d.ts:519
(opens new window)

### # getSortedVisibleDatasetMetas

▸ getSortedVisibleDatasetMetas(): `ChartMeta`<`Element`<`AnyObject`, `AnyObject`>, `Element`<`AnyObject`, `AnyObject`>, keyof `ChartTypeRegistry`>[]

#### # Returns

`ChartMeta`<`Element`<`AnyObject`, `AnyObject`>, `Element`<`AnyObject`, `AnyObject`>, keyof `ChartTypeRegistry`>[]

#### # Defined in

index.esm.d.ts:521
(opens new window)

### # getVisibleDatasetCount

▸ getVisibleDatasetCount(): `number`

#### # Returns

`number`

#### # Defined in

index.esm.d.ts:523
(opens new window)

### # hide

▸ hide(`datasetIndex`, `dataIndex?`): `void`

#### # Parameters

Name | Type
--- | ---
`datasetIndex` | `number`
`dataIndex?` | `number`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:528
(opens new window)

### # isDatasetVisible

▸ isDatasetVisible(`datasetIndex`): `boolean`

#### # Parameters

Name | Type
--- | ---
`datasetIndex` | `number`

#### # Returns

`boolean`

#### # Defined in

index.esm.d.ts:524
(opens new window)

### # isPointInArea

▸ isPointInArea(`point`): `boolean`

#### # Parameters

Name | Type
--- | ---
`point` | `Point`

#### # Returns

`boolean`

#### # Defined in

index.esm.d.ts:518
(opens new window)

### # notifyPlugins

▸ notifyPlugins(`hook`, `args?`): `boolean` | `void`

#### # Parameters

Name | Type
--- | ---
`hook` | `string`
`args?` | `AnyObject`

#### # Returns

`boolean` | `void`

#### # Defined in

index.esm.d.ts:540
(opens new window)

### # render

▸ render(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:515
(opens new window)

### # reset

▸ reset(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:513
(opens new window)

### # resize

▸ resize(`width?`, `height?`): `void`

#### # Parameters

Name | Type
--- | ---
`width?` | `number`
`height?` | `number`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:509
(opens new window)

### # setActiveElements

▸ setActiveElements(`active`): `void`

#### # Parameters

Name | Type
--- | ---
`active` | `ActiveDataPoint`[]

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:532
(opens new window)

### # setDatasetVisibility

▸ setDatasetVisibility(`datasetIndex`, `visible`): `void`

#### # Parameters

Name | Type
--- | ---
`datasetIndex` | `number`
`visible` | `boolean`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:525
(opens new window)

### # show

▸ show(`datasetIndex`, `dataIndex?`): `void`

#### # Parameters

Name | Type
--- | ---
`datasetIndex` | `number`
`dataIndex?` | `number`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:529
(opens new window)

### # stop

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

#### # Returns

`Chart`<`TType`, `TData`, `TLabel`>

#### # Defined in

index.esm.d.ts:507
(opens new window)

### # toBase64Image

▸ toBase64Image(`type?`, `quality?`): `string`

#### # Parameters

Name | Type
--- | ---
`type?` | `string`
`quality?` | `unknown`

#### # Returns

`string`

#### # Defined in

index.esm.d.ts:535
(opens new window)

### # toggleDataVisibility

▸ toggleDataVisibility(`index`): `void`

#### # Parameters

Name | Type
--- | ---
`index` | `number`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:526
(opens new window)

### # unbindEvents

▸ unbindEvents(): `void`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:537
(opens new window)

### # update

▸ update(`mode?`): `void`

#### # Parameters

Name | Type
--- | ---
`mode?` | `"resize"` | `"reset"` | `"none"` | `"hide"` | `"show"` | `"normal"` | `"active"`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:514
(opens new window)

### # updateHoverStyle

▸ updateHoverStyle(`items`, `mode`, `enabled`): `void`

#### # Parameters

Name | Type
--- | ---
`items` | `InteractionItem`[]
`mode` | `"dataset"`
`enabled` | `boolean`

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:538
(opens new window)

### # getChart

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

#### # Parameters

Name | Type
--- | ---
`key` | `string` | `HTMLCanvasElement` | `CanvasRenderingContext2D`

#### # Returns

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

#### # Defined in

index.esm.d.ts:547
(opens new window)

### # register

▸ `Static` register(...`items`): `void`

#### # Parameters

Name | Type
--- | ---
`...items` | `ChartComponentLike`[]

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:548
(opens new window)

### # unregister

▸ `Static` unregister(...`items`): `void`

#### # Parameters

Name | Type
--- | ---
`...items` | `ChartComponentLike`[]

#### # Returns

`void`

#### # Defined in

index.esm.d.ts:549
(opens new window)