feat: Add basic animation support (#20)

This commit is contained in:
2023-01-12 22:24:00 +01:00
committed by GitHub
parent ed06aa697e
commit c9fee7ca24
11 changed files with 176 additions and 45 deletions

View File

@ -36,16 +36,42 @@ class MainFragment : Fragment() {
val serie1 = BarSerie(this)
val serie2 = BarSerie(this)
animator.duration = 750
// transform the chart into a grouped chart
type = ChartType.STACKED
type = ChartType.GROUPED
yAxis.setYMin(0f)
// utils function to use Material3 auto colors
materielTheme(this, requireView())
serie2.barPaint.color = Color.RED
// give the serie it's entries
serie1.entries = generateRandomDataset(1)
serie2.entries = generateRandomDataset(1)
serie1.entries = generateRandomDataset(5)
serie2.entries = generateRandomDataset(5)
// refresh the Chart
refresh()
}
binding.chartStacked.apply {
// setup the Serie
val serie1 = BarSerie(this)
val serie2 = BarSerie(this)
animator.duration = 750
// transform the chart into a grouped chart
type = ChartType.STACKED
yAxis.setYMin(0f)
// utils function to use Material3 auto colors
materielTheme(this, requireView())
serie2.barPaint.color = Color.RED
// give the serie it's entries
serie1.entries = generateRandomDataset(10)
serie2.entries = generateRandomDataset(10)
// refresh the Chart
refresh()
@ -68,6 +94,7 @@ class MainFragment : Fragment() {
binding.chartBar.apply {
// setup the Serie
val serie = BarSerie(this)
yAxis.setYMin(0f)
// utils function to use Material3 auto colors
materielTheme(this, requireView())

View File

@ -23,6 +23,11 @@
android:layout_width="match_parent"
android:layout_height="200dp" />
<com.dzeio.charts.ChartView
android:id="@+id/chart_stacked"
android:layout_width="match_parent"
android:layout_height="200dp" />
<com.dzeio.charts.ChartView
android:id="@+id/chart_customization"
android:layout_width="match_parent"
@ -41,4 +46,4 @@
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>