I'm trying to make the right axis draggable.
Right now using one of the site examples im able to make the first yAxis
draggable by double clicking on it.
void MainWindow::mousePress()
{
// if an axis is selected, only allow the direction of that axis to be dragged
// if no axis is selected, both directions may be dragged
if (ui->customPlot->xAxis->selectedParts().testFlag(QCPAxis::spAxis))
ui->customPlot->axisRect()->setRangeDrag(ui->customPlot->xAxis->orientation());
else if (ui->customPlot->yAxis->selectedParts().testFlag(QCPAxis::spAxis))
ui->customPlot->axisRect()->setRangeDrag(ui->customPlot->yAxis->orientation());
else if (ui->customPlot->yAxis2->selectedParts().testFlag(QCPAxis::spAxis))
ui->customPlot->axisRect()->setRangeDrag(ui->customPlot->yAxis2->orientation());
else
ui->customPlot->axisRect()->setRangeDrag(Qt::Horizontal|Qt::Vertical);
}
My graphs has 2 lines, each with a different yAxis
.
What I would like to achieve is the same draggable effect on the second (on the right) yAxis
which is called yAxis2
.
With the code below even if I select the yAxis2
, it is the yAxis
which is dragged vertically.
I guess the problem is in axisRect() which is related only to the left yAxis rather than both of them.
I solved by modifiying the code in order to perform the drag calls on the right axis as well. It is pretty straightforward if one takes a look on what happens on the left axis.