diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/AxisLinePreviews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/AxisLinePreviews.kt index d28b5750d..2751f9203 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/AxisLinePreviews.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/AxisLinePreviews.kt @@ -22,9 +22,9 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.patrykandpatrick.vico.compose.axis.axisLabelComponent -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.endAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberEndAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.component.lineComponent @@ -91,11 +91,11 @@ public fun HorizontalAxisTextInside() { Chart( chart = columnChart(), model = model, - startAxis = startAxis( + startAxis = rememberStartAxis( horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside, label = label, ), - endAxis = endAxis( + endAxis = rememberEndAxis( horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside, guideline = null, label = label, @@ -121,16 +121,16 @@ public fun HorizontalAxisTextInsideAndBottomAxis() { Chart( chart = columnChart(), model = model, - startAxis = startAxis( + startAxis = rememberStartAxis( horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside, label = label, ), - endAxis = endAxis( + endAxis = rememberEndAxis( horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside, guideline = null, label = label, ), - bottomAxis = bottomAxis(), + bottomAxis = rememberBottomAxis(), ) } } @@ -142,10 +142,10 @@ public fun HorizontalAxisTextOutside() { Chart( chart = columnChart(), model = model, - startAxis = startAxis( + startAxis = rememberStartAxis( horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Outside, ), - endAxis = endAxis( + endAxis = rememberEndAxis( horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Outside, guideline = null, ), @@ -160,10 +160,10 @@ public fun HorizontalAxisGuidelineDoesNotOverlayBottomAxisLine() { Chart( chart = columnChart(), model = model, - startAxis = startAxis( + startAxis = rememberStartAxis( horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Outside, ), - bottomAxis = bottomAxis(), + bottomAxis = rememberBottomAxis(), ) } } diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ColumnChartsWithNegativeValuesPreviews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ColumnChartsWithNegativeValuesPreviews.kt index 589f17942..6c92f521d 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ColumnChartsWithNegativeValuesPreviews.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ColumnChartsWithNegativeValuesPreviews.kt @@ -23,8 +23,8 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.core.axis.AxisItemPlacer @@ -49,8 +49,8 @@ public fun SingleColumnChartWithNegativeValues() { ), ), model = model, - startAxis = startAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 9) }), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 9) }), + bottomAxis = rememberBottomAxis(), ) } } @@ -64,8 +64,8 @@ public fun SingleColumnChartWithNegativeValuesAndDataLabels() { dataLabel = textComponent(), ), model = model, - startAxis = startAxis(), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(), + bottomAxis = rememberBottomAxis(), ) } } @@ -82,8 +82,8 @@ public fun SingleColumnChartWithNegativeValuesAndAxisValuesOverridden() { ), ), model = model, - startAxis = startAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 4) }), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 4) }), + bottomAxis = rememberBottomAxis(), ) } } @@ -100,8 +100,8 @@ public fun SingleColumnChartWithNegativeValuesAndAxisValuesOverridden2() { ), ), model = model, - startAxis = startAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 3) }), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 3) }), + bottomAxis = rememberBottomAxis(), ) } } diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ContainedChartsPreview.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ContainedChartsPreview.kt index c4e571a01..7f603b641 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ContainedChartsPreview.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ContainedChartsPreview.kt @@ -22,9 +22,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.endAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberEndAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.chart.line.lineChart @@ -86,13 +86,13 @@ private fun getLineChart( ) private val startAxis: Axis - @Composable get() = startAxis( + @Composable get() = rememberStartAxis( label = textComponent(color = Color.Black), itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 5) }, ) private val endAxis: Axis - @Composable get() = endAxis( + @Composable get() = rememberEndAxis( label = textComponent(color = Color.DarkGray), itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 7) }, ) @@ -109,7 +109,7 @@ public fun ChartWithIndependentAxes(modifier: Modifier = Modifier) { chart = composedChart, model = model1 + model2, startAxis = startAxis, - bottomAxis = bottomAxis(), + bottomAxis = rememberBottomAxis(), endAxis = endAxis, modifier = modifier, ) @@ -126,7 +126,7 @@ public fun ChartWithDependentAxes(modifier: Modifier = Modifier) { chart = composedChart, model = model1 + model2, startAxis = startAxis, - bottomAxis = bottomAxis(), + bottomAxis = rememberBottomAxis(), endAxis = endAxis, modifier = modifier, ) @@ -139,7 +139,7 @@ public fun ColumnChart(modifier: Modifier = Modifier) { chart = getColumnChart(markerMap = markerMap), model = model1, startAxis = startAxis, - bottomAxis = bottomAxis(), + bottomAxis = rememberBottomAxis(), modifier = modifier, ) } @@ -151,7 +151,7 @@ public fun LineChart(modifier: Modifier = Modifier) { chart = getLineChart(markerMap = markerMap), model = model2, startAxis = startAxis, - bottomAxis = bottomAxis(), + bottomAxis = rememberBottomAxis(), modifier = modifier, ) } diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/LineChartPreviews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/LineChartPreviews.kt index 8a3d1a80b..4dc2d74b7 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/LineChartPreviews.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/LineChartPreviews.kt @@ -24,7 +24,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.line.lineChart import com.patrykandpatrick.vico.compose.chart.line.lineSpec @@ -79,7 +79,7 @@ public fun RegularLineChart() { Chart( chart = lineChart(), model = model1, - startAxis = startAxis(), + startAxis = rememberStartAxis(), ) } @@ -94,7 +94,7 @@ public fun RegularLineChartExpanded() { ), ), model = model1, - startAxis = startAxis(), + startAxis = rememberStartAxis(), ) } @@ -109,7 +109,7 @@ public fun RegularLineChartCollapsed() { ), ), model = model1, - startAxis = startAxis(), + startAxis = rememberStartAxis(), ) } @@ -131,7 +131,7 @@ public fun ComposedLineChart() { ), ), model = model1 + model2, - startAxis = startAxis(), + startAxis = rememberStartAxis(), ) } @@ -151,6 +151,6 @@ public fun ComposedLineChartCollapsed() { ), ), model = model1 + model2, - startAxis = startAxis(), + startAxis = rememberStartAxis(), ) } diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/StackedColumnChartsWithNegativeValuesPreviews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/StackedColumnChartsWithNegativeValuesPreviews.kt index efbc32212..e893f7acd 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/StackedColumnChartsWithNegativeValuesPreviews.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/StackedColumnChartsWithNegativeValuesPreviews.kt @@ -24,8 +24,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.component.lineComponent @@ -68,8 +68,8 @@ public fun StackedColumnChartWithNegativeValues() { mergeMode = Stack, ), model = model, - startAxis = startAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 8) }), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 8) }), + bottomAxis = rememberBottomAxis(), ) } } @@ -85,8 +85,8 @@ public fun StackedColumnChartWithNegativeValuesAndDataLabels() { mergeMode = Stack, ), model = model, - startAxis = startAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 8) }), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 8) }), + bottomAxis = rememberBottomAxis(), ) } } @@ -105,8 +105,8 @@ public fun StackedColumnChartWithNegativeValuesAndAxisValuesOverridden() { mergeMode = Stack, ), model = model, - startAxis = startAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 4) }), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 4) }), + bottomAxis = rememberBottomAxis(), ) } } @@ -125,8 +125,8 @@ public fun StackedColumnChartWithNegativeValuesAndAxisValuesOverridden2() { mergeMode = Stack, ), model = model, - startAxis = startAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 3) }), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 3) }), + bottomAxis = rememberBottomAxis(), ) } } diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ThresholdLinePreviews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ThresholdLinePreviews.kt index 37b6eb011..f4c25ac82 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ThresholdLinePreviews.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ThresholdLinePreviews.kt @@ -27,8 +27,8 @@ import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.chart.scroll.rememberChartScrollSpec @@ -95,8 +95,8 @@ public fun ThresholdLine() { ) }, model = model, - startAxis = startAxis(), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(), + bottomAxis = rememberBottomAxis(), chartScrollSpec = rememberChartScrollSpec(isScrollEnabled = false), ) } @@ -156,8 +156,8 @@ public fun ThresholdLineWithCustomText() { ) }, model = model, - startAxis = startAxis(), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(), + bottomAxis = rememberBottomAxis(), chartScrollSpec = rememberChartScrollSpec(isScrollEnabled = false), ) } @@ -179,8 +179,8 @@ public fun RangedThresholdLine() { ) }, model = model, - startAxis = startAxis(), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(), + bottomAxis = rememberBottomAxis(), chartScrollSpec = rememberChartScrollSpec(isScrollEnabled = false), ) } @@ -210,8 +210,8 @@ public fun RangedThresholdLineWithBrushShader() { ) }, model = model, - startAxis = startAxis(), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(), + bottomAxis = rememberBottomAxis(), chartScrollSpec = rememberChartScrollSpec(isScrollEnabled = false), ) } @@ -241,8 +241,8 @@ public fun RangedThresholdLineWithComponentShader() { ) }, model = model, - startAxis = startAxis(), - bottomAxis = bottomAxis(), + startAxis = rememberStartAxis(), + bottomAxis = rememberBottomAxis(), chartScrollSpec = rememberChartScrollSpec(isScrollEnabled = false), ) } diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart1.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart1.kt index 73d71a7f4..34e2d997b 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart1.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart1.kt @@ -20,8 +20,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.viewinterop.AndroidViewBinding -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.line.lineChart import com.patrykandpatrick.vico.compose.style.ProvideChartStyle @@ -47,8 +47,8 @@ private fun ComposeChart1(chartEntryModelProducer: ChartEntryModelProducer) { Chart( chart = lineChart(persistentMarkers = remember(marker) { mapOf(PERSISTENT_MARKER_X to marker) }), chartModelProducer = chartEntryModelProducer, - startAxis = startAxis(), - bottomAxis = bottomAxis(guideline = null), + startAxis = rememberStartAxis(), + bottomAxis = rememberBottomAxis(guideline = null), marker = marker, runInitialAnimation = false, ) diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart2.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart2.kt index d708ce743..4b12520bc 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart2.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart2.kt @@ -22,8 +22,8 @@ import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidViewBinding -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.component.shapeComponent @@ -71,8 +71,8 @@ private fun ComposeChart2(chartEntryModelProducer: ChartEntryModelProducer) { decorations = remember(thresholdLine) { listOf(thresholdLine) }, ), chartModelProducer = chartEntryModelProducer, - startAxis = startAxis(valueFormatter = startAxisValueFormatter, itemPlacer = startAxisItemPlacer), - bottomAxis = bottomAxis(itemPlacer = bottomAxisItemPlacer), + startAxis = rememberStartAxis(valueFormatter = startAxisValueFormatter, itemPlacer = startAxisItemPlacer), + bottomAxis = rememberBottomAxis(itemPlacer = bottomAxisItemPlacer), marker = rememberMarker(), runInitialAnimation = false, horizontalLayout = horizontalLayout, diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart3.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart3.kt index d1f6d6e44..9f7b22257 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart3.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart3.kt @@ -23,8 +23,8 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidViewBinding import com.patrykandpatrick.vico.R -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.edges.rememberFadingEdges import com.patrykandpatrick.vico.compose.chart.layout.fullWidth @@ -58,7 +58,7 @@ private fun ComposeChart3(chartEntryModelProducer: ChartEntryModelProducer) { Chart( chart = lineChart(axisValuesOverrider = axisValueOverrider), chartModelProducer = chartEntryModelProducer, - startAxis = startAxis( + startAxis = rememberStartAxis( guideline = null, horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside, titleComponent = textComponent( @@ -70,7 +70,7 @@ private fun ComposeChart3(chartEntryModelProducer: ChartEntryModelProducer) { ), title = stringResource(R.string.y_axis), ), - bottomAxis = bottomAxis( + bottomAxis = rememberBottomAxis( titleComponent = textComponent( background = shapeComponent(Shapes.pillShape, color2), color = Color.White, diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart4.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart4.kt index 090f45c91..533c14e4c 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart4.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart4.kt @@ -21,8 +21,8 @@ import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidViewBinding -import com.patrykandpatrick.vico.compose.axis.horizontal.topAxis -import com.patrykandpatrick.vico.compose.axis.vertical.endAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberTopAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberEndAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.chart.line.lineChart @@ -73,8 +73,8 @@ private fun ComposeChart4(chartEntryModelProducer: ComposedChartEntryModelProduc Chart( chart = remember(columnChart, lineChart) { columnChart + lineChart }, chartModelProducer = chartEntryModelProducer, - topAxis = topAxis(), - endAxis = endAxis(), + topAxis = rememberTopAxis(), + endAxis = rememberEndAxis(), marker = rememberMarker(), runInitialAnimation = false, ) diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart5.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart5.kt index ebbe37cd7..26d0e04f4 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart5.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart5.kt @@ -20,8 +20,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.viewinterop.AndroidViewBinding -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.style.ProvideChartStyle @@ -72,11 +72,11 @@ private fun ComposeChart5(chartEntryModelProducer: ChartEntryModelProducer) { mergeMode = ColumnChart.MergeMode.Stack, ), chartModelProducer = chartEntryModelProducer, - startAxis = startAxis( + startAxis = rememberStartAxis( itemPlacer = startAxisItemPlacer, labelRotationDegrees = AXIS_LABEL_ROTATION_DEGREES, ), - bottomAxis = bottomAxis(labelRotationDegrees = AXIS_LABEL_ROTATION_DEGREES), + bottomAxis = rememberBottomAxis(labelRotationDegrees = AXIS_LABEL_ROTATION_DEGREES), marker = rememberMarker(), runInitialAnimation = false, ) diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart6.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart6.kt index 32f2384da..4d8add880 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart6.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart6.kt @@ -22,8 +22,8 @@ import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidViewBinding -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.component.shapeComponent @@ -72,8 +72,8 @@ private fun ComposeChart6(chartEntryModelProducer: ChartEntryModelProducer) { decorations = remember(thresholdLine) { listOf(thresholdLine) }, ), chartModelProducer = chartEntryModelProducer, - startAxis = startAxis(), - bottomAxis = bottomAxis(valueFormatter = bottomAxisValueFormatter), + startAxis = rememberStartAxis(), + bottomAxis = rememberBottomAxis(valueFormatter = bottomAxisValueFormatter), marker = rememberMarker(), runInitialAnimation = false, ) diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart7.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart7.kt index 44ea6e4a6..824021971 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart7.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart7.kt @@ -26,8 +26,8 @@ import androidx.compose.ui.unit.sp import androidx.compose.ui.viewinterop.AndroidViewBinding import com.patrykandpatrick.vico.R import com.patrykandpatrick.vico.compose.axis.axisLabelComponent -import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.line.lineChart import com.patrykandpatrick.vico.compose.component.shape.roundedCornerShape @@ -66,11 +66,11 @@ private fun ComposeChart7(chartEntryModelProducer: ChartEntryModelProducer) { }, ), chartModelProducer = chartEntryModelProducer, - startAxis = startAxis( + startAxis = rememberStartAxis( label = rememberStartAxisLabel(), horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside, ), - bottomAxis = bottomAxis(), + bottomAxis = rememberBottomAxis(), marker = rememberMarker(), legend = rememberLegend(), runInitialAnimation = false, diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart8.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart8.kt index 70ed836da..700d27e4d 100644 --- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart8.kt +++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart8.kt @@ -20,8 +20,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.viewinterop.AndroidViewBinding -import com.patrykandpatrick.vico.compose.axis.vertical.endAxis -import com.patrykandpatrick.vico.compose.axis.vertical.startAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberEndAxis +import com.patrykandpatrick.vico.compose.axis.vertical.rememberStartAxis import com.patrykandpatrick.vico.compose.chart.Chart import com.patrykandpatrick.vico.compose.chart.column.columnChart import com.patrykandpatrick.vico.compose.chart.line.lineChart @@ -58,8 +58,8 @@ private fun ComposeChart8(chartEntryModelProducer: ComposedChartEntryModelProduc Chart( chart = remember(columnChart, lineChart) { columnChart + lineChart }, chartModelProducer = chartEntryModelProducer, - startAxis = startAxis(guideline = null), - endAxis = endAxis(), + startAxis = rememberStartAxis(guideline = null), + endAxis = rememberEndAxis(), marker = rememberMarker(), runInitialAnimation = false, ) diff --git a/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/axis/horizontal/HorizontalAxis.kt b/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/axis/horizontal/HorizontalAxis.kt index d111e9848..55d2444e5 100644 --- a/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/axis/horizontal/HorizontalAxis.kt +++ b/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/axis/horizontal/HorizontalAxis.kt @@ -36,7 +36,7 @@ import com.patrykandpatrick.vico.core.component.shape.LineComponent import com.patrykandpatrick.vico.core.component.text.TextComponent /** - * Creates a top axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Top]). + * Creates and remembers a top axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Top]). * * @param label the [TextComponent] to use for the labels. * @param axis the [LineComponent] to use for the axis line. @@ -51,6 +51,113 @@ import com.patrykandpatrick.vico.core.component.text.TextComponent * @param itemPlacer determines for what _x_ values the [HorizontalAxis] is to display labels, ticks, and guidelines. */ @Composable +public fun rememberTopAxis( + label: TextComponent? = axisLabelComponent(), + axis: LineComponent? = axisLineComponent(), + tick: LineComponent? = axisTickComponent(), + tickLength: Dp = currentChartStyle.axis.axisTickLength, + guideline: LineComponent? = axisGuidelineComponent(), + valueFormatter: AxisValueFormatter = DecimalFormatAxisValueFormatter(), + sizeConstraint: Axis.SizeConstraint = Axis.SizeConstraint.Auto(), + labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, + titleComponent: TextComponent? = null, + title: CharSequence? = null, + itemPlacer: AxisItemPlacer.Horizontal = remember { AxisItemPlacer.Horizontal.default() }, +): HorizontalAxis = + remember { createHorizontalAxis() }.apply { + this.label = label + axisLine = axis + this.tick = tick + this.guideline = guideline + this.valueFormatter = valueFormatter + tickLengthDp = tickLength.value + this.sizeConstraint = sizeConstraint + this.labelRotationDegrees = labelRotationDegrees + this.titleComponent = titleComponent + this.title = title + this.itemPlacer = itemPlacer + } + +/** + * Creates and remembers a bottom axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Bottom]). + * + * @param label the [TextComponent] to use for the labels. + * @param axis the [LineComponent] to use for the axis line. + * @param tick the [LineComponent] to use for the ticks. + * @param tickLength the length of the ticks. + * @param guideline the [LineComponent] to use for the guidelines. + * @param valueFormatter formats the labels. + * @param sizeConstraint defines how the [HorizontalAxis] is to size itself. + * @param titleComponent an optional [TextComponent] to use as the axis title. + * @param title the axis title. + * @param labelRotationDegrees the rotation of the axis labels (in degrees). + * @param itemPlacer determines for what _x_ values the [HorizontalAxis] is to display labels, ticks, and guidelines. + */ +@Composable +public fun rememberBottomAxis( + label: TextComponent? = axisLabelComponent(), + axis: LineComponent? = axisLineComponent(), + tick: LineComponent? = axisTickComponent(), + tickLength: Dp = currentChartStyle.axis.axisTickLength, + guideline: LineComponent? = axisGuidelineComponent(), + valueFormatter: AxisValueFormatter = DecimalFormatAxisValueFormatter(), + sizeConstraint: Axis.SizeConstraint = Axis.SizeConstraint.Auto(), + titleComponent: TextComponent? = null, + title: CharSequence? = null, + labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, + itemPlacer: AxisItemPlacer.Horizontal = remember { AxisItemPlacer.Horizontal.default() }, +): HorizontalAxis = + remember { createHorizontalAxis() }.apply { + this.label = label + axisLine = axis + this.tick = tick + this.guideline = guideline + this.valueFormatter = valueFormatter + tickLengthDp = tickLength.value + this.sizeConstraint = sizeConstraint + this.labelRotationDegrees = labelRotationDegrees + this.titleComponent = titleComponent + this.title = title + this.itemPlacer = itemPlacer + } + +/** + * Creates and remembers a top axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Top]). + * + * @param label the [TextComponent] to use for the labels. + * @param axis the [LineComponent] to use for the axis line. + * @param tick the [LineComponent] to use for the ticks. + * @param tickLength the length of the ticks. + * @param guideline the [LineComponent] to use for the guidelines. + * @param valueFormatter formats the labels. + * @param sizeConstraint defines how the [HorizontalAxis] is to size itself. + * @param labelRotationDegrees the rotation of the axis labels (in degrees). + * @param titleComponent an optional [TextComponent] to use as the axis title. + * @param title the axis title. + * @param itemPlacer determines for what _x_ values the [HorizontalAxis] is to display labels, ticks, and guidelines. + */ +@Composable +@Deprecated( + "Use `rememberTopAxis` instead.", + ReplaceWith( + """ + rememberTopAxis( + label = label, + axis = axis, + tick = tick, + tickLength = tickLength, + guideline = guideline, + valueFormatter = valueFormatter, + sizeConstraint = sizeConstraint, + labelRotationDegrees = labelRotationDegrees, + titleComponent = titleComponent, + title = title, + itemPlacer = itemPlacer, + ) + """, + "com.patrykandpatrick.vico.compose.axis.horizontal.rememberTopAxis", + ), +) public fun topAxis( label: TextComponent? = axisLabelComponent(), axis: LineComponent? = axisLineComponent(), @@ -63,22 +170,22 @@ public fun topAxis( titleComponent: TextComponent? = null, title: CharSequence? = null, itemPlacer: AxisItemPlacer.Horizontal = remember { AxisItemPlacer.Horizontal.default() }, -): HorizontalAxis = createHorizontalAxis { - this.label = label - this.axis = axis - this.tick = tick - this.guideline = guideline - this.valueFormatter = valueFormatter - this.tickLengthDp = tickLength.value - this.sizeConstraint = sizeConstraint - this.labelRotationDegrees = labelRotationDegrees - this.titleComponent = titleComponent - this.title = title - this.itemPlacer = itemPlacer -} +): HorizontalAxis = rememberTopAxis( + label, + axis, + tick, + tickLength, + guideline, + valueFormatter, + sizeConstraint, + labelRotationDegrees, + titleComponent, + title, + itemPlacer, +) /** - * Creates a bottom axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Bottom]). + * Creates and remembers a bottom axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Bottom]). * * @param label the [TextComponent] to use for the labels. * @param axis the [LineComponent] to use for the axis line. @@ -93,6 +200,27 @@ public fun topAxis( * @param itemPlacer determines for what _x_ values the [HorizontalAxis] is to display labels, ticks, and guidelines. */ @Composable +@Deprecated( + "Use `rememberBottomAxis` instead.", + ReplaceWith( + """ + rememberBottomAxis( + label = label, + axis = axis, + tick = tick, + tickLength = tickLength, + guideline = guideline, + valueFormatter = valueFormatter, + sizeConstraint = sizeConstraint, + titleComponent = titleComponent, + title = title, + labelRotationDegrees = labelRotationDegrees, + itemPlacer = itemPlacer, + ) + """, + "com.patrykandpatrick.vico.compose.axis.horizontal.rememberBottomAxis", + ), +) public fun bottomAxis( label: TextComponent? = axisLabelComponent(), axis: LineComponent? = axisLineComponent(), @@ -105,22 +233,22 @@ public fun bottomAxis( title: CharSequence? = null, labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, itemPlacer: AxisItemPlacer.Horizontal = remember { AxisItemPlacer.Horizontal.default() }, -): HorizontalAxis = createHorizontalAxis { - this.label = label - this.axis = axis - this.tick = tick - this.guideline = guideline - this.valueFormatter = valueFormatter - this.tickLengthDp = tickLength.value - this.sizeConstraint = sizeConstraint - this.labelRotationDegrees = labelRotationDegrees - this.titleComponent = titleComponent - this.title = title - this.itemPlacer = itemPlacer -} +): HorizontalAxis = rememberBottomAxis( + label, + axis, + tick, + tickLength, + guideline, + valueFormatter, + sizeConstraint, + titleComponent, + title, + labelRotationDegrees, + itemPlacer, +) /** - * Creates a top axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Top]). + * Creates and remembers a top axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Top]). * * @param label the [TextComponent] to use for the labels. * @param axis the [LineComponent] to use for the axis line. @@ -138,26 +266,12 @@ public fun bottomAxis( */ @Composable @Deprecated( - """`labelSpacing` and `labelOffset` are being replaced by `AxisItemPlacer.Horizontal`. Create a base implementation - with the desired spacing and offset via `AxisItemPlacer.Horizontal.default`, and use the `itemPlacer` parameter - of the other `topAxis` overload to apply it to the `HorizontalAxis` being created.""", - ReplaceWith( - """topAxis( - label = label, - axis = axis, - tick = tick, - tickLength = tickLength, - guideline = guideline, - valueFormatter = valueFormatter, - sizeConstraint = sizeConstraint, - labelRotationDegrees = labelRotationDegrees, - titleComponent = titleComponent, - title = title, - itemPlacer = remember { AxisItemPlacer.Horizontal.default(spacing = labelSpacing, offset = labelOffset) }, - )""", - "com.patrykandpatrick.vico.core.axis.AxisItemPlacer", - "androidx.compose.runtime.remember", - ), + """ + `topAxis` is being replaced by `rememberTopAxis`. Also, `labelSpacing` and `labelOffset` are being replaced by + `AxisItemPlacer.Horizontal`. If using `labelSpacing` or `labelOffset`, create a base `AxisItemPlacer.Horizontal` + implementation with the desired spacing and offset via `AxisItemPlacer.Horizontal.default`, and use the + `itemPlacer` parameter of `rememberTopAxis` to apply it to the `HorizontalAxis` being created. + """, ) public fun topAxis( label: TextComponent? = axisLabelComponent(), @@ -172,7 +286,7 @@ public fun topAxis( title: CharSequence? = null, labelSpacing: Int = 1, labelOffset: Int = 0, -): HorizontalAxis = topAxis( +): HorizontalAxis = rememberTopAxis( label, axis, tick, @@ -187,7 +301,7 @@ public fun topAxis( ) /** - * Creates a bottom axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Bottom]). + * Creates and remembers a bottom axis (i.e., a [HorizontalAxis] with [AxisPosition.Horizontal.Bottom]). * * @param label the [TextComponent] to use for the labels. * @param axis the [LineComponent] to use for the axis line. @@ -205,26 +319,13 @@ public fun topAxis( */ @Composable @Deprecated( - """`labelSpacing` and `labelOffset` are being replaced by `AxisItemPlacer.Horizontal`. Create a base implementation - with the desired spacing and offset via `AxisItemPlacer.Horizontal.default`, and use the `itemPlacer` parameter - of the other `bottomAxis` overload to apply it to the `HorizontalAxis` being created.""", - ReplaceWith( - """bottomAxis( - label = label, - axis = axis, - tick = tick, - tickLength = tickLength, - guideline = guideline, - valueFormatter = valueFormatter, - sizeConstraint = sizeConstraint, - titleComponent = titleComponent, - title = title, - labelRotationDegrees = labelRotationDegrees, - itemPlacer = remember { AxisItemPlacer.Horizontal.default(spacing = labelSpacing, offset = labelOffset) }, - )""", - "com.patrykandpatrick.vico.core.axis.AxisItemPlacer", - "androidx.compose.runtime.remember", - ), + """ + `bottomAxis` is being replaced by `rememberBottomAxis`. Also, `labelSpacing` and `labelOffset` are being replaced + by `AxisItemPlacer.Horizontal`. If using `labelSpacing` or `labelOffset`, create a base + `AxisItemPlacer.Horizontal` implementation with the desired spacing and offset via + `AxisItemPlacer.Horizontal.default`, and use the `itemPlacer` parameter of `rememberBottomAxis` to apply it to + the `HorizontalAxis` being created. + """, ) public fun bottomAxis( label: TextComponent? = axisLabelComponent(), @@ -239,7 +340,7 @@ public fun bottomAxis( labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, labelSpacing: Int = 1, labelOffset: Int = 0, -): HorizontalAxis = bottomAxis( +): HorizontalAxis = rememberBottomAxis( label, axis, tick, diff --git a/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/axis/vertical/VerticalAxis.kt b/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/axis/vertical/VerticalAxis.kt index 13e408ef3..3b13c9261 100644 --- a/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/axis/vertical/VerticalAxis.kt +++ b/vico/compose/src/main/java/com/patrykandpatrick/vico/compose/axis/vertical/VerticalAxis.kt @@ -24,6 +24,7 @@ import com.patrykandpatrick.vico.compose.axis.axisLabelComponent import com.patrykandpatrick.vico.compose.axis.axisLineComponent import com.patrykandpatrick.vico.compose.axis.axisTickComponent import com.patrykandpatrick.vico.compose.style.currentChartStyle +import com.patrykandpatrick.vico.core.DEF_LABEL_COUNT import com.patrykandpatrick.vico.core.axis.Axis import com.patrykandpatrick.vico.core.axis.AxisItemPlacer import com.patrykandpatrick.vico.core.axis.AxisPosition @@ -35,7 +36,7 @@ import com.patrykandpatrick.vico.core.component.shape.LineComponent import com.patrykandpatrick.vico.core.component.text.TextComponent /** - * Creates a start axis (i.e., a [VerticalAxis] with [AxisPosition.Vertical.Start]). + * Creates and remembers a start axis (i.e., a [VerticalAxis] with [AxisPosition.Vertical.Start]). * * @param label the [TextComponent] to use for the labels. * @param axis the [LineComponent] to use for the axis line. @@ -52,7 +53,7 @@ import com.patrykandpatrick.vico.core.component.text.TextComponent * @param title the axis title. */ @Composable -public fun startAxis( +public fun rememberStartAxis( label: TextComponent? = axisLabelComponent(), axis: LineComponent? = axisLineComponent(), tick: LineComponent? = axisTickComponent(), @@ -66,9 +67,9 @@ public fun startAxis( labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, titleComponent: TextComponent? = null, title: CharSequence? = null, -): VerticalAxis = createVerticalAxis { +): VerticalAxis = remember { createVerticalAxis() }.apply { this.label = label - this.axis = axis + axisLine = axis this.tick = tick this.guideline = guideline this.valueFormatter = valueFormatter @@ -83,7 +84,7 @@ public fun startAxis( } /** - * Creates an end axis (i.e., a [VerticalAxis] with [AxisPosition.Vertical.End]). + * Creates and remembers an end axis (i.e., a [VerticalAxis] with [AxisPosition.Vertical.End]). * * @param label the [TextComponent] to use for the labels. * @param axis the [LineComponent] to use for the axis line. @@ -100,7 +101,7 @@ public fun startAxis( * @param title the axis title. */ @Composable -public fun endAxis( +public fun rememberEndAxis( label: TextComponent? = axisLabelComponent(), axis: LineComponent? = axisLineComponent(), tick: LineComponent? = axisTickComponent(), @@ -114,13 +115,13 @@ public fun endAxis( labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, titleComponent: TextComponent? = null, title: CharSequence? = null, -): VerticalAxis = createVerticalAxis { +): VerticalAxis = remember { createVerticalAxis() }.apply { this.label = label - this.axis = axis + axisLine = axis this.tick = tick this.guideline = guideline this.valueFormatter = valueFormatter - this.tickLengthDp = tickLength.value + tickLengthDp = tickLength.value this.sizeConstraint = sizeConstraint this.horizontalLabelPosition = horizontalLabelPosition this.verticalLabelPosition = verticalLabelPosition @@ -131,7 +132,7 @@ public fun endAxis( } /** - * Creates a start axis (i.e., a [VerticalAxis] with [AxisPosition.Vertical.Start]). + * Creates and remembers a start axis (i.e., a [VerticalAxis] with [AxisPosition.Vertical.Start]). * * @param label the [TextComponent] to use for the labels. * @param axis the [LineComponent] to use for the axis line. @@ -150,31 +151,11 @@ public fun endAxis( @Composable @Deprecated( """ - `maxLabelCount` is being replaced by `AxisItemPlacer.Vertical`. Create a base implementation with the desired - maximum item count via `AxisItemPlacer.Vertical.default`, and use the `itemPlacer` parameter of the other - `startAxis` overload to apply it to the `VerticalAxis` being created. + `startAxis` is being replaced by `rememberStartAxis`. Also, `maxLabelCount` is being replaced by + `AxisItemPlacer.Vertical`. If using `maxLabelCount`, create a base `AxisItemPlacer.Vertical` implementation with + the desired maximum item count via `AxisItemPlacer.Vertical.default`, and use the `itemPlacer` parameter of + `rememberStartAxis` to apply it to the `VerticalAxis` being created. """, - ReplaceWith( - """ - startAxis( - label = label, - axis = axis, - tick = tick, - tickLength = tickLength, - guideline = guideline, - valueFormatter = valueFormatter, - sizeConstraint = sizeConstraint, - horizontalLabelPosition = horizontalLabelPosition, - verticalLabelPosition = verticalLabelPosition, - itemPlacer = remember { AxisItemPlacer.Vertical.default(maxLabelCount) }, - labelRotationDegrees = labelRotationDegrees, - titleComponent = titleComponent, - title = title, - ) - """, - "com.patrykandpatrick.vico.core.axis.AxisItemPlacer", - "androidx.compose.runtime.remember", - ), ) public fun startAxis( label: TextComponent? = axisLabelComponent(), @@ -186,11 +167,11 @@ public fun startAxis( sizeConstraint: Axis.SizeConstraint = Axis.SizeConstraint.Auto(), horizontalLabelPosition: VerticalAxis.HorizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Outside, verticalLabelPosition: VerticalAxis.VerticalLabelPosition = VerticalAxis.VerticalLabelPosition.Center, - maxLabelCount: Int, + maxLabelCount: Int = DEF_LABEL_COUNT, labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, titleComponent: TextComponent? = null, title: CharSequence? = null, -): VerticalAxis = startAxis( +): VerticalAxis = rememberStartAxis( label, axis, tick, @@ -207,7 +188,7 @@ public fun startAxis( ) /** - * Creates an end axis (i.e., a [VerticalAxis] with [AxisPosition.Vertical.End]). + * Creates and remembers an end axis (i.e., a [VerticalAxis] with [AxisPosition.Vertical.End]). * * @param label the [TextComponent] to use for the labels. * @param axis the [LineComponent] to use for the axis line. @@ -226,31 +207,11 @@ public fun startAxis( @Composable @Deprecated( """ - `maxLabelCount` is being replaced by `AxisItemPlacer.Vertical`. Create a base implementation with the desired - maximum item count via `AxisItemPlacer.Vertical.default`, and use the `itemPlacer` parameter of the other - `endAxis` overload to apply it to the `VerticalAxis` being created. + `endAxis` is being replaced by `rememberEndAxis`. Also, `maxLabelCount` is being replaced by + `AxisItemPlacer.Vertical`. If using `maxLabelCount`, create a base `AxisItemPlacer.Vertical` implementation with + the desired maximum item count via `AxisItemPlacer.Vertical.default`, and use the `itemPlacer` parameter of + `rememberEndAxis` to apply it to the `VerticalAxis` being created. """, - ReplaceWith( - """ - endAxis( - label = label, - axis = axis, - tick = tick, - tickLength = tickLength, - guideline = guideline, - valueFormatter = valueFormatter, - sizeConstraint = sizeConstraint, - horizontalLabelPosition = horizontalLabelPosition, - verticalLabelPosition = verticalLabelPosition, - itemPlacer = remember { AxisItemPlacer.Vertical.default(maxLabelCount) }, - labelRotationDegrees = labelRotationDegrees, - titleComponent = titleComponent, - title = title, - ) - """, - "com.patrykandpatrick.vico.core.axis.AxisItemPlacer", - "androidx.compose.runtime.remember", - ), ) public fun endAxis( label: TextComponent? = axisLabelComponent(), @@ -262,11 +223,11 @@ public fun endAxis( sizeConstraint: Axis.SizeConstraint = Axis.SizeConstraint.Auto(), horizontalLabelPosition: VerticalAxis.HorizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Outside, verticalLabelPosition: VerticalAxis.VerticalLabelPosition = VerticalAxis.VerticalLabelPosition.Center, - maxLabelCount: Int, + maxLabelCount: Int = DEF_LABEL_COUNT, labelRotationDegrees: Float = currentChartStyle.axis.axisLabelRotationDegrees, titleComponent: TextComponent? = null, title: CharSequence? = null, -): VerticalAxis = endAxis( +): VerticalAxis = rememberEndAxis( label, axis, tick,