Two axis Y with different variables
Opened this issue ยท 14 comments
I needed to implement linear chart with two Y variables. I used rightTitles and leftTitles. And calculated Spot Y for the second variable as (Y2 - minY2) / (maxY2 - minY2) * (maxY - minY) + minY to show it correctly in chart.
I needed to implement linear chart with two Y variables. I used rightTitles and leftTitles. And calculated Spot Y for the second variable as (Y2 - minY2) / (maxY2 - minY2) * (maxY - minY) + minY to show it correctly in chart.
Do you have an example to show me? I would be very grateful.
Thanks, @ldemyanenko your solution is smart.
Any update on this?
I am eagerly waiting for this feature... ๐
Any updates here?
I need this feature. (Comming from #1199)
Nothing? Stopped here?
Is there any development on the issue? Still in need of this feature. Calculating the second spotY using the first one doesn't work for me since the ratio between my spotY values differs.
It's possible to insert a second variable that seems to refer to the right axis. The variable must be scaled to the left axis, and lineTouchData
of LineChartData
overrided to scale back the labels:
lineTouchData: LineTouchData(
touchTooltipData: LineTouchTooltipData(
getTooltipItems: (lineBarSpotList) {
final List<LineTooltipItem> lineTooltipItemList = lineBarSpotList.map((lineBarSpot) => LineTooltipItem(
(lineBarSpot.y * (lineBarSpot.bar.color == colorOfRightAxisVariable ? rightLeftRatio : 1)).toStringAsFixed(1),
TextStyle(color: lineBarSpot.bar.color, fontWeight: FontWeight.bold)
)).toList();
return lineTooltipItemList;
},
),
),
Since the order of the LineBarSpot's as parameters of the function depends on the order of the values (sometimes the value that must be scaled is the biggest and the first, some other is the smallest and the second), the correct LineBarSpot can be identified by the bar.color property.
Any updates on this would be much appreciated