QCustomPlot Discussion and Comments

bind range of multi plots togetherReturn to overview

Hi,
Thanks for great lib.
I'm using QCPMarginGroup to hold and allow synchronization of multi plots. If I want to bind range of plots together, how can i do that? For example whenever user changes the range of a plot, range of other plots change respectively(same range for all plots) .

Hi,

This features had been in the previous version of the lib, in the main window example but I can't find it in the new one...
Here is how it's done :
Let's say I have 3 custom plots and that whenever I grab the X axis of one of them I want them to be synchronized...

// Synchronizing plots axis
connect(_plotVertical->xAxis, SIGNAL(rangeChanged(QCPRange)), _plotNorth->xAxis, SLOT(setRange(QCPRange)));
connect(_plotVertical->xAxis, SIGNAL(rangeChanged(QCPRange)), _plotEast->xAxis, SLOT(setRange(QCPRange)));
connect(_plotNorth->xAxis, SIGNAL(rangeChanged(QCPRange)), _plotVertical->xAxis, SLOT(setRange(QCPRange)));
connect(_plotNorth->xAxis, SIGNAL(rangeChanged(QCPRange)), _plotEast->xAxis, SLOT(setRange(QCPRange)));
connect(_plotEast->xAxis, SIGNAL(rangeChanged(QCPRange)), _plotVertical->xAxis, SLOT(setRange(QCPRange)));
connect(_plotEast->xAxis, SIGNAL(rangeChanged(QCPRange)), _plotNorth->xAxis, SLOT(setRange(QCPRange)));
connect(_plotVertical, SIGNAL(afterReplot()), _plotNorth, SLOT(replot()));
connect(_plotVertical, SIGNAL(afterReplot()), _plotEast, SLOT(replot()));
connect(_plotNorth, SIGNAL(afterReplot()), _plotVertical, SLOT(replot()));
connect(_plotNorth, SIGNAL(afterReplot()), _plotEast, SLOT(replot()));
connect(_plotEast, SIGNAL(afterReplot()), _plotVertical, SLOT(replot()));
connect(_plotEast, SIGNAL(afterReplot()), _plotNorth, SLOT(replot()));

Hope this helps.

Cheers!

I have just bind rangeChanged/setRangeChanged signal/slots and it works. It seems that replot() is not needed after range change.