Real time charting labels position

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Real time charting labels position

Post by Petr » Tue Nov 12, 2013 1:26 pm

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?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Real time charting labels position

Post by Sandra » Thu Nov 14, 2013 12:49 pm

Hello Petr,

Could you send us a simple project, where we can reproduce your problem here and we try to solve it?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Marc
Site Admin
Site Admin
Posts: 1265
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Real time charting labels position

Post by Marc » Thu Nov 14, 2013 1:28 pm

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
Steema Support

Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Re: Real time charting labels position

Post by Petr » Thu Nov 14, 2013 2:55 pm

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.
Attachments
labels2.png
labels2.png (308.87 KiB) Viewed 11878 times
labels1.png
labels1.png (302.29 KiB) Viewed 11874 times

Marc
Site Admin
Site Admin
Posts: 1265
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Real time charting labels position

Post by Marc » Fri Nov 15, 2013 10:42 am

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
Steema Support

Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Re: Real time charting labels position

Post by Petr » Fri Nov 15, 2013 11:55 am

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!
Attachments
GrapherProject.rar
(57.67 KiB) Downloaded 602 times

Marc
Site Admin
Site Admin
Posts: 1265
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Real time charting labels position

Post by Marc » Mon Nov 18, 2013 4:17 pm

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
Steema Support

Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Re: Real time charting labels position

Post by Petr » Tue Nov 19, 2013 8:00 am

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.

Post Reply