mirror of
https://github.com/dzeiocom/charts.git
synced 2025-06-14 20:09:20 +00:00
feat: Add basic animation support (#20)
This commit is contained in:
@ -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())
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user