# 介面:CoreChartOptions<TType>

# 型別參數

名稱 型別
TType 繼承自 ChartType

# 繼承關係

# 屬性

# animation

animation: false | AnimationSpec<TType> & { onComplete?: (this: Chart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>, event: AnimationEvent) => void ; onProgress?: (this: Chart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>, event: AnimationEvent) => void }

# 繼承自

AnimationOptions.animation

# 定義於

types/index.d.ts:1747 (開啟新視窗)


# animations

animations: AnimationsSpec<TType>

# 繼承自

AnimationOptions.animations

# 定義於

types/index.d.ts:1757 (開啟新視窗)


# aspectRatio

aspectRatio: number

畫布的長寬比 (即寬度 / 高度,值為 1 代表正方形畫布)。請注意,如果高度已明確定義為屬性或透過樣式定義,則會忽略此選項。

預設值

2

# 定義於

types/index.d.ts:1645 (開啟新視窗)


# backgroundColor

backgroundColor: Scriptable<Color, ScriptableContext<TType>>

基本背景顏色

請參閱

Defaults.backgroundColor

# 定義於

types/index.d.ts:1614 (開啟新視窗)


# borderColor

borderColor: Scriptable<Color, ScriptableContext<TType>>

基本邊框顏色

請參閱

Defaults.borderColor

# 定義於

types/index.d.ts:1619 (開啟新視窗)


# clip

clip: number | false | ChartArea

如何相對於 chartArea 裁剪。正值允許溢出,負值裁剪 chartArea 內部的像素數。0 = 在 chartArea 裁剪。也可以針對每個邊配置裁剪:clip: {left: 5, top: false, right: -2, bottom: 0}

# 定義於

types/index.d.ts:1603 (開啟新視窗)


# color

color: Scriptable<Color, ScriptableContext<TType>>

基本顏色

請參閱

Defaults.color

# 定義於

types/index.d.ts:1609 (開啟新視窗)


# datasets

datasets: Object

# 型別宣告

名稱 型別
bar BarControllerDatasetOptions
bubble BubbleControllerDatasetOptions
doughnut DoughnutControllerDatasetOptions
line LineControllerDatasetOptions & FillerControllerDatasetOptions
pie DoughnutControllerDatasetOptions
polarArea PolarAreaControllerDatasetOptions
radar RadarControllerDatasetOptions & FillerControllerDatasetOptions
scatter LineControllerDatasetOptions

# 定義於

types/index.d.ts:1590 (開啟新視窗)


# devicePixelRatio

devicePixelRatio: number

覆寫視窗的預設 devicePixelRatio。

預設值

window.devicePixelRatio

# 定義於

types/index.d.ts:1662

events: HTMLElementEventMap 的 keyof 陣列

events 選項定義圖表應監聽哪些瀏覽器事件以顯示工具提示和懸停效果。

預設值

['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']

# 定義於

types/index.d.ts:1672 (opens new window)


# font

font: Partial<FontSpec>

基礎字型

請參閱

Defaults.font

# 定義於

types/index.d.ts:1624 (opens new window)


# hover

hover: CoreInteractionOptions

# 定義於

types/index.d.ts:1666 (opens new window)


# indexAxis

indexAxis: "x" | "y"

圖表的基本軸。垂直圖表為 'x',水平圖表為 'y'。

預設值

'x'

# 定義於

types/index.d.ts:1598 (opens new window)


# interaction

interaction: CoreInteractionOptions

# 定義於

types/index.d.ts:1664 (opens new window)


# layout

layout: Partial<{ autoPadding: boolean ; padding: Scriptable<Padding, ScriptableContext<TType>> }>

# 定義於

types/index.d.ts:1684 (opens new window)


# locale

locale: string

用於數字格式化的地區設定(使用 Intl.NumberFormat)。

預設值

使用者瀏覽器設定

# 定義於

types/index.d.ts:1651 (opens new window)


# maintainAspectRatio

maintainAspectRatio: boolean

調整大小時,保持原始畫布的長寬比(寬度 / 高度)。為了使此選項正常運作,圖表必須在其專用的容器中。

預設值

true

# 定義於

types/index.d.ts:1634 (opens new window)


# normalized

normalized: boolean

如果您提供的數據具有唯一、排序且跨數據集一致的索引,並且提供 normalized: true 選項以告知 Chart.js 您已完成此操作,則 Chart.js 的速度最快。

# 繼承自

ParsingOptions.normalized

# 定義於

types/index.d.ts:63 (opens new window)


# parsing

parsing: false | { [key: string]: string; }

如何解析資料集。可以透過在圖表選項或資料集中指定 parsing: false 來停用解析。如果停用解析,則資料必須經過排序,並且採用相關圖表類型和比例尺內部使用的格式。

# 繼承自

ParsingOptions.parsing

# 定義於

types/index.d.ts:54 (opens new window)


# resizeDelay

resizeDelay: number

將調整大小更新延遲給定的毫秒數。這可以透過對元素的更新進行去抖動來簡化調整大小的過程。

預設值

0

# 定義於

types/index.d.ts:1639 (opens new window)


# responsive

responsive: boolean

當其容器調整大小時,調整圖表畫布的大小(重要注意事項...)。

預設值

true

# 定義於

types/index.d.ts:1629 (opens new window)


# transitions

transitions: TransitionsSpec<TType>

# 繼承自

AnimationOptions.transitions

# 定義於

types/index.d.ts:1758 (opens new window)

# 方法

# onClick

onClick(event, elements, chart): void

如果事件類型為 'mouseup' 或 'click',則會調用此函數。傳遞事件、活動元素陣列和圖表。

# 參數

名稱 型別
event ChartEvent
elements ActiveElement[]
chart Chart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>

# 回傳值

void

# 定義於

types/index.d.ts:1682 (opens new window)


# onHover

onHover(event, elements, chart): void

當任何事件觸發時調用。傳遞事件、活動元素(條、點等)陣列和圖表。

# 參數

名稱 型別
event ChartEvent
elements ActiveElement[]
chart Chart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>

# 回傳值

void

# 定義於

types/index.d.ts:1677 (opens new window)


# onResize

onResize(chart, size): void

當發生調整大小時調用。傳遞兩個參數:圖表實例和新大小。

# 參數

名稱 型別
chart Chart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>
size 物件
size.height number
size.width number

# 回傳值

void

# 定義於

types/index.d.ts:1656 (opens new window)