XYGraph

fun <X, Y> XYGraph(xAxisModel: AxisModel<X>, yAxisModel: AxisModel<Y>, xAxisContent: AxisContent<X>, yAxisContent: AxisContent<Y>, modifier: Modifier = Modifier, gridStyle: GridStyle = rememberGridStyle(), gestureConfig: GestureConfig = GestureConfig(), onPointerEvent: XYGraphPointerEventScope<X, Y>.(PointerEvent) -> Unit? = null, content: @Composable XYGraphScope<X, Y>.() -> Unit)

A composable that lays out a chart consisting of two axes, a grid, and plot content.

The layout process is performed in several steps:

  1. The sizes of the axis titles are determined.

  2. The axis models are consulted to determine the tick values.

  3. The axis labels are sub-composed and measured to determine their sizes.

  4. The remaining space is allocated to the plot area.

  5. The grid, axes, and plot content are composed and placed in the plot area.

The content of the XYGraph is a Composable lambda that receives an XYGraphScope. This scope provides the context of the graph's axes and allows for the conversion between data coordinates and screen coordinates, which is necessary for plotting data.

Parameters

xAxisModel

The AxisModel for the x-axis, which controls the range, coordinate transformation, and tick marks.

yAxisModel

The AxisModel for the y-axis, which controls the range, coordinate transformation, and tick marks.

xAxisContent

The content for the x-axis, including the title and labels. See AxisContent.

yAxisContent

The content for the y-axis, including the title and labels. See AxisContent.

modifier

The modifier to be applied to the graph.

gridStyle

The styling for the major and minor grid lines. See GridStyle.

gestureConfig

Configuration for pan and zoom gestures. See GestureConfig.

onPointerEvent

A callback that is invoked when a pointer event occurs within the plot area. The XYGraphPointerEventScope provides a scale function to convert from screen to data coordinates.

content

The composable content to be displayed within the graph, which typically includes one or more plot types like io.github.koalaplot.core.line.LinePlot or io.github.koalaplot.core.line.AreaPlot.

Type Parameters

X

The data type for the x-axis.

Y

The data type for the y-axis.