Start line graph from 2nd or 3rd x value #952
Answered
by
Gowsky
binshadpix
asked this question in
Questions
-
QuestionI have two line graphs with 5 points in x values, in first graph it will have only 3 values for the line graph which means if the x values are 2020, 2021, 2022, 2023, 2024. first line graph values are:- null, null, 10, 9, 8 so i want to start the first line graph from 2022 x-value is that possible? Vico version(s)1.12.0 UI framework(s)Jetpack Compose |
Beta Was this translation helpful? Give feedback.
Answered by
Gowsky
Nov 14, 2024
Replies: 1 comment 1 reply
-
Hello, @binshadpix. Yes, it is possible. You just have to set the data you'd like to be rendered. Here's an example. // Your example data
val x = listOf(2020, 2021, 2022, 2023, 2024)
val y1 = listOf(null, null, 10, 9, 8)
val y2 = listOf(8, 9, 6, 2, 7)
// Inside of a function that updates your data
val series1 = x.mapIndexedNotNull { index, x -> y1[index]?.let { y -> entryOf(x, y) } }
val series2 = x.zip(y2, ::entryOf)
chartEntryModelProducer.setEntries(series1, series2) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
binshadpix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, @binshadpix. Yes, it is possible. You just have to set the data you'd like to be rendered. Here's an example.