Herr von Wurst
Herr von Wurst

Reputation: 2621

QCharts Second Y Axis on the Right Side

I want to place a second ValueAxis on the right side of a ChartView. The documentation states that "The axes can be placed down, up, left, or right of the chart."

However I find no property in the documentation of AbstractAxis, ValueAxis or ChartView that accords to this. Only the alignment property of AbstractAxis drew my attention, however it is const and can not be modified in QML:

Invalid property assignment: "alignment" is a read-only property

I can see that there is a C++ way to set the alignment in the Multiple Axes Example, but I am looking for a QtQuick way to set the alignment. Am I missing something here?

Upvotes: 2

Views: 2766

Answers (1)

folibis
folibis

Reputation: 12854

Use appropriate properties of series instead of axis, for example:

ValueAxis {
    id: axisX
}
ValueAxis {
    id: axisY
}
LineSeries { // axes are right-bottom
    axisX: axisX
    axisYRight: axisY
}
LineSeries { // axes are top-left
    axisXTop: axisX
    axisY: axisY
}

And yes, I agree that alignment is misleading and that would be clearer to set axis using this property.

Upvotes: 5

Related Questions