Chart

fun <Model : ChartEntryModel> Chart(chart: Chart<Model>, chartModelProducer: ChartModelProducer<Model>, modifier: Modifier = Modifier, startAxis: AxisRenderer<AxisPosition.Vertical.Start>? = null, topAxis: AxisRenderer<AxisPosition.Horizontal.Top>? = null, endAxis: AxisRenderer<AxisPosition.Vertical.End>? = null, bottomAxis: AxisRenderer<AxisPosition.Horizontal.Bottom>? = null, marker: Marker? = null, markerVisibilityChangeListener: MarkerVisibilityChangeListener? = null, legend: Legend? = null, chartScrollSpec: ChartScrollSpec<Model> = rememberChartScrollSpec(), isZoomEnabled: Boolean = true, diffAnimationSpec: AnimationSpec<Float>? = defaultDiffAnimationSpec, runInitialAnimation: Boolean = true, fadingEdges: FadingEdges? = null, autoScaleUp: AutoScaleUp = AutoScaleUp.Full, chartScrollState: ChartScrollState = rememberChartScrollState(), horizontalLayout: HorizontalLayout = HorizontalLayout.segmented(), getXStep: (Model) -> Float? = null, placeholder: @Composable BoxScope.() -> Unit = {})

Displays a chart.

Parameters

chart

the chart itself (excluding axes, markers, etc.). You can use lineChart or columnChart, or provide a custom Chart implementation.

chartModelProducer

creates and updates the ChartEntryModel for the chart.

modifier

the modifier to be applied to the chart.

startAxis

the axis displayed at the start of the chart.

topAxis

the axis displayed at the top of the chart.

endAxis

the axis displayed at the end of the chart.

bottomAxis

the axis displayed at the bottom of the chart.

marker

appears when the chart is touched, highlighting the entry or entries nearest to the touch point.

markerVisibilityChangeListener

allows for listening to marker visibility changes.

legend

an optional legend for the chart.

chartScrollSpec

houses scrolling-related settings.

isZoomEnabled

whether zooming in and out is enabled.

diffAnimationSpec

the animation spec used for difference animations.

runInitialAnimation

whether to display an animation when the chart is created. In this animation, the value of each chart entry is animated from zero to the actual value. This animation isn’t run in previews.

fadingEdges

applies a horizontal fade to the edges of the chart area for scrollable charts.

autoScaleUp

defines whether the content of the chart should be scaled up when the dimensions are such that, at a scale factor of 1, an empty space would be visible near the end edge of the chart.

chartScrollState

houses information on the chart’s scroll state. Allows for programmatic scrolling.

horizontalLayout

defines how the chart’s content is positioned horizontally.

getXStep

overrides the x step (the difference between the x values of neighboring major entries). If this is null, the default x step (ChartEntryModel.xGcd) is used.

placeholder

shown when no ChartEntryModel is available.


fun <Model : ChartEntryModel> Chart(chart: Chart<Model>, model: Model, modifier: Modifier = Modifier, startAxis: AxisRenderer<AxisPosition.Vertical.Start>? = null, topAxis: AxisRenderer<AxisPosition.Horizontal.Top>? = null, endAxis: AxisRenderer<AxisPosition.Vertical.End>? = null, bottomAxis: AxisRenderer<AxisPosition.Horizontal.Bottom>? = null, marker: Marker? = null, markerVisibilityChangeListener: MarkerVisibilityChangeListener? = null, legend: Legend? = null, chartScrollSpec: ChartScrollSpec<Model> = rememberChartScrollSpec(), isZoomEnabled: Boolean = true, oldModel: Model? = null, fadingEdges: FadingEdges? = null, autoScaleUp: AutoScaleUp = AutoScaleUp.Full, chartScrollState: ChartScrollState = rememberChartScrollState(), horizontalLayout: HorizontalLayout = HorizontalLayout.segmented(), getXStep: (Model) -> Float? = null)

Displays a chart.

This function accepts a ChartEntryModel. For dynamic data, use the function overload that accepts a ChartModelProducer instance.

Parameters

chart

the chart itself (excluding axes, markers, etc.). You can use lineChart or columnChart, or provide a custom Chart implementation.

model

the ChartEntryModel for the chart.

modifier

the modifier to be applied to the chart.

startAxis

the axis displayed at the start of the chart.

topAxis

the axis displayed at the top of the chart.

endAxis

the axis displayed at the end of the chart.

bottomAxis

the axis displayed at the bottom of the chart.

marker

appears when the chart is touched, highlighting the entry or entries nearest to the touch point.

markerVisibilityChangeListener

allows for listening to marker visibility changes.

legend

an optional legend for the chart.

chartScrollSpec

houses scrolling-related settings.

isZoomEnabled

whether zooming in and out is enabled.

oldModel

the chart’s previous ChartEntryModel. This is used to determine whether to perform an automatic scroll.

fadingEdges

applies a horizontal fade to the edges of the chart area for scrollable charts.

autoScaleUp

defines whether the content of the chart should be scaled up when the dimensions are such that, at a scale factor of 1, an empty space would be visible near the end edge of the chart.

chartScrollState

houses information on the chart’s scroll state. Allows for programmatic scrolling.

horizontalLayout

defines how the chart’s content is positioned horizontally.

getXStep

overrides the x step (the difference between the x values of neighboring major entries). If this is null, the default x step (ChartEntryModel.xGcd) is used.