Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

FormatStringMode.DateTime, "mm:ss"

Solved!
Go to solution

Hi. I have changed the X-Axis to show the time interval mm:ss using the following;

 

grBurner.XAxes(0).MajorDivisions.LabelFormat() = New NationalInstruments.UI.FormatString(FormatStringMode.DateTime, "mm:ss")

 

This has worked fine with the update frequence at 1 Hz.

 

Now the Update is 4Hz  how I show the Axis in 1/4 seconds ?  (mm:ss:??)

 

Thanks

 

Richard.

0 Kudos
Message 1 of 11
(6,619 Views)

Hello Richard,

 

You could try:

 

grBurner.XAxes(0).MajorDivisions.LabelFormat() = New NationalInstruments.UI.FormatString(FormatStringMode.DateTime, "mm:ss.ff");

 

Let me know if that's not suitable for you.

 

NickB

National Instruments

Message 2 of 11
(6,617 Views)
Solution
Accepted by topic author Richard_Hirst

Hi Nick

 

No that did not work. it put the label correct as in 01:30.00  = 1.5 mins..

 

When the data is appended to the graph the time index is out by a factor of 4. ie. four samples = 4 seconds not 1 second.

 

Regards

 

Richard.

0 Kudos
Message 3 of 11
(6,614 Views)

Hi Richard,

 

I hope your well.

 

If your graph is showing the number of samples rather than the time the samples were collected - then this would suggest you have not generated the correct time data (time stamped) the data. How are you doing this, could you post a piece of example code?

 

Kind Regards,
James.

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 4 of 11
(6,599 Views)

Hello Richard,

 

I forgot to mention that if you are only using PlotY or PlotYAppend, you will need to specify a default increment.  You can do this by editing the plot object, either programmatically through: 

 

waveformPlot1.DefaultIncrement = .25;

 

or by specifying it through the UI Properties Dialog Box:

 

 

 

NickB

National Instruments

Message Edited by nickb on 11-27-2008 11:00 AM
Message 5 of 11
(6,597 Views)

Hi Nick.

 

Thanks for the information.

 

I just noticed that the Scatter Graph which I was using did not have this Property. So I have changed to a Waveform Graph and it displays the correct X Axis with the Increment set to 0.25.

 

Many Thanks

 

Richard.

0 Kudos
Message 6 of 11
(6,582 Views)

Hello Richard,

 

I'm glad you've gotten it working.  I did want to follow up with you on the scattergraph though.  The reason that you do not have the defalutincrement property on the scatterplot object is because you are responsible for the timing information when you supply the data.  A very simple example follows that demonstrates what I mean:

 

        private void Form1_Load(object sender, EventArgs e)
        {
            double time = 0;
            double[] data = new double[10];
            double[] timing = new double[10];
            Random rand = new Random();

            for (int i = 0; i<data.Length; i++)
            {
                data[i] = rand.NextDouble();
                timing[i] = time;
                time += .25;
            }
            scatterGraph1.PlotXY(timing, data);

            scatterGraph1.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "mm:ss.ff");
        }

 

Here you can see that the timing array increments at 4Hz, and when plotted, displays the same as I'm sure your waveform graph now shows.  I just bring this to your attention in case the scatter plot really is more suited to your needs (ie, you want to have explicit control over the timing information associated with the y data)

 

 

 

NickB

National Instruments

Message Edited by nickb on 11-27-2008 03:46 PM
Message 7 of 11
(6,580 Views)

Hi Nick.

 

Working ok now using Scattergraph. I did not realise you could add 0.25 to the Axis.

 

Thanks for your help.

 

Richard.

0 Kudos
Message 8 of 11
(6,523 Views)

Hi Nick,

 

Following on from you surgestion, I have found out that when I Pan or Zoom the graph less than the 'Zero' point I get the following erros message. I guess the graph is trying to display time less than zero.?

 

How can I trap this..?

 

Thanks

 

Richard

 

 

 

System.ArgumentOutOfRangeException was unhandled
  Message="Only double values within a range of 0, or DateTime.MinValue, to 315537897599, or DateTime.MaxValue, can be converted to DateTime.\r\nParameter name: source"
  Source="NationalInstruments.Common"
  ParamName="source"
  StackTrace:
       at NationalInstruments.DataConverter.ConvertToDateTimeHandler(Object source, Type targetType)
       at NationalInstruments.DataConverter.Convert(Object source, Type targetType)
       at NationalInstruments.UI.FormatString.FormatDouble(Double value)
       at NationalInstruments.UI.Internal.bn.a(Graphics A_0, Font A_1, FormatString A_2, Double A_3)
       at NationalInstruments.UI.Internal.c3.a(Graphics A_0, c A_1, Int32 A_2, Double A_3)
       at NationalInstruments.UI.Internal.az.a(Graphics A_0)
       at NationalInstruments.UI.Internal.az.d(ds A_0)
       at NationalInstruments.UI.Internal.ad.a(ds A_0)
       at NationalInstruments.Restricted.XYGraphManager.a(ds A_0, Int32 A_1, Int32 A_2, Int32 A_3, Int32 A_4, Int32& A_5, Int32& A_6, Int32& A_7)
       at NationalInstruments.Restricted.XYGraphManager.Layout(ds layoutArgs)
       at NationalInstruments.Restricted.ControlBaseManager.b()
       at NationalInstruments.Restricted.ControlBaseManager.OnLayoutChanged(EventArgs e, Boolean raiseAppearanceChanged)
       at NationalInstruments.Restricted.ControlElement.OnLayoutChanged(Boolean raiseAppearanceChanged)
       at NationalInstruments.Restricted.XYGraphManager.PanXYInternal(Single xFactor, Single yFactor, Action action)
       at NationalInstruments.Restricted.GraphManager.OnInteractiveMouseMove(MouseEventArgs e)
       at NationalInstruments.Restricted.XYGraphManager.OnInteractiveMouseMove(MouseEventArgs e)
       at NationalInstruments.Restricted.GraphManager.c(Object A_0, MouseEventArgs A_1)
       at System.Windows.Forms.MouseEventHandler.Invoke(Object sender, MouseEventArgs e)
       at NationalInstruments.UI.WindowsForms.Internal.m.e(Object A_0, MouseEventArgs A_1)
       at NationalInstruments.UI.WindowsForms.Internal.m.c(MouseEventArgs A_0)
       at NationalInstruments.UI.WindowsForms.Internal.m.c(Object A_0, MouseEventArgs A_1)
       at System.Windows.Forms.Control.OnMouseMove(MouseEventArgs e)
       at NationalInstruments.UI.WindowsForms.ControlBase.OnMouseMove(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseMove(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at Target_Telemetry.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

0 Kudos
Message 9 of 11
(6,205 Views)

Hello Richard,

 

You can trap this in the RangeChanged event of the XAxis.   Here you can check the XAxisEventArgs to determine if the axis range minimum is below some setpoint - say .01, and then reset the range. Resetting the range requires a new range object, something like this - 

 

e.XAxis.Range = new Range(0, e.XAxis.Range.Maximum);

 

Let me know if you have any other questions!

 

NickB

National Instruments 

 

 

0 Kudos
Message 10 of 11
(6,188 Views)