Clear Chart and set XAxis range

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
thade.oconnor
Posts: 4
Joined: Thu Sep 05, 2013 4:12 am

Clear Chart and set XAxis range

Post by thade.oconnor » Wed Sep 11, 2013 10:32 pm

Hi,

I have a WPF data series chart which I need to clear based on a user request. The plot has time on the X axis, in the format MM:SS. The only problem is that when I set the XAxes range to SetRange(0, plotXrange) - to reset the axis lables (to start at 0:00), that if the plot has been running for more than a (approx) minute it will reset to 1:00 (or 2:00 if longer than two minutes of run time).

Is there a different function call required? I've checked through your PDF, however couldn't find anything that was more appropriate.

Reset code included below:

//This is only called on reset event.

Code: Select all

m_chart.BeginUpdate();
{
                foreach (SampleDataSeries sds in m_chart.ViewXY.SampleDataSeries)
                {
                    sds.Clear();
                }
                m_chart.ViewXY.XAxes[0].SetRange(0, plotXrange);
}
m_chart.EndUpdate();

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Clear Chart and set XAxis range

Post by ArctionPasi » Sat Sep 14, 2013 4:56 pm

Hi Thade,

I believe the correct LabelsTimeFormat is "mm:ss". MM is for months.

To check I've understood your goal correctly... in the reset command, you want the labels start at 0:00. Your SetRange makes that correctly. Probably the problem is in sds.FirstSampleTimeStamp, which you should set to 0 too.

:) I hope it helps...
LightningChart Support Team, PT

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Clear Chart and set XAxis range

Post by ArctionPasi » Sun Sep 15, 2013 4:35 pm

...and set xAxis.ScrollPosition = 0, that is the real-time scroll position property which makes the chart scroll, sweep or step with optimal efficiency. xAxis.SetRange is not needed.

:ugeek:
LightningChart Support Team, PT

thade.oconnor
Posts: 4
Joined: Thu Sep 05, 2013 4:12 am

Re: Clear Chart and set XAxis range

Post by thade.oconnor » Wed Sep 25, 2013 2:19 am

Hi,

I've added xAxis.ScrollPosition = 0. This has generally worked however I have noticed sometimes that the chart will restart in the center of the graph.

Note: that my chart is reversed (which may be a factor).

Have you got any idea that might be happening with my plot.

Regards,
Thade

Image

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Clear Chart and set XAxis range

Post by ArctionPasi » Wed Sep 25, 2013 4:30 am

Are you sure you have set FirstSampleTimeStamp to 0? And if you are keeping the latest X value in a member variable, remember to reset it too. m_dCurrentX = 0.

I tested with Thread-fed multi-channel data example. I just set xAxis.Reversed = True. Other code changes I didn't make. By setting Scroll mode to Scrolling, and using Starting, Stopping and Starting again worked correctly. Your Reset operation should be pretty much Like Stop and Start, right?
LightningChart Support Team, PT

Post Reply