One Line chart with two data sets #962
Answered
by
Gowsky
wojtekkula3
asked this question in
Questions
-
Beta Was this translation helpful? Give feedback.
Answered by
Gowsky
Nov 28, 2024
Replies: 1 comment 2 replies
-
Hello, @wojtekkula3. This is possible in both Vico val modelProducer = ComposedChartEntryModelProducer.build() modelProducer.runTransaction {
add(entriesOf(40, 60, 80, 150))
add(entriesOf(10, 30, 50, 60))
} val lineChart1 =
lineChart(
axisValuesOverrider = AxisValuesOverrider.fixed(maxY = 200f),
targetVerticalAxisPosition = AxisPosition.Vertical.Start,
)
val lineChart2 =
lineChart(
axisValuesOverrider = AxisValuesOverrider.fixed(maxY = 100f),
targetVerticalAxisPosition = AxisPosition.Vertical.End,
)
val itemPlacer = remember { AxisItemPlacer.Vertical.default(maxItemCount = 5) }
Chart(
chart = remember(lineChart1, lineChart2) { lineChart1 + lineChart2 },
chartModelProducer = modelProducer,
startAxis = rememberStartAxis(itemPlacer = itemPlacer),
endAxis = rememberEndAxis(guideline = null, itemPlacer = itemPlacer),
bottomAxis = rememberBottomAxis(),
) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
wojtekkula3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, @wojtekkula3. This is possible in both Vico
1.15.0
and Vico2.0.0-beta.3
. To implement it, instead of using a singleLineChart
/LineCartesianLayer
with two series, you should use two (each with one series) and link them to separate y-axes. Below is an example for Vico 1.15.0. It usesComposedChartEntryModelProducer
, but you can also create the model manually if needed.