feat(graphs): add chart animation for when a value changes

This commit is contained in:
Nishant Mishra
2025-12-04 11:04:34 +05:30
parent 3c86c2ce38
commit a5d3918522
2 changed files with 6 additions and 2 deletions

View File

@@ -22,6 +22,7 @@ import androidx.compose.animation.core.AnimationSpec
import androidx.compose.foundation.layout.height
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.motionScheme
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
@@ -96,7 +97,7 @@ fun TimeColumnChart(
millisecondsToMinutes(value, minutesFormat)
}
},
animationSpec: AnimationSpec<Float>? = null
animationSpec: AnimationSpec<Float>? = motionScheme.defaultEffectsSpec()
) {
ProvideVicoTheme(rememberM3VicoTheme()) {
CartesianChartHost(
@@ -160,6 +161,7 @@ fun TimeColumnChart(
minZoom = Zoom.min(Zoom.Content, Zoom.fixed())
),
animationSpec = animationSpec,
animateIn = false,
modifier = modifier.height(226.dp),
)
}

View File

@@ -22,6 +22,7 @@ import androidx.compose.animation.core.AnimationSpec
import androidx.compose.foundation.layout.height
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.motionScheme
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
@@ -102,7 +103,7 @@ fun TimeLineChart(
millisecondsToMinutes(value, minutesFormat)
}
},
animationSpec: AnimationSpec<Float>? = null
animationSpec: AnimationSpec<Float>? = motionScheme.defaultEffectsSpec()
) {
ProvideVicoTheme(rememberM3VicoTheme()) {
CartesianChartHost(
@@ -183,6 +184,7 @@ fun TimeLineChart(
minZoom = Zoom.min(Zoom.Content, Zoom.fixed())
),
animationSpec = animationSpec,
animateIn = false,
modifier = modifier.height(224.dp),
)
}