BarChartProAPI
React BarChartPro 组件的 API 参考文档。了解此导出模块的 props、CSS 和其他 API。
演示
导入
import { BarChartPro } from '@mui/x-charts-pro/BarChartPro';
// or
import { BarChartPro } from '@mui/x-charts-pro';
通过阅读此关于最小化捆绑包大小的指南,了解它们之间的差异。
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
series* | Array<object> | - | 要在柱状图中显示的系列。 BarSeriesType 对象的数组。 |
axisHighlight | { x?: 'band' | 'line' | 'none', y?: 'band' | 'line' | 'none' } | - | 坐标轴高亮的配置。默认设置为柱状图方向的 'band'。取决于 有关更多详细信息,请参阅高亮文档。 |
barLabel | 'value' | func | - | 如果提供,该函数将用于格式化柱状图的标签。可以设置为 'value' 以显示当前值。 |
borderRadius | number | - | 定义柱状图元素的边框半径。 |
bottomAxis | object | string | xAxisIds[0] 第一个提供的坐标轴的 ID | 指示在图表底部显示哪个坐标轴。可以是字符串(坐标轴的 ID)或 |
colors | Array<string> | func | blueberryTwilightPalette | 用于着色多个系列的调色板。 |
dataset | Array<object> | - | 对象数组,可用于使用其 |
disableAxisListener | bool | false | 如果为 |
grid | { horizontal?: bool, vertical?: bool } | - | 在背景中显示笛卡尔网格的选项。 |
height | number | - | 图表的高度,单位为 px。如果未定义,则采用父元素的高度。 |
highlightedItem | { dataIndex?: number, seriesId?: number | string } | - | 当前高亮的项目。将高亮变为受控 prop。 |
layout | 'horizontal' | 'vertical' | 'vertical' | 柱状图元素的方向。 |
leftAxis | object | string | yAxisIds[0] 第一个提供的坐标轴的 ID | 指示在图表左侧显示哪个坐标轴。可以是字符串(坐标轴的 ID)或 |
loading | bool | false | 如果为 |
margin | { bottom?: number, left?: number, right?: number, top?: number } | object 取决于图表类型。 | SVG 和绘图区域之间的边距。它用于为额外信息(例如 x 轴和 y 轴或图例)留出一些空间。接受具有可选属性的对象: |
onAxisClick | func | - | 为 onClick 事件调用的函数。第二个参数包含有关当前鼠标位置的所有折线/柱状图元素的信息。 签名: function(event: MouseEvent, data: null | AxisData) => void
|
onHighlightChange | func | - | 当高亮项目更改时触发的回调。 签名: function(highlightedItem: HighlightItemData | null) => void
|
onItemClick | func | - | 单击柱状图项目时触发的回调。 签名: function(event: React.MouseEvent
|
onZoomChange | func | - | 当缩放已更改时触发的回调。 签名: function(zoomData: Array
|
resolveSizeBeforeRender | bool | false | 图表将在首次渲染之前尝试等待父容器解析其大小。 |
rightAxis | object | string | null | 指示在图表右侧显示哪个坐标轴。可以是字符串(坐标轴的 ID)或 |
skipAnimation | bool | - | 如果为 |
slotProps | object | {} | 用于每个组件插槽的 props。 |
slots | object | {} | 可覆盖的组件插槽。 有关更多详细信息,请参阅下面的插槽 API。 |
tooltip | { axisContent?: elementType, classes?: object, itemContent?: elementType, slotProps?: object, slots?: object, trigger?: 'axis' | 'item' | 'none' } | - | 工具提示的配置。 有关更多详细信息,请参阅工具提示文档。 |
topAxis | object | string | null | 指示在图表顶部显示哪个坐标轴。可以是字符串(坐标轴的 ID)或 |
width | number | - | 图表的宽度,单位为 px。如果未定义,则采用父元素的宽度。 |
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, zoom?: { filterMode?: 'discard' | 'keep', maxEnd?: number, maxSpan?: number, minSpan?: number, minStart?: number, panning?: bool, step?: number } | bool }> | - | 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, zoom?: { filterMode?: 'discard' | 'keep', maxEnd?: number, maxSpan?: number, minSpan?: number, minStart?: number, panning?: bool, step?: number } | bool }> | - | y 轴的配置。如果未提供,则使用默认坐标轴配置。 AxisConfig 对象的数组。 |
zoom | Array<{ axisId: number | string, end: number, start: number }> | - | 与每个坐标轴相关的缩放数据列表。 |
源代码
如果您在此页面中找不到信息,请考虑查看组件的实现以获取更多详细信息。