QCustomPlot Discussion and Comments

My labels of xAxis will concentrate too much so that they Crowded together while I zoom xAxis out.Return to overview

the labels is set by "xAxis->setTickVectorLabels(labels);".
How to avoid their overlapping while zooming?

This has to be done at the application level, I would share my whole code but it is very specific to my program so I don't think it would be very useful.

This function will need to be called as the window is re-sized or the plot is zoomed.

High level code:

pass in pointers to your full data set

create 2 new vectors to store your modified axis data

//Determine how many labels could fit on the plot(my labels are ~54 pixels wide)
numberOfLabels = activePlot()->axisRect()->width() / 54;

//Determine your viewing window
window = activePlot()->xAxis->range().size()/numberOfLabels;

iterate through your full data set and add a label for each window

//Set the axis ticks information

As you zoom more labels are added as your window shrinks.

but how to handle zoom event?

It depends on how you are zooming. If you use the mouse wheel connect the mouseWheel signal to a slot in your code. In that slot call the function to re-generate your axis with the new bounds.

connect(customPlot, SIGNAL(mouseWheel(QWheelEvent*)),
this, SLOT(mouseWheel()));