1 Attachment(s)
Set offset for first scale line in the plot
Hello All,
I am very new to Qwt. To support our current application I am looking for the solution to my below problem.
I have an application data plotted using qwt and it works fine. I refresh my data every 5 seconds.
I have set lower and upper bound along with Major steps size using "setAxisScale"
It displays the label of the Major ticks automatically, However I would like to set the scale such that it displays the time in round figure.
Currently it displays the time randomly (at least to me!!) for example, I have given the step size as 1 Hour so it displays the label something like,
12.01, 13.01, 14.01... etc
How can I modify such that my xaxes adjust Major ticks to displays time in round figure like 12.00, 13.00, 14.00 ??
Can I set the offset for first Major tick to round the time and other Major ticks fall in line based on step size?
Attachment 12143
I have overloaded the label function to get the time in HH:mm format and it works fine.
Code:
{
virtual QwtText label
(double v
) const {
quint32 displytime = (int)v;
if (displytime == 0) {
}
else {
displytime = quint32(v) - m_pd.baseSeconds;
displytime *= m_pd.dataReso.width();
displytime += m_pd.baseSeconds;
}
std::string sp_temp = t.toString(format).toStdString();
return t.toString(format);
}
};
*** Here, baseSeconds are the lower bound value of my graph
However I assume that there would be some setting in the plot which will help me get the scale drawn on the hourly rounded time points.
I am not just looking at the the changing label but label should be appropriate according to the graph position
Thanks
/SP
Re: Set offset for first scale line in the plot
In general there is a date/time based scale system ( QwtDateScaleEngine + QwtDateScaleDraw ), that creates useful ticks for date/time scales.
But from your code it looks like you need a scale that displays the time elapsed since some point in time. This would be a different type of scale engine ( on my TODO list for quite some time ).
To make it short: you also need to implement a scale engine, what mostly means to provide 2 algos for aligning a given interval and then finding the ticks.
Uwe
Re: Set offset for first scale line in the plot
Thanks for the response uwe!!
Yes, in my case I have scaling working for me but only thing is it automatically displays the scale which I want to stream line so that my Major Ticks are drawn at round figure time like 8.00, 9.00, 10.00 based on my tick size as 60 minutes
So, here I think if I am able to set the position for first major tick then rest will fall in line, is it possible?
I was looking at QwtScaleDiv class but did not get much information on how I can utilize it.
I am trying to set the QList of Major ticks (not yet achieved) to set the position of my major ticks to see if it helps me.
Thanks
/SP