ChartContainerAPI
React ChartContainer 組件的 API 參考文檔。了解此導出模組的 props、CSS 和其他 API。
示範
導入
import { ChartContainer } from '@mui/x-charts/ChartContainer';
// or
import { ChartContainer } from '@mui/x-charts';
// or
import { ChartContainer } from '@mui/x-charts-pro';
請閱讀這篇關於最小化 bundle size 的指南,以了解差異。
原生組件的 Props 也可用。
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
height* | number | - | 圖表的高度,單位為 px。 |
series* | Array<object> | - | 要顯示的 series 陣列。每種 series 類型都有其獨特性。請參閱相應的文檔頁面以了解更多資訊。 |
width* | number | - | 圖表的寬度,單位為 px。 |
colors | Array<string> | func | blueberryTwilightPalette | 用於為多個 series 上色的調色盤。 |
dataset | Array<object> | - | 一個物件陣列,可用於使用其 |
disableAxisListener | bool | false | 如果為 |
highlightedItem | { dataIndex?: number, seriesId?: number | string } | - | 當前醒目提示的項目。將醒目提示變成受控的 prop。 |
margin | { bottom?: number, left?: number, right?: number, top?: number } | object Depends on the charts type. | SVG 和繪圖區域之間的邊距。它用於為額外資訊(例如 x 軸和 y 軸或圖例)留出一些空間。接受具有可選屬性的物件: |
onHighlightChange | func | - | 當醒目提示的項目變更時觸發的回調。 Signature: function(highlightedItem: HighlightItemData | null) => void
|
plugins | Array<object> | - | 定義如何預處理數據的插件陣列。如果未提供,則容器支援線條圖、條狀圖、散佈圖和圓餅圖。 |
skipAnimation | bool | - | 如果為 |
xAxis | Array<{ classes?: object, colorMap?: { colors: Array<string>, type: 'ordinal', unknownColor?: string, values?: Array<Date | number | string> } | { color: Array<string> | func, max?: Date | number, min?: Date | number, type: 'continuous' } | { colors: Array<string>, thresholds: Array<Date | number>, type: 'piecewise' }, data?: array, dataKey?: string, disableLine?: bool, disableTicks?: bool, domainLimit?: 'nice' | 'strict' | func, fill?: string, hideTooltip?: bool, id?: number | string, label?: string, labelFontSize?: number, labelStyle?: object, max?: Date | number, min?: Date | number, position?: 'bottom' | 'top', reverse?: bool, scaleType?: 'band' | 'linear' | 'log' | 'point' | 'pow' | 'sqrt' | 'time' | 'utc', slotProps?: object, slots?: object, stroke?: string, sx?: Array<func | object | bool> | func | object, tickFontSize?: number, tickInterval?: 'auto' | array | func, tickLabelInterval?: 'auto' | func, tickLabelPlacement?: 'middle' | 'tick', tickLabelStyle?: object, tickMaxStep?: number, tickMinStep?: number, tickNumber?: number, tickPlacement?: 'end' | 'extremities' | 'middle' | 'start', tickSize?: number, valueFormatter?: func }> | - | x 軸的配置。如果未提供,則使用預設軸配置。 AxisConfig 物件的陣列。 |
yAxis | Array<{ classes?: object, colorMap?: { colors: Array<string>, type: 'ordinal', unknownColor?: string, values?: Array<Date | number | string> } | { color: Array<string> | func, max?: Date | number, min?: Date | number, type: 'continuous' } | { colors: Array<string>, thresholds: Array<Date | number>, type: 'piecewise' }, data?: array, dataKey?: string, disableLine?: bool, disableTicks?: bool, domainLimit?: 'nice' | 'strict' | func, fill?: string, hideTooltip?: bool, id?: number | string, label?: string, labelFontSize?: number, labelStyle?: object, max?: Date | number, min?: Date | number, position?: 'left' | 'right', reverse?: bool, scaleType?: 'band' | 'linear' | 'log' | 'point' | 'pow' | 'sqrt' | 'time' | 'utc', slotProps?: object, slots?: object, stroke?: string, sx?: Array<func | object | bool> | func | object, tickFontSize?: number, tickInterval?: 'auto' | array | func, tickLabelInterval?: 'auto' | func, tickLabelPlacement?: 'middle' | 'tick', tickLabelStyle?: object, tickMaxStep?: number, tickMinStep?: number, tickNumber?: number, tickPlacement?: 'end' | 'extremities' | 'middle' | 'start', tickSize?: number, valueFormatter?: func }> | - | y 軸的配置。如果未提供,則使用預設軸配置。 AxisConfig 物件的陣列。 |
zAxis | Array<{ colorMap?: { colors: Array<string>, type: 'ordinal', unknownColor?: string, values?: Array<Date | number | string> } | { color: Array<string> | func, max?: Date | number, min?: Date | number, type: 'continuous' } | { colors: Array<string>, thresholds: Array<Date | number>, type: 'piecewise' }, data?: array, dataKey?: string, id?: string, max?: number, min?: number }> | - | z 軸的配置。 |
ref
會轉發到根元素。原始碼
如果您在此頁面中找不到資訊,請考慮查看組件的實作以獲取更多詳細資訊。