Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Scattergraph time axis major tick labels are not even intervals

I need to make a scattergraph where the vertical y-axis is based on time and the major intervals labels need to be even time intervals in the form hh:mm.   I can create the time axis and configure the minimum and maximum time but I cannot format the major tick interval so they display even time intervals like 12:30, 1:00, 1:30... , instead the major tick intervals are determined in some other way that I have no control over.

ex.
Chart1.Plots(0).YAxis.MajorDivisions.LabelFormat = New NationalInstruments.UI.FormatString(NationalInstruments.UI.FormatStringMode.DateTime, "hh:mm")
        Chart1.Plots(0).YAxis.Mode = AxisMode.Fixed
        Chart1.Plots(0).YAxis.Range = New Range("12:00", TimeSpan.FromMinutes(120))
        Chart1.Plots(0).YAxis.AutoSpacing = False
        Chart1.Plots(0).YAxis.MajorDivisions.Interval = 30 'this has no affect
        Chart1.Plots(0).YAxis.Inverted = True
0 Kudos
Message 1 of 3
(3,706 Views)
Chart1.Plots(0).YAxis.MajorDivisions.Interval = 30 'this has no affect
 
The interval is in seconds - having a major interval every 30 seconds for a 120 minute range would be pretty busy... perhaps NI set a minimum interval based on the range. Try setting the Interval to 1200 or something like that. Everything else looks ok...
0 Kudos
Message 2 of 3
(3,701 Views)
As Shea24 pointed out that having an interval of 30 second would make the labels of the major divisions too close together. Even though you have explicitly set AutoSpacing to false, since the specified interval of 30 seconds would make the labels congested, the graph reverts to the same behavior as when AutoSpacing is true.
 
Regarding the code, you will need to convert the interval that you want (30 seconds, in this case) to a TimeSpan and convert it back to a double type. This can be done using the DataConverter class in the NationalInstruments namespace. The following code sets the major divisions to show labels at an interval of 30 minutes:
        Chart1.Plots(0).YAxis.MajorDivisions.LabelFormat = New NationalInstruments.UI.FormatString(NationalInstruments.UI.FormatStringMode.DateTime, "hh:mm")
        Chart1.Plots(0).YAxis.Mode = AxisMode.Fixed
        Chart1.Plots(0).YAxis.Range = New Range("12:00", TimeSpan.FromMinutes(120))
        Chart1.Plots(0).YAxis.AutoSpacing = False
        Chart1.Plots(0).YAxis.MajorDivisions.Interval = DataConverter.Convert(TimeSpan.FromMinutes(30), GetType(Double)) 'this has no affect
        Chart1.Plots(0).YAxis.Inverted = True
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 3 of 3
(3,691 Views)