Performance issues #699
Replies: 3 comments 2 replies
-
|
Hello @Salocin808, can you provide a MRE that is self-contained? The code you shared contains references that are unknown. |
Beta Was this translation helpful? Give feedback.
-
|
I fixed this issue by downsampling my data and adapting the x axis accordingly. private const val DOWN_SAMPLING_FACTOR = 5
private fun downsampleData(data: MutableList<Int>): List<Int> {
return data.chunked(DOWN_SAMPLING_FACTOR).map { chunk ->
val average = chunk.average()
if (average >= 0.5) 1 else 0
}
}
@Composable
fun AppScheduleChart(
activeTimeSlots: ImmutableList<ActiveTimeSlot>,
modifier: Modifier = Modifier,
) {
val yValues = List(MINUTE_OF_DAY_MAX_CLIMATIX_VALUE) { Y_MIN }.toMutableList()
val xValues = (0 until (MINUTE_OF_DAY_MAX_CLIMATIX_VALUE / DOWN_SAMPLING_FACTOR)).toList()
activeTimeSlots.forEach {
for (i in it.startMinuteOfDay..it.endMinuteOfDay) {
yValues[i] = Y_MAX
}
}
val modelProducer = remember { CartesianChartModelProducer.build() }
LaunchedEffect(activeTimeSlots) {
withContext(Dispatchers.Default) {
modelProducer.tryRunTransaction {
lineSeries {
series(xValues, downsampleData(yValues))
}
}
}
}
Chart(modelProducer = modelProducer, modifier = modifier)
}
Now I have 288 values instead of 1440 and everything runs smoothly. I still wonder why the previous vico version was able to handle it though. In any case, this works for me. But its definately worth looking into for you guys. |
Beta Was this translation helpful? Give feedback.
-
|
We're closing this in favour of #1025. Please note that @patrickmichalik's comment indicates the key issue in this case. Fixing the problems mentioned there should address any performance issues. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey @patrickmichalik
I currently have massive performance issues with a fairly simple graph:
The x axis represents minutes of the day (1440 values). I am drawing the chart with
getXStep = { 60f * 6 }.Especially with older devices but also with newer ones, displaying these charts takes a long time. While debugging I realized, that
drawBackgroundLineis really slowSo I set
backgroundShader = null. This makes it better but still not optimal. Reducing the dataset to half the points (~700 values) also increases performance but neither options are viable solutions for me.Do you have any idea how I could increase the performance?
Note that I was migrating this chart from
1.14.0to vico2. With the old version it was running smoothlyBeta Was this translation helpful? Give feedback.
All reactions