Cant assign axisYRight to LineSeries created at runtime
-
Hello everyone,
I am working on an application that creates LineSeries at runtime.
The problem I am having is that I need two y-Axis, meaning that one has to be an axisYRight.
When dynamically creating the LineSeries I cant assign one of the y-Axis as an axisYRight, trying to assign the axis afterwards does nothing.
I have tried getting around the problem by already having a LineSeries with the correct axis in the View and setting the unwanted axis to invisible but
this leads to the LineSeries accepting a completely different and wrong scaling or that LineSeries not showing up at all.Is there a way to correctly implement this?
The following code illustrates the issue.ChartView { id: linechart; anchors.fill: parent; property var updateChart: chartContext.updateChart; title: chartContext.chartTitle; antialiasing: true; ValueAxis { id: xAxis; min: chartContext.minXAxis; max: chartContext.maxXAxis; } ValueAxis { id: yAxis; min: chartContext.minYAxis; max: chartContext.maxYAxis; } ValueAxis { id: yAxis2; min: chartContext.minYAxis2; max: chartContext.maxYAxis2; } onUpdateChartChanged: { linechart.removeAllSeries(); for (var i = 0; i < dataModel.numberOfSeries; ++i) { var lineSeries; if (dataModel.axisLocation(i) == "Right") { lineSeries = linechart.createSeries(ChartView.SeriesTypeLine, dataModel.getYLabel(i), xAxis); lineSeries.axisYRight = yAxis2; } else { lineSeries = linechart.createSeries(ChartView.SeriesTypeLine, dataModel.getYLabel(i), xAxis, yAxis); } } } }
Code example taken from: https://stackoverflow.com/q/43543560
Thanks for your help.