QCustomPlot Discussion and Comments

Custom xAxis valuesReturn to overview

Hi,
i have graph with x values 0, 1, 2 ... 4686 but those values translate to 0, 0.00051, 0.00102 ... 2.38986. And i want to display translated values on my xAxis with zoom support(fixedTicker wouldn't work i want to get values in between points) .
I have some ideas how i could achieve this:
The most straight forward way is to use translated values as graph data but some functions like moving tracer suddenly become not so pretty.

tracer->setGraphKey(tracer->position->key()-0.00051);

Other solutions i though of is to use 0.00051*1000000 for graph data and 0.00051 for xAxis values or QCPAxisTicker method
generate (const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector< double > &ticks, QVector< double > *subTicks, QVector< QString > *tickLabels)

But those 2 solutions seem complicated. What's the best approach here?

Create a sublcass of QCPAxisTicker and then reimplement only getTickLabel. Reimplementing this is very simple since you just receive the value as a double parameter tick and return a corresponding QString.

I also suggest adding an interface (i.e. getter and setter) for the scale coefficient, so you don't hardcode that value 0.00051 into your getTickLabel reimplementation.

Thanks it was easy and exactly what i wanted. As a c++ noobie it's hard to identify when I need to override certain methods :S.