Skip to content

Start line graph from 2nd or 3rd x value #952

Answered by Gowsky
binshadpix asked this question in Questions
Discussion options

You must be logged in to vote

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)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@binshadpix
Comment options

Answer selected by binshadpix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants