diff --git a/.gitignore b/.gitignore
index 37e77b667..7fe64d424 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@
/.idea/other.xml
/.idea/codeStyles/Project.xml
/.idea/inspectionProfiles/Project_Default.xml
+/.idea/studiobot.xml
*.iml
.gradle
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 962b221c2..7d9505635 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -127,8 +127,10 @@
+
+
-
\ No newline at end of file
+
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index b690c663e..3fbe5fd05 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,24 +1,25 @@
[versions]
accompanist = "0.34.0"
activity = "1.9.0"
-agp = "8.4.1"
+agp = "8.5.1"
androidXAnnotation = "1.8.0"
androidXCore = "1.13.1"
appcompat = "1.7.0"
-composeBom = "2024.05.00"
+composeBom = "2024.06.00"
composeNavigation = "2.7.7"
+composeStableMarker = "1.0.5"
coroutines = "1.8.1"
desugar_jdk_libs = "2.0.4"
dokka = "1.9.20"
jUnit = "4.13.2"
jUnitExt = "1.1.5"
-jupiter = "5.10.2"
+jupiter = "5.10.3"
kotlin = "2.0.0"
-lifecycle = "2.8.1"
+lifecycle = "2.8.3"
material = "1.12.0"
-mockK = "1.13.11"
+mockK = "1.13.12"
paparazziGradlePlugin = "1.3.4"
-testCore = "1.5.0"
+testCore = "1.6.1"
[libraries]
activityCompose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" }
@@ -32,6 +33,7 @@ composeMaterial = { group = "androidx.compose.material", name = "material" }
composeMaterial3 = { group = "androidx.compose.material3", name = "material3" }
composeNavigation = { group = "androidx.navigation", name = "navigation-compose", version.ref = "composeNavigation" }
composePreview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
+composeStableMarker = { group = "com.github.skydoves", name = "compose-stable-marker", version.ref = "composeStableMarker" }
composeUI = { group = "androidx.compose.ui", name = "ui" }
composeUITooling = { group = "androidx.compose.ui", name = "ui-tooling" }
composeViewBinding = { group = "androidx.compose.ui", name = "ui-viewbinding" }
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index e6441136f..2c3521197 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a4413138c..09523c0e5 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
index b740cf133..f5feea6d6 100755
--- a/gradlew
+++ b/gradlew
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
#
@@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
diff --git a/gradlew.bat b/gradlew.bat
index 25da30dbd..9d21a2183 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
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
deleted file mode 100644
index 1956327cc..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/AxisLinePreviews.kt
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.foundation.layout.PaddingValues
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.tooling.preview.Preview
-import androidx.compose.ui.unit.dp
-import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberAxisLabelComponent
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberEndAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.compose.common.component.rememberShapeComponent
-import com.patrykandpatrick.vico.compose.common.of
-import com.patrykandpatrick.vico.core.cartesian.axis.VerticalAxis
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.data.ColumnCartesianLayerModel
-import com.patrykandpatrick.vico.core.common.Dimensions
-import com.patrykandpatrick.vico.core.common.shape.Corner
-import com.patrykandpatrick.vico.core.common.shape.CorneredShape
-import com.patrykandpatrick.vico.core.common.shape.CutCornerTreatment
-import com.patrykandpatrick.vico.core.common.shape.RoundedCornerTreatment
-import com.patrykandpatrick.vico.core.common.shape.Shape
-
-private val model = CartesianChartModel(ColumnCartesianLayerModel.build { series(1, 2, 3, 4) })
-
-@Composable
-@Preview(showBackground = true, widthDp = 250)
-fun HorizontalAxisTextInside() {
- val label =
- rememberAxisLabelComponent(
- background =
- rememberShapeComponent(
- shape =
- CorneredShape(
- topLeft = Corner.Relative(percentage = 50, cornerTreatment = CutCornerTreatment),
- bottomRight =
- Corner.Relative(percentage = 50, cornerTreatment = RoundedCornerTreatment),
- ),
- color = Color.LightGray,
- strokeColor = Color.Gray,
- strokeWidth = 1.dp,
- ),
- padding = Dimensions.of(horizontal = 2.dp, vertical = 8.dp),
- margins = Dimensions.of(horizontal = 4.dp, vertical = 4.dp),
- )
- PaddingValues()
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- startAxis =
- rememberStartAxis(
- horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside,
- label = label,
- ),
- endAxis =
- rememberEndAxis(
- horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside,
- guideline = null,
- label = label,
- ),
- ),
- model = model,
- )
-}
-
-@Composable
-@Preview(showBackground = true, widthDp = 250)
-fun HorizontalAxisTextInsideAndBottomAxis() {
- val label =
- rememberAxisLabelComponent(
- background = rememberShapeComponent(shape = Shape.Pill, color = Color.LightGray),
- padding = Dimensions.of(horizontal = 2.dp, vertical = 8.dp),
- margins = Dimensions.of(horizontal = 4.dp, vertical = 4.dp),
- )
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- startAxis =
- rememberStartAxis(
- horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside,
- label = label,
- ),
- endAxis =
- rememberEndAxis(
- horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside,
- guideline = null,
- label = label,
- ),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
-}
-
-@Composable
-@Preview(showBackground = true, widthDp = 250)
-fun HorizontalAxisTextOutside() {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- startAxis =
- rememberStartAxis(horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Outside),
- endAxis =
- rememberEndAxis(
- horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Outside,
- guideline = null,
- ),
- ),
- model = model,
- )
-}
-
-@Composable
-@Preview(showBackground = true, widthDp = 250)
-fun HorizontalAxisGuidelineDoesNotOverlayBottomAxisLine() {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- startAxis =
- rememberStartAxis(horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Outside),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
-}
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/CandlestickLinePreview.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/CandlestickLinePreview.kt
deleted file mode 100644
index 2fe954a98..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/CandlestickLinePreview.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.material3.Surface
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.remember
-import androidx.compose.ui.tooling.preview.Preview
-import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.layer.absoluteRelative
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberCandlestickCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.core.cartesian.data.CandlestickCartesianLayerModel
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.layer.CandlestickCartesianLayer
-
-@Preview(widthDp = 350)
-@Composable
-fun CandlestickLinePreview() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberCandlestickCartesianLayer(
- CandlestickCartesianLayer.CandleProvider.absoluteRelative()
- ),
- startAxis = rememberStartAxis(),
- bottomAxis = rememberBottomAxis(),
- ),
- model =
- remember {
- CartesianChartModel(
- CandlestickCartesianLayerModel.build(
- opening = listOf(4, 8, 12, 14, 10, 18),
- closing = listOf(8, 12, 14, 10, 18, 14),
- low = listOf(2, 6, 10, 4, 6, 10),
- high = listOf(12, 14, 16, 16, 20, 18),
- )
- )
- },
- )
- }
-}
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
deleted file mode 100644
index da4781b89..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ColumnChartsWithNegativeValuesPreviews.kt
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.foundation.layout.height
-import androidx.compose.material.Surface
-import androidx.compose.runtime.Composable
-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.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisItemPlacer
-import com.patrykandpatrick.vico.core.cartesian.data.AxisValueOverrider
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.data.LineCartesianLayerModel
-import com.patrykandpatrick.vico.sample.showcase.rememberMarker
-
-private val model =
- CartesianChartModel(LineCartesianLayerModel.build { series(2, -1, 4, -2, 1, 5, -3) })
-
-@Preview
-@Composable
-public fun SingleColumnChartWithNegativeValues() {
- val marker = rememberMarker()
- Surface {
- CartesianChartHost(
- modifier = Modifier.height(250.dp),
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 9 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- persistentMarkers = mapOf(2f to marker, 3f to marker),
- ),
- model = model,
- )
- }
-}
-
-@Preview
-@Composable
-public fun SingleColumnChartWithNegativeValuesAndDataLabels() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(dataLabel = rememberTextComponent()),
- startAxis = rememberStartAxis(),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
-
-@Preview
-@Composable
-public fun SingleColumnChartWithNegativeValuesAndAxisValuesOverridden() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(
- axisValueOverrider = AxisValueOverrider.fixed(minY = 1f, maxY = 4f)
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 4 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
-
-@Preview
-@Composable
-public fun SingleColumnChartWithNegativeValuesAndAxisValuesOverridden2() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(
- axisValueOverrider = AxisValueOverrider.fixed(minY = -2f, maxY = 0f)
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 3 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
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
deleted file mode 100644
index aa294b788..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ContainedChartsPreview.kt
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.remember
-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.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberEndAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
-import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
-import com.patrykandpatrick.vico.compose.common.shader.color
-import com.patrykandpatrick.vico.compose.common.shader.verticalGradient
-import com.patrykandpatrick.vico.core.cartesian.axis.Axis
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisItemPlacer
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisPosition.Vertical
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisPosition.Vertical.End
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisPosition.Vertical.Start
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.data.ColumnCartesianLayerModel
-import com.patrykandpatrick.vico.core.cartesian.data.LineCartesianLayerModel
-import com.patrykandpatrick.vico.core.cartesian.layer.ColumnCartesianLayer
-import com.patrykandpatrick.vico.core.cartesian.marker.CartesianMarker
-import com.patrykandpatrick.vico.core.common.shader.DynamicShader
-import com.patrykandpatrick.vico.core.common.shape.Shape
-import com.patrykandpatrick.vico.sample.showcase.rememberMarker
-
-private val model =
- CartesianChartModel(
- ColumnCartesianLayerModel.build { series(1, 2, 4, 1, 4) },
- LineCartesianLayerModel.build { series(4, 1, 8, 12, 5) },
- )
-
-private val markerMap: Map
- @Composable get() = mapOf(4f to rememberMarker())
-
-@Composable
-private fun getColumnLayer(verticalAxisPosition: Vertical? = null) =
- rememberColumnCartesianLayer(
- columnProvider =
- ColumnCartesianLayer.ColumnProvider.series(
- rememberLineComponent(color = Color.Black, thickness = 8.dp, shape = Shape.Pill)
- ),
- verticalAxisPosition = verticalAxisPosition,
- )
-
-@Composable
-private fun getLineLayer(verticalAxisPosition: Vertical? = null) =
- rememberLineCartesianLayer(
- lines =
- listOf(
- rememberLineSpec(
- shader = DynamicShader.color(Color.DarkGray),
- backgroundShader =
- DynamicShader.verticalGradient(arrayOf(Color.DarkGray, Color.DarkGray.copy(alpha = 0f))),
- )
- ),
- verticalAxisPosition = verticalAxisPosition,
- )
-
-private val startAxis: Axis
- @Composable
- get() =
- rememberStartAxis(
- label = rememberTextComponent(color = Color.Black),
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 5 }) },
- )
-
-private val endAxis: Axis
- @Composable
- get() =
- rememberEndAxis(
- label = rememberTextComponent(color = Color.DarkGray),
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 7 }) },
- )
-
-@Composable
-@Preview("Chart with independent axes", widthDp = 350)
-public fun ChartWithIndependentAxes(modifier: Modifier = Modifier) {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- getColumnLayer(Start),
- getLineLayer(End),
- startAxis = startAxis,
- bottomAxis = rememberBottomAxis(),
- endAxis = endAxis,
- ),
- model = model,
- modifier = modifier,
- )
-}
-
-@Composable
-@Preview("Chart with dependent axes", widthDp = 350)
-public fun ChartWithDependentAxes(modifier: Modifier = Modifier) {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- getColumnLayer(),
- getLineLayer(),
- startAxis = startAxis,
- bottomAxis = rememberBottomAxis(),
- endAxis = endAxis,
- persistentMarkers = markerMap,
- ),
- model = model,
- modifier = modifier,
- )
-}
-
-@Composable
-@Preview("Column chart", widthDp = 350)
-public fun ColumnChart(modifier: Modifier = Modifier) {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- getColumnLayer(),
- startAxis = startAxis,
- bottomAxis = rememberBottomAxis(),
- persistentMarkers = markerMap,
- ),
- model = model,
- modifier = modifier,
- )
-}
-
-@Composable
-@Preview("Line chart", widthDp = 350)
-public fun LineChart(modifier: Modifier = Modifier) {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- getLineLayer(),
- startAxis = startAxis,
- bottomAxis = rememberBottomAxis(),
- persistentMarkers = markerMap,
- ),
- model = model,
- modifier = modifier,
- )
-}
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/HorizontalDecorationPreviews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/HorizontalDecorationPreviews.kt
deleted file mode 100644
index 262088f3a..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/HorizontalDecorationPreviews.kt
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material3.Surface
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Modifier
-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.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.decoration.rememberHorizontalBox
-import com.patrykandpatrick.vico.compose.cartesian.decoration.rememberHorizontalLine
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.compose.cartesian.rememberVicoScrollState
-import com.patrykandpatrick.vico.compose.common.ProvideVicoTheme
-import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
-import com.patrykandpatrick.vico.compose.common.component.rememberShapeComponent
-import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
-import com.patrykandpatrick.vico.compose.common.of
-import com.patrykandpatrick.vico.compose.common.shader.toDynamicShader
-import com.patrykandpatrick.vico.compose.common.vicoTheme
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.data.ColumnCartesianLayerModel
-import com.patrykandpatrick.vico.core.common.Dimensions
-import com.patrykandpatrick.vico.core.common.VerticalPosition
-import com.patrykandpatrick.vico.core.common.shader.ComponentShader
-import com.patrykandpatrick.vico.core.common.shape.Shape
-
-private val model = CartesianChartModel(ColumnCartesianLayerModel.build { series(1, 2, 3, 4) })
-
-val Color.Companion.DimmedGray: Color
- get() = Color(0xFFAAAAAA)
-
-@Composable
-private fun ProvidePreviewVicoTheme(content: @Composable () -> Unit) {
- Surface(
- color = Color.Transparent,
- modifier =
- Modifier.background(color = Color.LightGray, shape = RoundedCornerShape(size = 4.dp))
- .padding(8.dp),
- ) {
- ProvideVicoTheme(
- vicoTheme.copy(
- columnCartesianLayerColors = listOf(Color.DimmedGray),
- lineColor = Color.DimmedGray,
- textColor = Color.DimmedGray,
- ),
- content,
- )
- }
-}
-
-@Preview(widthDp = 250)
-@Composable
-fun ThresholdLine() {
- ProvidePreviewVicoTheme {
- CartesianChartHost(
- modifier = Modifier,
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- startAxis = rememberStartAxis(),
- bottomAxis = rememberBottomAxis(),
- decorations =
- listOf(
- rememberHorizontalLine(
- y = { 2f },
- line = rememberLineComponent(color = Color.Black, thickness = 2.dp),
- labelComponent =
- rememberTextComponent(Color.Black, padding = Dimensions.of(horizontal = 8.dp)),
- )
- ),
- ),
- model = model,
- scrollState = rememberVicoScrollState(scrollEnabled = false),
- )
- }
-}
-
-@Preview(widthDp = 250)
-@Composable
-fun ThresholdLineWithCustomText() {
- ProvidePreviewVicoTheme {
- CartesianChartHost(
- modifier = Modifier,
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- decorations =
- listOf(
- rememberHorizontalLine(
- y = { 2f },
- line = rememberLineComponent(color = Color.Black, thickness = 2.dp),
- labelComponent =
- rememberTextComponent(
- color = Color.White,
- lineCount = 3,
- background =
- rememberShapeComponent(
- shape = Shape.rounded(bottomLeftPercent = 25, bottomRightPercent = 25),
- color = Color.Black,
- ),
- padding = Dimensions.of(start = 8.dp, top = 2.dp, end = 8.dp, bottom = 4.dp),
- margins = Dimensions.of(horizontal = 4.dp),
- ),
- label = { "Horizontal line 1 📐" },
- verticalLabelPosition = VerticalPosition.Bottom,
- ),
- rememberHorizontalLine(
- y = { 3f },
- line = rememberLineComponent(color = Color.DarkGray, thickness = 2.dp),
- labelComponent =
- rememberTextComponent(
- color = Color.White,
- lineCount = 3,
- background =
- rememberShapeComponent(
- shape = Shape.cut(topLeftPercent = 25, topRightPercent = 25),
- color = Color.DarkGray,
- ),
- padding = Dimensions.of(start = 8.dp, top = 4.dp, end = 8.dp, bottom = 2.dp),
- margins = Dimensions.of(horizontal = 4.dp),
- ),
- label = { "Horizontal line 2 📐" },
- ),
- ),
- startAxis = rememberStartAxis(),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- scrollState = rememberVicoScrollState(scrollEnabled = false),
- )
- }
-}
-
-@Preview(widthDp = 250)
-@Composable
-fun RangedThresholdLine() {
- ProvidePreviewVicoTheme {
- CartesianChartHost(
- modifier = Modifier,
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- decorations =
- listOf(
- rememberHorizontalBox(
- y = { 2f..3f },
- box = rememberShapeComponent(color = Color.Black.copy(alpha = .5f)),
- labelComponent =
- rememberTextComponent(
- color = Color.Black,
- padding = Dimensions.of(horizontal = 8.dp),
- ),
- )
- ),
- startAxis = rememberStartAxis(),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- scrollState = rememberVicoScrollState(scrollEnabled = false),
- )
- }
-}
-
-@Preview(widthDp = 250)
-@Composable
-fun RangedThresholdLineWithBrushShader() {
- ProvidePreviewVicoTheme {
- CartesianChartHost(
- modifier = Modifier,
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- decorations =
- listOf(
- rememberHorizontalBox(
- y = { 2f..3f },
- box =
- rememberShapeComponent(
- color = Color.Black,
- dynamicShader =
- Brush.verticalGradient(
- colors = listOf(Color.Black.copy(0.75f), Color.Black.copy(0.25f))
- )
- .toDynamicShader(),
- ),
- labelComponent =
- rememberTextComponent(
- color = Color.Black,
- padding = Dimensions.of(horizontal = 8.dp),
- ),
- )
- ),
- startAxis = rememberStartAxis(),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- scrollState = rememberVicoScrollState(scrollEnabled = false),
- )
- }
-}
-
-@Preview(widthDp = 250)
-@Composable
-fun RangedThresholdLineWithComponentShader() {
- ProvidePreviewVicoTheme {
- CartesianChartHost(
- modifier = Modifier,
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(),
- decorations =
- listOf(
- rememberHorizontalBox(
- y = { 2f..3f },
- box =
- rememberShapeComponent(
- color = Color.Black,
- dynamicShader =
- ComponentShader(
- rememberShapeComponent(shape = Shape.Pill, color = Color.Black),
- componentSizeDp = 4f,
- ),
- strokeWidth = 2.dp,
- strokeColor = Color.Black,
- ),
- labelComponent =
- rememberTextComponent(
- color = Color.Black,
- padding = Dimensions.of(horizontal = 8.dp),
- ),
- )
- ),
- startAxis = rememberStartAxis(),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- scrollState = rememberVicoScrollState(scrollEnabled = false),
- )
- }
-}
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
deleted file mode 100644
index 7343ea3f0..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/LineChartPreviews.kt
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.Surface
-import androidx.compose.runtime.Composable
-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.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.compose.common.shader.color
-import com.patrykandpatrick.vico.compose.common.shader.verticalGradient
-import com.patrykandpatrick.vico.core.cartesian.data.AxisValueOverrider
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.data.LineCartesianLayerModel
-import com.patrykandpatrick.vico.core.common.shader.DynamicShader
-
-private val model1 = CartesianChartModel(LineCartesianLayerModel.build { series(0, 2, 4, 0, 2) })
-
-private val model2 =
- CartesianChartModel(
- LineCartesianLayerModel.build { series(0, 2, 4, 0, 2) },
- LineCartesianLayerModel.build { series(1, 3, 4, 1, 3) },
- )
-
-private val model3 =
- CartesianChartModel(
- LineCartesianLayerModel.build {
- series(3, 2, 2, 3, 1)
- series(1, 3, 1, 2, 3)
- }
- )
-
-@Preview("Line Chart Dark", widthDp = 200)
-@Composable
-fun LineChartDark() {
- Surface(shape = RoundedCornerShape(8.dp), color = Color.Black) {
- val yellow = Color(0xFFFFAA4A)
- val pink = Color(0xFFFF4AAA)
-
- CartesianChartHost(
- modifier = Modifier.padding(8.dp),
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- listOf(
- rememberLineSpec(
- shader = DynamicShader.color(yellow),
- backgroundShader =
- DynamicShader.verticalGradient(
- arrayOf(yellow.copy(alpha = 0.5f), yellow.copy(alpha = 0f))
- ),
- ),
- rememberLineSpec(
- shader = DynamicShader.color(pink),
- backgroundShader =
- DynamicShader.verticalGradient(
- arrayOf(pink.copy(alpha = 0.5f), pink.copy(alpha = 0f))
- ),
- ),
- ),
- axisValueOverrider = AxisValueOverrider.fixed(maxY = 4f),
- )
- ),
- model = model3,
- )
- }
-}
-
-@Preview("Line Chart", widthDp = 200)
-@Composable
-fun RegularLineChart() {
- CartesianChartHost(
- chart = rememberCartesianChart(rememberLineCartesianLayer(), startAxis = rememberStartAxis()),
- model = model1,
- )
-}
-
-@Preview("Line Chart Expanded", widthDp = 200)
-@Composable
-fun RegularLineChartExpanded() {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- axisValueOverrider = AxisValueOverrider.fixed(minY = -1f, maxY = 5f)
- ),
- startAxis = rememberStartAxis(),
- ),
- model = model1,
- )
-}
-
-@Preview("Line Chart Collapsed", widthDp = 200)
-@Composable
-fun RegularLineChartCollapsed() {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- axisValueOverrider = AxisValueOverrider.fixed(minY = 1f, maxY = 3f)
- ),
- startAxis = rememberStartAxis(),
- ),
- model = model1,
- )
-}
-
-@Preview("Composed Chart", widthDp = 200)
-@Composable
-fun ComposedLineChart() {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(),
- rememberLineCartesianLayer(
- listOf(
- rememberLineSpec(
- shader = DynamicShader.color(Color.Blue),
- backgroundShader =
- DynamicShader.verticalGradient(
- arrayOf(Color.Blue.copy(alpha = 0.4f), Color.Blue.copy(alpha = 0f))
- ),
- )
- )
- ),
- startAxis = rememberStartAxis(),
- ),
- model = model2,
- )
-}
-
-@Preview("Composed Chart Collapsed", widthDp = 200)
-@Composable
-fun ComposedLineChartCollapsed() {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- axisValueOverrider = AxisValueOverrider.fixed(minY = 1f, maxY = 3f)
- ),
- rememberLineCartesianLayer(
- axisValueOverrider = AxisValueOverrider.fixed(minY = 1f, maxY = 3f)
- ),
- startAxis = rememberStartAxis(),
- ),
- model = model2,
- )
-}
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/LineChartsWithNegativeValuesPreviews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/LineChartsWithNegativeValuesPreviews.kt
deleted file mode 100644
index d6b648164..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/LineChartsWithNegativeValuesPreviews.kt
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.foundation.layout.height
-import androidx.compose.material.Surface
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.remember
-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.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberAxisLineComponent
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.fullWidth
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
-import com.patrykandpatrick.vico.compose.common.shader.color
-import com.patrykandpatrick.vico.core.cartesian.HorizontalLayout
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisItemPlacer
-import com.patrykandpatrick.vico.core.cartesian.data.AxisValueOverrider
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.data.LineCartesianLayerModel
-import com.patrykandpatrick.vico.core.common.shader.DynamicShader
-import com.patrykandpatrick.vico.core.common.shader.TopBottomShader
-import com.patrykandpatrick.vico.sample.showcase.rememberMarker
-
-private val model =
- CartesianChartModel(LineCartesianLayerModel.build { series(-2, -1, 4, -2, 1, 5, -3) })
-
-@Preview
-@Composable
-fun SingleLineChartWithNegativeValues() {
- val marker = rememberMarker()
- Surface {
- CartesianChartHost(
- modifier = Modifier.height(250.dp),
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- lines =
- listOf(
- rememberLineSpec(
- shader =
- TopBottomShader(
- DynamicShader.color(Color(0xFF25BE53)),
- DynamicShader.color(Color(0xFFE73B3B)),
- )
- )
- )
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 4 }) },
- guideline = rememberAxisLineComponent(),
- ),
- bottomAxis =
- rememberBottomAxis(
- guideline = rememberAxisLineComponent(),
- itemPlacer = AxisItemPlacer.Horizontal.default(spacing = 2),
- ),
- persistentMarkers = mapOf(2f to marker, 3f to marker),
- ),
- model = model,
- horizontalLayout = HorizontalLayout.fullWidth(),
- )
- }
-}
-
-@Preview
-@Composable
-fun SingleLineChartWithNegativeValuesAndDataLabels() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- lines =
- listOf(
- rememberLineSpec(
- shader = DynamicShader.color(Color.DarkGray),
- dataLabel = rememberTextComponent(),
- )
- )
- ),
- startAxis = rememberStartAxis(),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
-
-@Preview
-@Composable
-fun SingleLineChartWithNegativeValuesAndAxisValuesOverridden() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- axisValueOverrider = AxisValueOverrider.fixed(minY = 1f, maxY = 4f)
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 4 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
-
-@Preview
-@Composable
-fun SingleLineChartWithNegativeValuesAndAxisValuesOverridden2() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- axisValueOverrider = AxisValueOverrider.fixed(minY = -2f, maxY = 0f)
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 3 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/Previews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/Previews.kt
deleted file mode 100644
index d8852fdef..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/Previews.kt
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.ColumnScope
-import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.shape.CornerSize
-import androidx.compose.foundation.shape.CutCornerShape
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material3.Card
-import androidx.compose.material3.CardDefaults
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.material3.Text
-import androidx.compose.runtime.Composable
-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 androidx.compose.ui.unit.sp
-import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
-import com.patrykandpatrick.vico.compose.common.component.rememberShapeComponent
-import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
-import com.patrykandpatrick.vico.compose.common.of
-import com.patrykandpatrick.vico.compose.common.shader.color
-import com.patrykandpatrick.vico.compose.common.shader.component
-import com.patrykandpatrick.vico.compose.common.shader.verticalGradient
-import com.patrykandpatrick.vico.compose.common.shape.toVicoShape
-import com.patrykandpatrick.vico.core.cartesian.axis.VerticalAxis
-import com.patrykandpatrick.vico.core.cartesian.data.AxisValueOverrider
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.data.ColumnCartesianLayerModel
-import com.patrykandpatrick.vico.core.cartesian.data.LineCartesianLayerModel
-import com.patrykandpatrick.vico.core.cartesian.layer.ColumnCartesianLayer
-import com.patrykandpatrick.vico.core.common.Dimensions
-import com.patrykandpatrick.vico.core.common.shader.DynamicShader
-import com.patrykandpatrick.vico.core.common.shape.DashedShape
-import com.patrykandpatrick.vico.core.common.shape.Shape.Companion.Pill
-import com.patrykandpatrick.vico.core.common.shape.Shape.Companion.Rectangle
-import com.patrykandpatrick.vico.sample.VicoTheme
-
-private val chartModifier = Modifier.height(100.dp)
-
-@Preview("Sample Card With Column Chart", widthDp = 200)
-@Composable
-fun ColumnChartCard(): Unit = VicoTheme {
- val colors = MaterialTheme.colorScheme
-
- SampleCard {
- CartesianChartHost(
- modifier = chartModifier,
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(
- ColumnCartesianLayer.ColumnProvider.series(
- rememberLineComponent(
- color = colors.primary,
- thickness = 8.dp,
- shape = RoundedCornerShape(4.dp).toVicoShape(),
- dynamicShader =
- DynamicShader.verticalGradient(arrayOf(colors.primary, colors.secondary)),
- )
- )
- ),
- startAxis =
- rememberStartAxis(
- label =
- rememberTextComponent(
- color = colors.primary,
- textSize = 10.sp,
- background =
- rememberShapeComponent(
- shape =
- CutCornerShape(
- CornerSize(percent = 25),
- CornerSize(percent = 50),
- CornerSize(percent = 50),
- CornerSize(percent = 25),
- )
- .toVicoShape(),
- color = colors.primary.copy(alpha = 0.1f),
- ),
- padding = Dimensions.of(end = 8.dp, start = 4.dp),
- ),
- axis = null,
- tick = null,
- guideline = rememberLineComponent(colors.primary.copy(alpha = .1f)),
- ),
- ),
- model = CartesianChartModel(ColumnCartesianLayerModel.build { series(1, 2, 3, 2) }),
- )
- }
-}
-
-@Preview("Sample Card With Line Chart", widthDp = 200)
-@Composable
-fun LineChartCard(): Unit = VicoTheme {
- val colors = MaterialTheme.colorScheme
-
- SampleCard {
- CartesianChartHost(
- modifier = Modifier.height(100.dp),
- chart =
- rememberCartesianChart(
- rememberLineCartesianLayer(
- listOf(
- rememberLineSpec(
- point = null,
- shader = DynamicShader.color(colors.primary),
- backgroundShader =
- DynamicShader.component(
- componentSize = 4.dp,
- component =
- rememberShapeComponent(
- shape = Pill,
- color = colors.primary,
- margins = Dimensions.of(0.5.dp),
- ),
- ),
- )
- ),
- axisValueOverrider = AxisValueOverrider.fixed(minX = 0f, maxY = 3f),
- ),
- startAxis =
- rememberStartAxis(
- label =
- rememberTextComponent(
- color = colors.onSurface,
- textSize = 10.sp,
- background = rememberShapeComponent(shape = Rectangle, color = Color.LightGray),
- padding = Dimensions.of(horizontal = 4.dp, vertical = 2.dp),
- ),
- axis = null,
- tick = null,
- guideline =
- rememberLineComponent(
- color = Color.LightGray,
- shape =
- DashedShape(shape = Pill, dashLengthDp = 2.dp.value, gapLengthDp = 4.dp.value),
- ),
- horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside,
- ),
- bottomAxis =
- rememberBottomAxis(
- label = null,
- axis = rememberLineComponent(Color.LightGray),
- tick = null,
- guideline = null,
- ),
- ),
- model =
- CartesianChartModel(
- LineCartesianLayerModel.build {
- series(x = listOf(-1, 0, 1, 2, 3, 4, 5), y = listOf(0, 0, 1, 2, 0, 2, 1))
- }
- ),
- )
- }
-}
-
-@Composable
-private fun SampleCard(chart: @Composable ColumnScope.() -> Unit) {
- Card(
- modifier = Modifier.padding(8.dp),
- shape = RoundedCornerShape(8.dp),
- elevation = CardDefaults.elevatedCardElevation(4.dp),
- ) {
- Column(modifier = Modifier.padding(16.dp)) {
- chart()
- Spacer(modifier = Modifier.height(8.dp))
- Text(text = "Title", style = MaterialTheme.typography.titleMedium)
- Text(
- text = "This is a subtitle. It may be long.",
- style = MaterialTheme.typography.bodyMedium,
- )
- }
- }
-}
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ShapePreviews.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ShapePreviews.kt
deleted file mode 100644
index b83b18b01..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/ShapePreviews.kt
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import android.graphics.Paint
-import android.graphics.Path
-import android.graphics.drawable.Drawable
-import androidx.annotation.DrawableRes
-import androidx.compose.foundation.Canvas
-import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.remember
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.nativeCanvas
-import androidx.compose.ui.platform.LocalContext
-import androidx.compose.ui.tooling.preview.Preview
-import androidx.compose.ui.unit.dp
-import androidx.core.content.res.ResourcesCompat
-import com.patrykandpatrick.vico.R
-import com.patrykandpatrick.vico.compose.common.shape.dashed
-import com.patrykandpatrick.vico.compose.common.shape.toComposeShape
-import com.patrykandpatrick.vico.core.common.drawContext
-import com.patrykandpatrick.vico.core.common.shape.CorneredShape
-import com.patrykandpatrick.vico.core.common.shape.Shape
-
-@Composable
-private fun PreviewShape(shape: Shape) {
- val black = 0xFF212121.toInt()
- val paint = remember { Paint(Paint.ANTI_ALIAS_FLAG).apply { color = black } }
- val path = remember { Path() }
-
- Column(
- modifier =
- Modifier.width(100.dp)
- .background(color = Color.White, shape = RoundedCornerShape(size = 4.dp))
- .padding(8.dp),
- verticalArrangement = Arrangement.spacedBy(8.dp),
- ) {
- Text(text = "Canvas")
-
- Canvas(modifier = Modifier.fillMaxWidth().height(50.dp)) {
- shape.drawShape(
- context = drawContext(drawContext.canvas.nativeCanvas),
- paint = paint,
- path = path,
- left = 0f,
- top = 0f,
- right = size.width,
- bottom = size.height,
- )
- }
-
- if (shape is CorneredShape) {
- Spacer(modifier = Modifier.height(8.dp))
-
- Text(text = "Compose Shape")
-
- Box(
- modifier =
- Modifier.height(50.dp)
- .fillMaxWidth()
- .background(color = Color(black), shape = shape.toComposeShape())
- )
- }
- }
-}
-
-@Composable
-@Preview
-public fun PreviewRectShape() {
- PreviewShape(shape = Shape.Rectangle)
-}
-
-@Composable
-@Preview
-public fun PreviewPillShape() {
- PreviewShape(shape = Shape.Pill)
-}
-
-@Composable
-@Preview
-public fun RoundedCorner25Shape() {
- PreviewShape(shape = Shape.rounded(allPercent = 25))
-}
-
-@Composable
-@Preview
-public fun RoundedCornerCustom1Shape() {
- PreviewShape(shape = Shape.rounded(topLeftPercent = 50, bottomRightPercent = 75))
-}
-
-@Composable
-@Preview
-public fun CutCorner25Shape() {
- PreviewShape(shape = Shape.cut(allPercent = 25))
-}
-
-@Composable
-@Preview
-public fun CutCornerCustom1Shape() {
- PreviewShape(shape = Shape.cut(topRightPercent = 100, bottomLeftPercent = 15))
-}
-
-@Composable
-@Preview
-public fun DrawableShape() {
- PreviewShape(
- shape =
- Shape.drawable(
- drawable = getDrawable(id = R.drawable.ic_baseline_android_24),
- keepAspectRatio = true,
- otherShape = Shape.Pill,
- )
- )
-}
-
-@Composable
-@Preview
-public fun DrawableShape2() {
- PreviewShape(
- shape =
- Shape.drawable(
- drawable = getDrawable(id = R.drawable.ic_baseline_android_24),
- keepAspectRatio = true,
- otherShape = Shape.Pill,
- )
- )
-}
-
-@Composable
-@Preview
-public fun DrawableShapeStretched() {
- PreviewShape(shape = Shape.drawable(getDrawable(id = R.drawable.ic_baseline_android_24)))
-}
-
-@Composable
-@Preview
-public fun DashedCutCornerCustomShape() {
- PreviewShape(
- shape =
- Shape.dashed(
- shape = Shape.cut(topRightPercent = 50, bottomLeftPercent = 50),
- dashLength = 24.dp,
- gapLength = 8.dp,
- )
- )
-}
-
-@Composable
-private fun getDrawable(@DrawableRes id: Int): Drawable =
- ResourcesCompat.getDrawable(LocalContext.current.resources, id, null)!!
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
deleted file mode 100644
index 4ee9e08e6..000000000
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/StackedColumnChartsWithNegativeValuesPreviews.kt
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2024 by Patryk Goworowski and Patrick Michalik.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.patrykandpatrick.vico.sample.previews
-
-import androidx.compose.foundation.layout.height
-import androidx.compose.material.Surface
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.remember
-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.cartesian.CartesianChartHost
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
-import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
-import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
-import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisItemPlacer
-import com.patrykandpatrick.vico.core.cartesian.data.AxisValueOverrider
-import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
-import com.patrykandpatrick.vico.core.cartesian.data.ColumnCartesianLayerModel
-import com.patrykandpatrick.vico.core.cartesian.layer.ColumnCartesianLayer
-import com.patrykandpatrick.vico.sample.showcase.rememberMarker
-
-private val model =
- CartesianChartModel(
- ColumnCartesianLayerModel.build {
- series(2, -1, -4, 2, 1, -5, -2, -3)
- series(3, -2, 2, -1, 2, -3, -4, -1)
- series(1, -2, 2, 1, -1, 4, 4, -2)
- }
- )
-
-private val columnProvider
- @Composable
- get() =
- ColumnCartesianLayer.ColumnProvider.series(
- rememberLineComponent(color = Color(0xFF494949), thickness = 8.dp),
- rememberLineComponent(color = Color(0xFF7C7A7A), thickness = 8.dp),
- rememberLineComponent(color = Color(0xFFFF5D73), thickness = 8.dp),
- )
-
-@Preview
-@Composable
-public fun StackedColumnChartWithNegativeValues() {
- val marker = rememberMarker()
- Surface {
- CartesianChartHost(
- modifier = Modifier.height(250.dp),
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(
- columnProvider = columnProvider,
- mergeMode = { ColumnCartesianLayer.MergeMode.Stacked },
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 8 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- persistentMarkers = mapOf(2f to marker, 3f to marker),
- ),
- model = model,
- )
- }
-}
-
-@Preview
-@Composable
-public fun StackedColumnChartWithNegativeValuesAndDataLabels() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(
- columnProvider = columnProvider,
- dataLabel = rememberTextComponent(),
- mergeMode = { ColumnCartesianLayer.MergeMode.Stacked },
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 8 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
-
-@Preview
-@Composable
-public fun StackedColumnChartWithNegativeValuesAndAxisValuesOverridden() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(
- columnProvider = columnProvider,
- axisValueOverrider = AxisValueOverrider.fixed(minY = 1f, maxY = 4f),
- mergeMode = { ColumnCartesianLayer.MergeMode.Stacked },
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 4 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
-
-@Preview
-@Composable
-public fun StackedColumnChartWithNegativeValuesAndAxisValuesOverridden2() {
- Surface {
- CartesianChartHost(
- chart =
- rememberCartesianChart(
- rememberColumnCartesianLayer(
- columnProvider = columnProvider,
- axisValueOverrider = AxisValueOverrider.fixed(minY = -2f, maxY = 0f),
- mergeMode = { ColumnCartesianLayer.MergeMode.Stacked },
- ),
- startAxis =
- rememberStartAxis(
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 3 }) }
- ),
- bottomAxis = rememberBottomAxis(),
- ),
- model = model,
- )
- }
-}
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/composables/column/ColumnCharts.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/composables/column/ColumnCharts.kt
index 1f5539a87..5b65e81b1 100644
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/composables/column/ColumnCharts.kt
+++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/previews/composables/column/ColumnCharts.kt
@@ -35,7 +35,6 @@ import com.patrykandpatrick.vico.sample.previews.resource.shortColumnModel
@Composable
public fun DefaultColumnChart(
model: CartesianChartModel = shortColumnModel,
- oldModel: CartesianChartModel? = null,
scrollable: Boolean = true,
initialScroll: Scroll.Absolute = Scroll.Absolute.Start,
autoScrollCondition: AutoScrollCondition = AutoScrollCondition.Never,
@@ -49,7 +48,6 @@ public fun DefaultColumnChart(
bottomAxis = rememberBottomAxis(),
),
model = model,
- oldModel = oldModel,
scrollState =
rememberVicoScrollState(
scrollEnabled = scrollable,
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/Marker.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/Marker.kt
index 84dad1482..0dcfe765e 100644
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/Marker.kt
+++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/Marker.kt
@@ -16,7 +16,6 @@
package com.patrykandpatrick.vico.sample.showcase
-import android.graphics.Typeface
import android.text.Layout
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
@@ -25,6 +24,7 @@ import androidx.compose.ui.unit.dp
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberAxisGuidelineComponent
import com.patrykandpatrick.vico.compose.common.component.fixed
import com.patrykandpatrick.vico.compose.common.component.rememberLayeredComponent
+import com.patrykandpatrick.vico.compose.common.component.rememberShadow
import com.patrykandpatrick.vico.compose.common.component.rememberShapeComponent
import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
import com.patrykandpatrick.vico.compose.common.of
@@ -32,9 +32,13 @@ import com.patrykandpatrick.vico.compose.common.shape.markerCornered
import com.patrykandpatrick.vico.core.cartesian.CartesianMeasureContext
import com.patrykandpatrick.vico.core.cartesian.HorizontalDimensions
import com.patrykandpatrick.vico.core.cartesian.Insets
+import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModel
import com.patrykandpatrick.vico.core.cartesian.marker.CartesianMarker
import com.patrykandpatrick.vico.core.cartesian.marker.DefaultCartesianMarker
import com.patrykandpatrick.vico.core.common.Dimensions
+import com.patrykandpatrick.vico.core.common.LayeredComponent
+import com.patrykandpatrick.vico.core.common.component.Shadow
+import com.patrykandpatrick.vico.core.common.component.ShapeComponent
import com.patrykandpatrick.vico.core.common.component.TextComponent
import com.patrykandpatrick.vico.core.common.copyColor
import com.patrykandpatrick.vico.core.common.shape.Corner
@@ -47,25 +51,27 @@ internal fun rememberMarker(
): CartesianMarker {
val labelBackgroundShape = Shape.markerCornered(Corner.FullyRounded)
val labelBackground =
- rememberShapeComponent(labelBackgroundShape, MaterialTheme.colorScheme.surface)
- .setShadow(
- radius = LABEL_BACKGROUND_SHADOW_RADIUS_DP,
- dy = LABEL_BACKGROUND_SHADOW_DY_DP,
- applyElevationOverlay = true,
- )
+ rememberShapeComponent(
+ color = MaterialTheme.colorScheme.surfaceBright,
+ shape = labelBackgroundShape,
+ shadow =
+ rememberShadow(
+ radius = LABEL_BACKGROUND_SHADOW_RADIUS_DP.dp,
+ dy = LABEL_BACKGROUND_SHADOW_DY_DP.dp,
+ ),
+ )
val label =
rememberTextComponent(
color = MaterialTheme.colorScheme.onSurface,
- background = labelBackground,
- padding = Dimensions.of(8.dp, 4.dp),
- typeface = Typeface.MONOSPACE,
textAlignment = Layout.Alignment.ALIGN_CENTER,
+ padding = Dimensions.of(8.dp, 4.dp),
+ background = labelBackground,
minWidth = TextComponent.MinWidth.fixed(40.dp),
)
val indicatorFrontComponent =
- rememberShapeComponent(Shape.Pill, MaterialTheme.colorScheme.surface)
- val indicatorCenterComponent = rememberShapeComponent(Shape.Pill)
- val indicatorRearComponent = rememberShapeComponent(Shape.Pill)
+ rememberShapeComponent(MaterialTheme.colorScheme.surface, Shape.Pill)
+ val indicatorCenterComponent = rememberShapeComponent(shape = Shape.Pill)
+ val indicatorRearComponent = rememberShapeComponent(shape = Shape.Pill)
val indicator =
rememberLayeredComponent(
rear = indicatorRearComponent,
@@ -83,31 +89,49 @@ internal fun rememberMarker(
DefaultCartesianMarker(
label = label,
labelPosition = labelPosition,
- indicator = if (showIndicator) indicator else null,
- indicatorSizeDp = 36f,
- setIndicatorColor =
+ indicator =
if (showIndicator) {
{ color ->
- indicatorRearComponent.color = color.copyColor(alpha = .15f)
- indicatorCenterComponent.color = color
- indicatorCenterComponent.setShadow(radius = 12f, color = color)
+ LayeredComponent(
+ rear = ShapeComponent(color.copyColor(alpha = 0.15f), Shape.Pill),
+ front =
+ LayeredComponent(
+ rear =
+ ShapeComponent(
+ color = color,
+ shape = Shape.Pill,
+ shadow = Shadow(radiusDp = 12f, color = color),
+ ),
+ front = indicatorFrontComponent,
+ padding = Dimensions.of(5.dp),
+ ),
+ padding = Dimensions.of(10.dp),
+ )
}
} else {
null
},
+ indicatorSizeDp = 36f,
guideline = guideline,
) {
- override fun getInsets(
+ override fun updateInsets(
context: CartesianMeasureContext,
- outInsets: Insets,
horizontalDimensions: HorizontalDimensions,
+ model: CartesianChartModel,
+ insets: Insets,
) {
with(context) {
- super.getInsets(context, outInsets, horizontalDimensions)
val baseShadowInsetDp =
CLIPPING_FREE_SHADOW_RADIUS_MULTIPLIER * LABEL_BACKGROUND_SHADOW_RADIUS_DP
- outInsets.top += (baseShadowInsetDp - LABEL_BACKGROUND_SHADOW_DY_DP).pixels
- outInsets.bottom += (baseShadowInsetDp + LABEL_BACKGROUND_SHADOW_DY_DP).pixels
+ var topInset = (baseShadowInsetDp - LABEL_BACKGROUND_SHADOW_DY_DP).pixels
+ var bottomInset = (baseShadowInsetDp + LABEL_BACKGROUND_SHADOW_DY_DP).pixels
+ when (labelPosition) {
+ LabelPosition.Top,
+ LabelPosition.AbovePoint -> topInset += label.getHeight(context) + tickSizeDp.pixels
+ LabelPosition.Bottom -> bottomInset += label.getHeight(context) + tickSizeDp.pixels
+ LabelPosition.AroundPoint -> {}
+ }
+ insets.ensureValuesAtLeast(top = topInset, bottom = bottomInset)
}
}
}
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 8720b0d5c..62f777043 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
@@ -25,14 +25,16 @@ import androidx.compose.ui.viewinterop.AndroidViewBinding
import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
+import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLine
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
import com.patrykandpatrick.vico.compose.cartesian.rememberVicoZoomState
+import com.patrykandpatrick.vico.compose.common.data.rememberExtraLambda
import com.patrykandpatrick.vico.compose.common.shader.color
import com.patrykandpatrick.vico.core.cartesian.axis.BaseAxis
import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.lineSeries
+import com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer
import com.patrykandpatrick.vico.core.common.shader.DynamicShader
import com.patrykandpatrick.vico.databinding.Chart1Binding
import com.patrykandpatrick.vico.sample.showcase.UIFramework
@@ -43,10 +45,10 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart1(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/line-layer#data. */
lineSeries { series(x, x.map { Random.nextFloat() * 15 }) }
@@ -66,15 +68,17 @@ private fun ComposeChart1(modelProducer: CartesianChartModelProducer, modifier:
chart =
rememberCartesianChart(
rememberLineCartesianLayer(
- listOf(rememberLineSpec(DynamicShader.color(Color(0xffa485e0))))
+ LineCartesianLayer.LineProvider.series(
+ rememberLine(DynamicShader.color(Color(0xffa485e0)))
+ )
),
startAxis = rememberStartAxis(),
bottomAxis = rememberBottomAxis(guideline = null),
- persistentMarkers = mapOf(PERSISTENT_MARKER_X to marker),
+ marker = marker,
+ persistentMarkers = rememberExtraLambda(marker) { marker at PERSISTENT_MARKER_X },
),
modelProducer = modelProducer,
modifier = modifier,
- marker = marker,
zoomState = rememberVicoZoomState(zoomEnabled = false),
)
}
@@ -86,10 +90,10 @@ private fun ViewChart1(modelProducer: CartesianChartModelProducer, modifier: Mod
{ inflater, parent, attachToParent ->
Chart1Binding.inflate(inflater, parent, attachToParent).apply {
with(chartView) {
- chart?.addPersistentMarker(PERSISTENT_MARKER_X, marker)
+ chart?.persistentMarkers = { marker at PERSISTENT_MARKER_X }
this.modelProducer = modelProducer
(chart?.bottomAxis as BaseAxis).guideline = null
- this.marker = marker
+ chart?.marker = marker
}
}
},
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart10.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart10.kt
index 09cfa4b25..90fbdbd21 100644
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart10.kt
+++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart10.kt
@@ -28,7 +28,7 @@ import com.patrykandpatrick.vico.compose.cartesian.fullWidth
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberCandlestickCartesianLayer
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
import com.patrykandpatrick.vico.core.cartesian.HorizontalLayout
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisItemPlacer
+import com.patrykandpatrick.vico.core.cartesian.axis.HorizontalAxis
import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.RandomCartesianModelGenerator
import com.patrykandpatrick.vico.databinding.Chart10Binding
@@ -42,11 +42,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart10(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(key1 = Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/candlestick-layer#data. */
add(RandomCartesianModelGenerator.getRandomCandlestickLayerModelPartial())
@@ -74,14 +74,14 @@ private fun ComposeChart10(modelProducer: CartesianChartModelProducer, modifier:
guideline = null,
itemPlacer =
remember {
- AxisItemPlacer.Horizontal.default(spacing = 3, addExtremeLabelPadding = true)
+ HorizontalAxis.ItemPlacer.default(spacing = 3, addExtremeLabelPadding = true)
},
),
+ marker = marker,
+ horizontalLayout = HorizontalLayout.fullWidth(),
),
modelProducer = modelProducer,
- marker = marker,
modifier = modifier,
- horizontalLayout = HorizontalLayout.fullWidth(),
)
}
@@ -90,6 +90,6 @@ private fun ViewChart10(modelProducer: CartesianChartModelProducer, modifier: Mo
val marker = rememberMarker(showIndicator = false)
AndroidViewBinding(Chart10Binding::inflate, modifier = modifier) {
chartView.modelProducer = modelProducer
- chartView.marker = marker
+ chartView.chart?.marker = marker
}
}
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 e552d0df4..4c83e1c77 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
@@ -16,7 +16,6 @@
package com.patrykandpatrick.vico.sample.showcase.charts
-import android.graphics.Typeface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
@@ -36,8 +35,8 @@ import com.patrykandpatrick.vico.compose.common.component.rememberShapeComponent
import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
import com.patrykandpatrick.vico.compose.common.of
import com.patrykandpatrick.vico.core.cartesian.HorizontalLayout
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisItemPlacer
import com.patrykandpatrick.vico.core.cartesian.axis.BaseAxis
+import com.patrykandpatrick.vico.core.cartesian.axis.HorizontalAxis
import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.CartesianValueFormatter
import com.patrykandpatrick.vico.core.cartesian.data.columnSeries
@@ -62,11 +61,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart2(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/column-layer#data. */
columnSeries { series(List(47) { 2 + Random.nextFloat() * 18 }) }
@@ -101,15 +100,15 @@ private fun ComposeChart2(modelProducer: CartesianChartModelProducer, modifier:
valueFormatter = bottomAxisValueFormatter,
itemPlacer =
remember {
- AxisItemPlacer.Horizontal.default(spacing = 3, addExtremeLabelPadding = true)
+ HorizontalAxis.ItemPlacer.default(spacing = 3, addExtremeLabelPadding = true)
},
),
+ marker = rememberMarker(),
+ horizontalLayout = HorizontalLayout.fullWidth(),
decorations = listOf(rememberComposeHorizontalLine()),
),
modelProducer = modelProducer,
modifier = modifier,
- marker = rememberMarker(),
- horizontalLayout = HorizontalLayout.fullWidth(),
)
}
@@ -120,10 +119,10 @@ private fun ViewChart2(modelProducer: CartesianChartModelProducer, modifier: Mod
{ inflater, parent, attachToParent ->
Chart2Binding.inflate(inflater, parent, attachToParent).apply {
with(chartView) {
- chart?.addDecoration(getViewHorizontalLine())
+ chart?.decorations = listOf(getViewHorizontalLine())
this.modelProducer = modelProducer
(chart?.bottomAxis as BaseAxis).valueFormatter = bottomAxisValueFormatter
- this.marker = marker
+ chart?.marker = marker
}
}
},
@@ -139,14 +138,13 @@ private fun rememberComposeHorizontalLine(): HorizontalLine {
line = rememberLineComponent(color, HORIZONTAL_LINE_THICKNESS_DP.dp),
labelComponent =
rememberTextComponent(
- background = rememberShapeComponent(Shape.Pill, color),
+ margins = Dimensions.of(HORIZONTAL_LINE_LABEL_MARGIN_DP.dp),
padding =
Dimensions.of(
HORIZONTAL_LINE_LABEL_HORIZONTAL_PADDING_DP.dp,
HORIZONTAL_LINE_LABEL_VERTICAL_PADDING_DP.dp,
),
- margins = Dimensions.of(HORIZONTAL_LINE_LABEL_MARGIN_DP.dp),
- typeface = Typeface.MONOSPACE,
+ background = rememberShapeComponent(color, Shape.Pill),
),
)
}
@@ -156,19 +154,18 @@ private fun getViewHorizontalLine() =
y = { HORIZONTAL_LINE_Y },
line = LineComponent(HORIZONTAL_LINE_COLOR, HORIZONTAL_LINE_THICKNESS_DP),
labelComponent =
- TextComponent.build {
- background = ShapeComponent(Shape.Pill, HORIZONTAL_LINE_COLOR)
+ TextComponent(
+ margins = Dimensions(HORIZONTAL_LINE_LABEL_MARGIN_DP),
padding =
Dimensions(
HORIZONTAL_LINE_LABEL_HORIZONTAL_PADDING_DP,
HORIZONTAL_LINE_LABEL_VERTICAL_PADDING_DP,
- )
- margins = Dimensions(HORIZONTAL_LINE_LABEL_MARGIN_DP)
- typeface = Typeface.MONOSPACE
- },
+ ),
+ background = ShapeComponent(HORIZONTAL_LINE_COLOR, Shape.Pill),
+ ),
)
-private const val HORIZONTAL_LINE_Y = 14f
+private const val HORIZONTAL_LINE_Y = 14.0
private const val HORIZONTAL_LINE_COLOR = -2893786
private const val HORIZONTAL_LINE_THICKNESS_DP = 2f
private const val HORIZONTAL_LINE_LABEL_HORIZONTAL_PADDING_DP = 8f
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 290fc2cf4..b5a662aa6 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
@@ -16,7 +16,6 @@
package com.patrykandpatrick.vico.sample.showcase.charts
-import android.graphics.Typeface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
@@ -30,8 +29,8 @@ import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
import com.patrykandpatrick.vico.compose.cartesian.fullWidth
+import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLine
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
import com.patrykandpatrick.vico.compose.cartesian.rememberFadingEdges
import com.patrykandpatrick.vico.compose.cartesian.rememberVicoZoomState
@@ -61,11 +60,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart3(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/line-layer#data. */
lineSeries { series(List(Defaults.ENTRY_COUNT) { Random.nextFloat() * 20 }) }
@@ -86,7 +85,8 @@ private fun ComposeChart3(modelProducer: CartesianChartModelProducer, modifier:
chart =
rememberCartesianChart(
rememberLineCartesianLayer(
- lines = listOf(rememberLineSpec(shader = DynamicShader.color(lineColor))),
+ lineProvider =
+ LineCartesianLayer.LineProvider.series(rememberLine(DynamicShader.color(lineColor))),
axisValueOverrider = axisValueOverrider,
),
startAxis =
@@ -96,10 +96,9 @@ private fun ComposeChart3(modelProducer: CartesianChartModelProducer, modifier:
titleComponent =
rememberTextComponent(
color = Color.Black,
- background = rememberShapeComponent(Shape.Pill, lineColor),
- padding = Dimensions.of(horizontal = 8.dp, vertical = 2.dp),
margins = Dimensions.of(end = 4.dp),
- typeface = Typeface.MONOSPACE,
+ padding = Dimensions.of(8.dp, 2.dp),
+ background = rememberShapeComponent(lineColor, Shape.Pill),
),
title = stringResource(R.string.y_axis),
),
@@ -107,21 +106,19 @@ private fun ComposeChart3(modelProducer: CartesianChartModelProducer, modifier:
rememberBottomAxis(
titleComponent =
rememberTextComponent(
- background = rememberShapeComponent(Shape.Pill, bottomAxisLabelBackgroundColor),
color = Color.White,
- padding = Dimensions.of(horizontal = 8.dp, vertical = 2.dp),
margins = Dimensions.of(top = 4.dp),
- typeface = Typeface.MONOSPACE,
+ padding = Dimensions.of(8.dp, 2.dp),
+ background = rememberShapeComponent(bottomAxisLabelBackgroundColor, Shape.Pill),
),
title = stringResource(R.string.x_axis),
),
+ marker = rememberMarker(DefaultCartesianMarker.LabelPosition.AroundPoint),
+ horizontalLayout = HorizontalLayout.fullWidth(),
fadingEdges = rememberFadingEdges(),
),
modelProducer = modelProducer,
modifier = modifier,
- marker = rememberMarker(DefaultCartesianMarker.LabelPosition.AroundPoint),
- runInitialAnimation = false,
- horizontalLayout = HorizontalLayout.fullWidth(),
zoomState = rememberVicoZoomState(zoomEnabled = false),
)
}
@@ -133,9 +130,8 @@ private fun ViewChart3(modelProducer: CartesianChartModelProducer, modifier: Mod
AndroidViewBinding(Chart3Binding::inflate, modifier) {
with(chartView) {
(chart?.layers?.get(0) as LineCartesianLayer?)?.axisValueOverrider = axisValueOverrider
- runInitialAnimation = false
this.modelProducer = modelProducer
- this.marker = marker
+ chart?.marker = marker
}
}
}
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 d6fe313c9..89f1ecf24 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
@@ -27,18 +27,18 @@ import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberEndAxis
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberTopAxis
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesianLayer
+import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLine
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
import com.patrykandpatrick.vico.compose.cartesian.rememberVicoZoomState
import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
import com.patrykandpatrick.vico.compose.common.shader.color
import com.patrykandpatrick.vico.compose.common.shape.rounded
-import com.patrykandpatrick.vico.core.cartesian.DefaultPointConnector
import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.columnSeries
import com.patrykandpatrick.vico.core.cartesian.data.lineSeries
import com.patrykandpatrick.vico.core.cartesian.layer.ColumnCartesianLayer
+import com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer
import com.patrykandpatrick.vico.core.common.shader.DynamicShader
import com.patrykandpatrick.vico.core.common.shape.Shape
import com.patrykandpatrick.vico.databinding.Chart4Binding
@@ -53,11 +53,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart4(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/column-layer#data. */
columnSeries {
@@ -98,21 +98,19 @@ private fun ComposeChart4(modelProducer: CartesianChartModelProducer, modifier:
)
),
rememberLineCartesianLayer(
- lines =
- listOf(
- rememberLineSpec(
- shader = DynamicShader.color(lineColor),
- pointConnector = DefaultPointConnector(cubicStrength = 0f),
- )
+ LineCartesianLayer.LineProvider.series(
+ rememberLine(
+ shader = DynamicShader.color(lineColor),
+ pointConnector = remember { LineCartesianLayer.PointConnector.cubic(curvature = 0f) },
)
+ )
),
topAxis = rememberTopAxis(),
endAxis = rememberEndAxis(),
+ marker = rememberMarker(),
),
modelProducer = modelProducer,
modifier = modifier,
- marker = rememberMarker(),
- runInitialAnimation = false,
zoomState = rememberVicoZoomState(zoomEnabled = false),
)
}
@@ -122,9 +120,8 @@ private fun ViewChart4(modelProducer: CartesianChartModelProducer, modifier: Mod
val marker = rememberMarker()
AndroidViewBinding(Chart4Binding::inflate, modifier) {
with(chartView) {
- runInitialAnimation = false
this.modelProducer = modelProducer
- this.marker = marker
+ chart?.marker = marker
}
}
}
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 b76b1253b..e7e9ea7b2 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
@@ -30,7 +30,6 @@ import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesian
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
import com.patrykandpatrick.vico.compose.cartesian.rememberVicoZoomState
import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisItemPlacer
import com.patrykandpatrick.vico.core.cartesian.axis.VerticalAxis
import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.columnSeries
@@ -48,11 +47,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart5(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/column-layer#data. */
columnSeries {
@@ -113,11 +112,10 @@ private fun ComposeChart5(modelProducer: CartesianChartModelProducer, modifier:
labelRotationDegrees = AXIS_LABEL_ROTATION_DEGREES,
),
bottomAxis = rememberBottomAxis(labelRotationDegrees = AXIS_LABEL_ROTATION_DEGREES),
+ marker = rememberMarker(),
),
modelProducer = modelProducer,
modifier = modifier,
- marker = rememberMarker(),
- runInitialAnimation = false,
zoomState = rememberVicoZoomState(zoomEnabled = false),
)
}
@@ -127,10 +125,9 @@ private fun ViewChart5(modelProducer: CartesianChartModelProducer, modifier: Mod
val marker = rememberMarker()
AndroidViewBinding(Chart5Binding::inflate, modifier) {
with(chartView) {
- runInitialAnimation = false
this.modelProducer = modelProducer
(chart?.startAxis as VerticalAxis).itemPlacer = startAxisItemPlacer
- this.marker = marker
+ chart?.marker = marker
}
}
}
@@ -142,4 +139,4 @@ private const val AXIS_LABEL_ROTATION_DEGREES = 45f
private val color1 = Color(0xff6438a7)
private val color2 = Color(0xff3490de)
private val color3 = Color(0xff73e8dc)
-private val startAxisItemPlacer = AxisItemPlacer.Vertical.count({ 3 })
+private val startAxisItemPlacer = VerticalAxis.ItemPlacer.count({ 3 })
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 61310f128..044ec1710 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
@@ -16,7 +16,6 @@
package com.patrykandpatrick.vico.sample.showcase.charts
-import android.graphics.Typeface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
@@ -59,11 +58,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart6(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/column-layer#data. */
columnSeries {
@@ -90,7 +89,6 @@ internal fun Chart6(uiFramework: UIFramework, modifier: Modifier) {
@Composable
private fun ComposeChart6(modelProducer: CartesianChartModelProducer, modifier: Modifier) {
- val horizontalBox = rememberComposeHorizontalBox()
val shape = remember { Shape.cut(topLeftPercent = 50) }
CartesianChartHost(
chart =
@@ -102,12 +100,11 @@ private fun ComposeChart6(modelProducer: CartesianChartModelProducer, modifier:
),
startAxis = rememberStartAxis(),
bottomAxis = rememberBottomAxis(valueFormatter = bottomAxisValueFormatter),
- decorations = remember(horizontalBox) { listOf(horizontalBox) },
+ marker = rememberMarker(),
+ decorations = listOf(rememberComposeHorizontalBox()),
),
modelProducer = modelProducer,
modifier = modifier,
- marker = rememberMarker(),
- runInitialAnimation = false,
zoomState = rememberVicoZoomState(zoomEnabled = false),
)
}
@@ -119,12 +116,11 @@ private fun ViewChart6(modelProducer: CartesianChartModelProducer, modifier: Mod
{ inflater, parent, attachToParent ->
Chart6Binding.inflate(inflater, parent, attachToParent).apply {
with(chartView) {
- chart?.addDecoration(getViewHorizontalBox())
- runInitialAnimation = false
+ chart?.decorations = listOf(getViewHorizontalBox())
this.modelProducer = modelProducer
(chart?.bottomAxis as HorizontalAxis).valueFormatter =
bottomAxisValueFormatter
- this.marker = marker
+ chart?.marker = marker
}
}
},
@@ -140,14 +136,13 @@ private fun rememberComposeHorizontalBox(): HorizontalBox {
box = rememberShapeComponent(color = color.copy(HORIZONTAL_BOX_ALPHA)),
labelComponent =
rememberTextComponent(
- background = rememberShapeComponent(Shape.Rectangle, color),
+ margins = Dimensions.of(HORIZONTAL_BOX_LABEL_MARGIN_DP.dp),
padding =
Dimensions.of(
HORIZONTAL_BOX_LABEL_HORIZONTAL_PADDING_DP.dp,
HORIZONTAL_BOX_LABEL_VERTICAL_PADDING_DP.dp,
),
- margins = Dimensions.of(HORIZONTAL_BOX_LABEL_MARGIN_DP.dp),
- typeface = Typeface.MONOSPACE,
+ background = rememberShapeComponent(color, Shape.Rectangle),
),
)
}
@@ -157,26 +152,25 @@ private fun getViewHorizontalBox() =
y = { horizontalBoxY },
box = ShapeComponent(color = HORIZONTAL_BOX_COLOR.copyColor(HORIZONTAL_BOX_ALPHA)),
labelComponent =
- TextComponent.build {
- typeface = Typeface.MONOSPACE
- background = ShapeComponent(Shape.Rectangle, HORIZONTAL_BOX_COLOR)
+ TextComponent(
+ margins = Dimensions(HORIZONTAL_BOX_LABEL_MARGIN_DP),
padding =
Dimensions(
HORIZONTAL_BOX_LABEL_HORIZONTAL_PADDING_DP,
HORIZONTAL_BOX_LABEL_VERTICAL_PADDING_DP,
- )
- margins = Dimensions(HORIZONTAL_BOX_LABEL_MARGIN_DP)
- },
+ ),
+ background = ShapeComponent(HORIZONTAL_BOX_COLOR, Shape.Rectangle),
+ ),
)
private const val HORIZONTAL_BOX_COLOR = -1448529
-private const val HORIZONTAL_BOX_ALPHA = .36f
+private const val HORIZONTAL_BOX_ALPHA = 0.36f
private const val HORIZONTAL_BOX_LABEL_HORIZONTAL_PADDING_DP = 8f
private const val HORIZONTAL_BOX_LABEL_VERTICAL_PADDING_DP = 2f
private const val HORIZONTAL_BOX_LABEL_MARGIN_DP = 4f
private val columnColors = listOf(Color(0xff3e6558), Color(0xff5e836a), Color(0xffa5ba8e))
-private val horizontalBoxY = 7f..14f
+private val horizontalBoxY = 7.0..14.0
private val daysOfWeek = listOf("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
private val bottomAxisValueFormatter = CartesianValueFormatter { x, _, _ ->
daysOfWeek[x.toInt() % daysOfWeek.size]
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 d682dd21b..84c564a8b 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
@@ -16,7 +16,6 @@
package com.patrykandpatrick.vico.sample.showcase.charts
-import android.graphics.Typeface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
@@ -24,15 +23,14 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidViewBinding
import com.patrykandpatrick.vico.R
import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberAxisLabelComponent
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
+import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLine
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
import com.patrykandpatrick.vico.compose.cartesian.rememberVicoZoomState
import com.patrykandpatrick.vico.compose.common.component.rememberShapeComponent
@@ -48,6 +46,7 @@ import com.patrykandpatrick.vico.core.cartesian.CartesianMeasureContext
import com.patrykandpatrick.vico.core.cartesian.axis.VerticalAxis
import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.lineSeries
+import com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer
import com.patrykandpatrick.vico.core.common.Dimensions
import com.patrykandpatrick.vico.core.common.shader.DynamicShader
import com.patrykandpatrick.vico.core.common.shape.Shape
@@ -63,11 +62,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart7(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/line-layer#data. */
lineSeries {
@@ -98,10 +97,11 @@ private fun ComposeChart7(modelProducer: CartesianChartModelProducer, modifier:
chart =
rememberCartesianChart(
rememberLineCartesianLayer(
- lines =
+ LineCartesianLayer.LineProvider.series(
chartColors.map { color ->
- rememberLineSpec(shader = DynamicShader.color(color), backgroundShader = null)
+ rememberLine(shader = DynamicShader.color(color), backgroundShader = null)
}
+ )
),
startAxis =
rememberStartAxis(
@@ -109,12 +109,11 @@ private fun ComposeChart7(modelProducer: CartesianChartModelProducer, modifier:
horizontalLabelPosition = VerticalAxis.HorizontalLabelPosition.Inside,
),
bottomAxis = rememberBottomAxis(),
+ marker = rememberMarker(),
legend = rememberLegend(),
),
modelProducer = modelProducer,
modifier = modifier,
- marker = rememberMarker(),
- runInitialAnimation = false,
zoomState = rememberVicoZoomState(zoomEnabled = false),
)
}
@@ -126,12 +125,11 @@ private fun ViewChart7(modelProducer: CartesianChartModelProducer, modifier: Mod
val legend = rememberLegend()
AndroidViewBinding(Chart7Binding::inflate, modifier) {
with(chartView) {
- runInitialAnimation = false
this.modelProducer = modelProducer
(chart?.startAxis as VerticalAxis).horizontalLabelPosition =
VerticalAxis.HorizontalLabelPosition.Inside
(chart?.startAxis as VerticalAxis).label = startAxisLabel
- this.marker = marker
+ chart?.marker = marker
chart?.legend = legend
}
}
@@ -141,9 +139,9 @@ private fun ViewChart7(modelProducer: CartesianChartModelProducer, modifier: Mod
private fun rememberStartAxisLabel() =
rememberAxisLabelComponent(
color = Color.Black,
- background = rememberShapeComponent(shape = Shape.rounded(4.dp), color = Color(0xfffab94d)),
- padding = Dimensions.of(horizontal = 8.dp, vertical = 2.dp),
- margins = Dimensions.of(all = 4.dp),
+ margins = Dimensions.of(4.dp),
+ padding = Dimensions.of(8.dp, 2.dp),
+ background = rememberShapeComponent(Color(0xfffab94d), Shape.rounded(4.dp)),
)
@Composable
@@ -152,14 +150,9 @@ private fun rememberLegend() =
items =
chartColors.mapIndexed { index, chartColor ->
rememberLegendItem(
- icon = rememberShapeComponent(Shape.Pill, chartColor),
- label =
- rememberTextComponent(
- color = vicoTheme.textColor,
- textSize = 12.sp,
- typeface = Typeface.MONOSPACE,
- ),
- labelText = stringResource(R.string.series_x, index + 1),
+ icon = rememberShapeComponent(chartColor, Shape.Pill),
+ labelComponent = rememberTextComponent(vicoTheme.textColor),
+ label = stringResource(R.string.series_x, index + 1),
)
},
iconSize = 8.dp,
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 edc808c7a..b7712b5c4 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
@@ -28,8 +28,8 @@ import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberEndAxis
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberColumnCartesianLayer
+import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLine
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
import com.patrykandpatrick.vico.compose.cartesian.rememberVicoZoomState
import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
@@ -55,11 +55,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart8(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/column-layer#data. */
columnSeries {
@@ -103,17 +103,17 @@ private fun ComposeChart8(modelProducer: CartesianChartModelProducer, modifier:
verticalAxisPosition = AxisPosition.Vertical.Start,
),
rememberLineCartesianLayer(
- lines = listOf(rememberLineSpec(shader = DynamicShader.color(color4))),
+ lineProvider =
+ LineCartesianLayer.LineProvider.series(rememberLine(DynamicShader.color(color4))),
verticalAxisPosition = AxisPosition.Vertical.End,
),
startAxis = rememberStartAxis(guideline = null),
endAxis = rememberEndAxis(guideline = null),
bottomAxis = rememberBottomAxis(),
+ marker = rememberMarker(),
),
modelProducer = modelProducer,
modifier = modifier,
- marker = rememberMarker(),
- runInitialAnimation = false,
zoomState = rememberVicoZoomState(zoomEnabled = false),
)
}
@@ -126,10 +126,9 @@ private fun ViewChart8(modelProducer: CartesianChartModelProducer, modifier: Mod
(chart?.layers?.get(0) as ColumnCartesianLayer).verticalAxisPosition =
AxisPosition.Vertical.Start
(chart?.layers?.get(1) as LineCartesianLayer).verticalAxisPosition = AxisPosition.Vertical.End
- runInitialAnimation = false
this.modelProducer = modelProducer
(chart?.startAxis as BaseAxis).guideline = null
- this.marker = marker
+ chart?.marker = marker
}
}
}
diff --git a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart9.kt b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart9.kt
index b38eb0d70..ac8a0869a 100644
--- a/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart9.kt
+++ b/sample/src/main/java/com/patrykandpatrick/vico/sample/showcase/charts/Chart9.kt
@@ -34,8 +34,8 @@ import com.patrykandpatrick.vico.compose.cartesian.axis.rememberAxisLabelCompone
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottomAxis
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStartAxis
import com.patrykandpatrick.vico.compose.cartesian.fullWidth
+import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLine
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
-import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineSpec
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
import com.patrykandpatrick.vico.compose.common.component.rememberShapeComponent
@@ -45,8 +45,9 @@ import com.patrykandpatrick.vico.compose.common.shader.component
import com.patrykandpatrick.vico.compose.common.shader.verticalGradient
import com.patrykandpatrick.vico.compose.common.shape.dashed
import com.patrykandpatrick.vico.core.cartesian.HorizontalLayout
-import com.patrykandpatrick.vico.core.cartesian.axis.AxisItemPlacer
import com.patrykandpatrick.vico.core.cartesian.axis.BaseAxis
+import com.patrykandpatrick.vico.core.cartesian.axis.HorizontalAxis
+import com.patrykandpatrick.vico.core.cartesian.axis.VerticalAxis
import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.lineSeries
import com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer
@@ -67,11 +68,11 @@ import kotlinx.coroutines.withContext
@Composable
internal fun Chart9(uiFramework: UIFramework, modifier: Modifier) {
- val modelProducer = remember { CartesianChartModelProducer.build() }
+ val modelProducer = remember { CartesianChartModelProducer() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
- modelProducer.tryRunTransaction {
+ modelProducer.runTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/line-layer#data. */
lineSeries { series(x = x, y = x.map { Random.nextFloat() * 30 - 10 }) }
@@ -95,9 +96,9 @@ private fun ComposeChart9(modelProducer: CartesianChartModelProducer, modifier:
chart =
rememberCartesianChart(
rememberLineCartesianLayer(
- lines =
- listOf(
- rememberLineSpec(
+ lineProvider =
+ LineCartesianLayer.LineProvider.series(
+ rememberLine(
shader =
TopBottomShader(DynamicShader.color(colors[0]), DynamicShader.color(colors[1])),
backgroundShader =
@@ -107,8 +108,8 @@ private fun ComposeChart9(modelProducer: CartesianChartModelProducer, modifier:
componentSize = 6.dp,
component =
rememberShapeComponent(
- shape = Shape.Pill,
color = colors[0],
+ shape = Shape.Pill,
margins = Dimensions.of(1.dp),
),
),
@@ -120,8 +121,8 @@ private fun ComposeChart9(modelProducer: CartesianChartModelProducer, modifier:
componentSize = 5.dp,
component =
rememberShapeComponent(
- shape = Shape.Rectangle,
color = colors[1],
+ shape = Shape.Rectangle,
margins = Dimensions.of(horizontal = 2.dp),
),
checkeredArrangement = false,
@@ -138,17 +139,17 @@ private fun ComposeChart9(modelProducer: CartesianChartModelProducer, modifier:
label =
rememberAxisLabelComponent(
color = MaterialTheme.colorScheme.onBackground,
+ margins = Dimensions.of(end = 8.dp),
+ padding = Dimensions.of(6.dp, 2.dp),
background =
rememberShapeComponent(
- shape = Shape.Pill,
color = Color.Transparent,
+ shape = Shape.Pill,
strokeColor = MaterialTheme.colorScheme.outlineVariant,
- strokeWidth = 1.dp,
+ strokeThickness = 1.dp,
),
- padding = Dimensions.of(horizontal = 6.dp, vertical = 2.dp),
- margins = Dimensions.of(end = 8.dp),
),
- axis = null,
+ line = null,
tick = null,
guideline =
rememberLineComponent(
@@ -156,22 +157,21 @@ private fun ComposeChart9(modelProducer: CartesianChartModelProducer, modifier:
shape =
remember { Shape.dashed(shape = Shape.Pill, dashLength = 4.dp, gapLength = 8.dp) },
),
- itemPlacer = remember { AxisItemPlacer.Vertical.count(count = { 4 }) },
+ itemPlacer = remember { VerticalAxis.ItemPlacer.count(count = { 4 }) },
),
bottomAxis =
rememberBottomAxis(
guideline = null,
itemPlacer =
remember {
- AxisItemPlacer.Horizontal.default(spacing = 3, addExtremeLabelPadding = true)
+ HorizontalAxis.ItemPlacer.default(spacing = 3, addExtremeLabelPadding = true)
},
),
+ marker = marker,
+ horizontalLayout = HorizontalLayout.fullWidth(),
),
modelProducer = modelProducer,
modifier = modifier,
- marker = marker,
- runInitialAnimation = false,
- horizontalLayout = HorizontalLayout.fullWidth(),
)
}
@@ -179,53 +179,57 @@ private fun ComposeChart9(modelProducer: CartesianChartModelProducer, modifier:
private fun ViewChart9(modelProducer: CartesianChartModelProducer, modifier: Modifier) {
val marker = rememberMarker()
val colors = chartColors
- AndroidViewBinding(Chart9Binding::inflate, modifier) {
- with(chartView) {
- runInitialAnimation = false
- this.modelProducer = modelProducer
- (chart?.bottomAxis as BaseAxis).guideline = null
- this.marker = marker
- with(chart?.layers?.get(0) as LineCartesianLayer) {
- lines =
- listOf(
- LineCartesianLayer.LineSpec(
- shader =
- TopBottomShader(DynamicShader.color(colors[0]), DynamicShader.color(colors[1])),
- backgroundShader =
- TopBottomShader(
- DynamicShader.compose(
- DynamicShader.component(
- componentSize = 6.dp,
- component =
- ShapeComponent(
- shape = Shape.Pill,
- color = colors[0].toArgb(),
- margins = Dimensions.of(1.dp),
+ AndroidViewBinding(
+ { inflater, parent, attachToParent ->
+ Chart9Binding.inflate(inflater, parent, attachToParent).apply {
+ with(chartView) {
+ this.modelProducer = modelProducer
+ (chart?.bottomAxis as BaseAxis).guideline = null
+ chart?.marker = marker
+ with(chart?.layers?.get(0) as LineCartesianLayer) {
+ lineProvider =
+ LineCartesianLayer.LineProvider.series(
+ LineCartesianLayer.Line(
+ shader =
+ TopBottomShader(DynamicShader.color(colors[0]), DynamicShader.color(colors[1])),
+ backgroundShader =
+ TopBottomShader(
+ DynamicShader.compose(
+ DynamicShader.component(
+ componentSize = 6.dp,
+ component =
+ ShapeComponent(
+ color = colors[0].toArgb(),
+ shape = Shape.Pill,
+ margins = Dimensions.of(1.dp),
+ ),
),
- ),
- DynamicShader.verticalGradient(arrayOf(Color.Black, Color.Transparent)),
- PorterDuff.Mode.DST_IN,
- ),
- DynamicShader.compose(
- DynamicShader.component(
- componentSize = 5.dp,
- component =
- ShapeComponent(
- shape = Shape.Rectangle,
- color = colors[1].toArgb(),
- margins = Dimensions.of(horizontal = 2.dp),
+ DynamicShader.verticalGradient(arrayOf(Color.Black, Color.Transparent)),
+ PorterDuff.Mode.DST_IN,
+ ),
+ DynamicShader.compose(
+ DynamicShader.component(
+ componentSize = 5.dp,
+ component =
+ ShapeComponent(
+ color = colors[1].toArgb(),
+ shape = Shape.Rectangle,
+ margins = Dimensions.of(horizontal = 2.dp),
+ ),
+ checkeredArrangement = false,
),
- checkeredArrangement = false,
+ DynamicShader.verticalGradient(arrayOf(Color.Transparent, Color.Black)),
+ PorterDuff.Mode.DST_IN,
+ ),
),
- DynamicShader.verticalGradient(arrayOf(Color.Transparent, Color.Black)),
- PorterDuff.Mode.DST_IN,
- ),
- ),
- )
- )
+ )
+ )
+ }
+ }
}
- }
- }
+ },
+ modifier,
+ )
}
private val chartColors
diff --git a/sample/src/main/res/values/chart_10_styles.xml b/sample/src/main/res/values/chart_10_styles.xml
index 989618271..c180198cf 100644
--- a/sample/src/main/res/values/chart_10_styles.xml
+++ b/sample/src/main/res/values/chart_10_styles.xml
@@ -18,6 +18,6 @@
diff --git a/sample/src/main/res/values/chart_1_styles.xml b/sample/src/main/res/values/chart_1_styles.xml
index 4ebbda7d7..24340f96a 100644
--- a/sample/src/main/res/values/chart_1_styles.xml
+++ b/sample/src/main/res/values/chart_1_styles.xml
@@ -22,6 +22,6 @@
diff --git a/sample/src/main/res/values/chart_2_styles.xml b/sample/src/main/res/values/chart_2_styles.xml
index 267dbddf0..750aab04e 100644
--- a/sample/src/main/res/values/chart_2_styles.xml
+++ b/sample/src/main/res/values/chart_2_styles.xml
@@ -28,6 +28,6 @@
diff --git a/sample/src/main/res/values/chart_3_styles.xml b/sample/src/main/res/values/chart_3_styles.xml
index ea172ec95..45b6bc87f 100644
--- a/sample/src/main/res/values/chart_3_styles.xml
+++ b/sample/src/main/res/values/chart_3_styles.xml
@@ -1,5 +1,5 @@
+
+
@@ -73,16 +78,16 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -106,15 +111,17 @@
-
+
-
+
-
+
+
+
@@ -152,7 +159,7 @@
-
+
@@ -184,6 +191,8 @@
+
+
diff --git a/vico/views/src/main/res/values/candlestick_chart_attrs.xml b/vico/views/src/main/res/values/candlestick_chart_attrs.xml
index bb2107971..f5b5f17d6 100644
--- a/vico/views/src/main/res/values/candlestick_chart_attrs.xml
+++ b/vico/views/src/main/res/values/candlestick_chart_attrs.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/vico/views/src/main/res/values/column_chart_attrs.xml b/vico/views/src/main/res/values/column_chart_attrs.xml
index 8404ecfa7..95c76cd5a 100644
--- a/vico/views/src/main/res/values/column_chart_attrs.xml
+++ b/vico/views/src/main/res/values/column_chart_attrs.xml
@@ -1,5 +1,5 @@