Page 1 of 1
Real time charting labels position
Posted: Tue Nov 12, 2013 1:26 pm
by 15666633
Hello, I have a realtime chart, and i need fixed labels position on bootom axis. I set Increment property to some constant value, and use this
Code: Select all
private void ScrollAxis()
{
if (m_plot.XValues.Last >= m_plot.Chart.Axes.Bottom.Maximum
&&
!Helper.IsPainterInStaticMode)
{
double range = m_plot.Chart.Axes.Bottom.Maximum - m_plot.Chart.Axes.Bottom.Minimum;
m_plot.Chart.Axes.Bottom.SetMinMax(m_plot.XValues.Last - range , m_plot.XValues.Last );
m_plot.Chart.Axes.Bottom.IncrementOffset = m_plot.Chart.Axes.Bottom.Increment - m_plot.XValues.Last % m_plot.Chart.Axes.Bottom.Increment;
}
}
function to scroll axis to the proper position, and leave labbels on fixed place( by setting ). Everything is fine except one thing, the last one label blinks periodicaly. Is it a computational problem? Or may be there is some special mode tahat lets showing axis labels on fixed positions?
Re: Real time charting labels position
Posted: Thu Nov 14, 2013 12:49 pm
by 10050769
Hello Petr,
Could you send us a simple project, where we can reproduce your problem here and we try to solve it?
Thanks,
Re: Real time charting labels position
Posted: Thu Nov 14, 2013 1:28 pm
by Marc
Hello,
When you say
last one label blinks periodicaly
that refers to the label not plotting at all when some values are set and then showing again when a different value is set? Do the labels themselves vary in text width? ..ie. with decimal fractions?
Regards,
Marc
Re: Real time charting labels position
Posted: Thu Nov 14, 2013 2:55 pm
by 15666633
Hi Marc!
No, i mean that labels must have constant position on the canvas, but the labels value vary constantle.
On this two pics You can see What i want to have.
As you can see the values are different, but the labels positions are same places, and the range of bottom axis is also constant. Also you can find that it's a realtime chart. So everytime, when series updates, i use to recalculate increment ofset wit Scroll axis function. That's no correct, because it doesn't work properly if Canvas Size() changes. So i'm looking the different way to solve this problem. Any advices?
P.S. Text length is constatnt.
Re: Real time charting labels position
Posted: Fri Nov 15, 2013 10:42 am
by Marc
Hell Petr,
Your approach seems a very valid way of resolving the requirement. I'll run it up here with your code sample and see if I can see the problem plus a way of getting around it.
You say
doesn't work properly if Canvas Size() changes
Are you referring to the automatic resizing of the Chart rectangle as data is added .. or some manual resizing done externally to the auto-chart-code (eg. resizing of the window)?
Regards,
Marc
Re: Real time charting labels position
Posted: Fri Nov 15, 2013 11:55 am
by 15666633
Hi mark,
you wrote
or some manual resizing done externally to the auto-chart-code (eg. resizing of the window)?
exactly, so canvas size changes automaticaly.
I attached my project, for better understanding my problems, for this question and some other topics on fhe forum.
firstly you should build the solution, because order is important, when you will start it press AddplotButton, and try to resize the form, not only like minimizing/maximizing, so you will see the problem, that axis start moves. And also you will be able to see the problem i discribed in the first post of this topic.
Thank you!
Re: Real time charting labels position
Posted: Mon Nov 18, 2013 4:17 pm
by Marc
Hello Petr,
There are four properties that have an effect on the output.
Label size affects how the labels fit to the Axis so for tests we set them to vertical to give then the room they need:
Code: Select all
m_TChart.Axes.Bottom.Labels.Angle = 90;
If you turn RoundFirstLabel off then the calculation won't try to 'move-to-fit' a rounded label (that affects the last rendered label too)
Code: Select all
m_TChart.Axes.Bottom.Labels.RoundFirstLabel = false;
With that, if the way the first labels are set is acceptable to you, you may have the solution you require.
If not you can further adjust the first and last labels to fit withn the render zone of the Chart label (with or without RoundFirstLabel set to true/false)
Code: Select all
m_TChart.Axes.Bottom.MinimumOffset = 15;
m_TChart.Axes.Bottom.MaximumOffset = 15;
I hope that may be of help.
Regards,
Marc
Re: Real time charting labels position
Posted: Tue Nov 19, 2013 8:00 am
by 15666633
Hi Mark!
With
Code: Select all
m_TChart.Axes.Bottom.MinimumOffset = 1;
m_TChart.Axes.Bottom.MaximumOffset = 0;
that looks exactly like i need. More than this i don't need to recalculate increment offset anymore.Thanks a lot.