XYGraph
A composable that lays out a chart consisting of two axes, a grid, and plot content.
The layout process is performed in several steps:
The sizes of the axis titles are determined.
The axis models are consulted to determine the tick values.
The axis labels are sub-composed and measured to determine their sizes.
The remaining space is allocated to the plot area.
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
The data type for the x-axis.
The data type for the y-axis.
The AxisModel for the x-axis, which controls the range, coordinate transformation, and tick marks.
The AxisModel for the y-axis, which controls the range, coordinate transformation, and tick marks.
The content for the x-axis, including the title and labels. See AxisContent.
The content for the y-axis, including the title and labels. See AxisContent.
The modifier to be applied to the graph.
The styling for the major and minor grid lines. See GridStyle.
Configuration for pan and zoom gestures. See GestureConfig.
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.
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.
Deprecated
Use the overload that accepts AxisContent and GridStyle objects instead.
Replace with
XYGraph(
xAxisModel = xAxisModel,
yAxisModel = yAxisModel,
modifier = modifier,
xAxisContent = AxisContent(
style = xAxisStyle,
labels = { xAxisLabels(it) },
title = xAxisTitle,
),
yAxisContent = AxisContent(
style = yAxisStyle,
labels = { yAxisLabels(it) },
title = yAxisTitle,
),
gridStyle = GridStyle(
horizontalMajorStyle = horizontalMajorGridLineStyle,
horizontalMinorStyle = horizontalMinorGridLineStyle,
verticalMajorStyle = verticalMajorGridLineStyle,
verticalMinorStyle = verticalMinorGridLineStyle,
),
gestureConfig = gestureConfig,
onPointerMove = onPointerMove,
content = content,
)Provides a set of X-Y axes and grid for displaying X-Y plots.
Parameters
The data type for the x-axis
The data type for the y-axis
x-axis state controlling the display of the axis and coordinate transformation
y-axis state controlling the display of the axis and coordinate transformation
Style for the x-axis
Composable to display labels for specific x-axis values
Title for the X-axis
Style for the y-axis
Composable to display labels for specific y-axis values
Title for the y-axis
Configuration for gesture handling. See GestureConfig
Callback invoked when the pointer moves with the current pointer position in plot coordinates
The content to be displayed, which should include one plot for each series to be plotted on this XYGraph.
Deprecated
This overload is deprecated. Call the primary XYGraph function and use the rememberXAxisContent() and rememberYAxisContent() helpers.
Replace with
XYGraph(
xAxisModel = xAxisModel,
yAxisModel = yAxisModel,
modifier = modifier,
xAxisContent = rememberStringAxisContent(label = xAxisLabels, title = xAxisTitle, style = xAxisStyle),
yAxisContent = rememberStringAxisContent(label = yAxisLabels, title = yAxisTitle, style = yAxisStyle),
gridStyle = GridStyle(
horizontalMajorStyle = horizontalMajorGridLineStyle,
horizontalMinorStyle = horizontalMinorGridLineStyle,
verticalMajorStyle = verticalMajorGridLineStyle,
verticalMinorStyle = verticalMinorGridLineStyle
),
gestureConfig = gestureConfig,
onPointerMove = onPointerMove,
content = content
)An XYGraph overload that takes Strings for axis labels and titles instead of Composables for use cases where custom styling is not required.
Provides a set of X-Y axes and grid for displaying an X-Y plot.
Parameters
The data type for the x-axis
The data type for the y-axis
x-axis state controlling the display of the axis and coordinate transformation
y-axis state controlling the display of the axis and coordinate transformation
Style for the x-axis
String factory of x-axis label Strings
Title for the X-axis
Style for the y-axis
String factory of y-axis label Strings
Title for the y-axis
Configuration for gesture handling. See GestureConfig
Callback invoked when the pointer moves with the current pointer position in plot coordinates
The content to be displayed within this graph, which should include one plot for each data series to be plotted.