feat: Add basic Stacked charts support (#22)

This commit is contained in:
2023-01-12 21:56:29 +01:00
committed by GitHub
parent 6afe0a938e
commit ed06aa697e
6 changed files with 104 additions and 18 deletions

View File

@ -37,15 +37,15 @@ class MainFragment : Fragment() {
val serie2 = BarSerie(this)
// transform the chart into a grouped chart
type = ChartType.GROUPED
type = ChartType.STACKED
// 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)
serie1.entries = generateRandomDataset(1)
serie2.entries = generateRandomDataset(1)
// refresh the Chart
refresh()
@ -164,7 +164,7 @@ class MainFragment : Fragment() {
private fun generateRandomDataset(size: Int = 100, min: Int = 0, max: Int = 100): ArrayList<Entry> {
val dataset: ArrayList<Entry> = arrayListOf()
for (i in 0 .. size) {
for (i in 0 until size) {
dataset.add(Entry(
i.toDouble(),
Random.nextInt(min, max).toFloat()
@ -233,4 +233,4 @@ class MainFragment : Fragment() {
}
}
}
}
}