Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I fix the major divisions in a waveform graph when the axes range changed?

how can I fix the major divisions in a waveform graph when the axes range changed? for example: y axes range = (-5,5); major division is 1, so the grid line is 10. when y axes range = (-15,5); major division is 2, but the grid line isnot 10. how can I fix the major divisions not change? i want it is always 10. thanks.
0 Kudos
Message 1 of 5
(6,723 Views)

Hello there,

 

There are two solutions for your problem:

 

Solution1: Allow the graph to calculate ticks

 

  1. Set XAxis.AutoSpacing to false.
  2. Handle the XAxis.RangeChanged event and inside the event handler,
  3. Set the XAxis.MajorDivisions.Interval to (XAxis.Range.Interval / 10).

This ensures that there are 10 ticks, hence 10 gridlines.

 

Solution2: Calculate ticks manually!

 

  1. Set GridVisible, TickVisible and LabelVisible to false for XAxis.MajorDivisions
  2. Add as many XAxis.CustomDivisions as you want
  3. Set the visibility of objects as you want for ticks, grids, labels
  4. Handle the XAxis.RangeChanged event and
      1. Set CustomDivisions[0].Value to XAxis.Range.Minimun and CustomDivisions[lenght-1].Value to XAxis.Range.Maximum.
      2. Scale other CustomerDivisions so that you see only 10 (or any number that you please) ticks and grids.

This solutiosn that there are 10 ticks, hence 10 gridlines and you have higher control over the spacing between the gridlines.

 

Hope this helps!

 

Vijet Patankar

National Instruments

0 Kudos
Message 2 of 5
(6,722 Views)

Will this solution also fix the labels number resolution? Or is there a different way to change the WPF graph's label so it shows more resolution? eg: 99.579

..GraphAxis.png

0 Kudos
Message 3 of 5
(6,670 Views)

Hi gs70,

 

You can specify the LabelPresenter property on the RangeLabeledDivisions instance in your MajorDivisions property of the axis. You can use a GeneralValueFormatter and specify the format string you want (number of digits, etc.).

Jeff | LabVIEW Software Engineer
0 Kudos
Message 4 of 5
(6,666 Views)

Thanks that did the trick...

 

I posted the XAML code for reference..

 

 

<ni:Graph.Axes>
                <ni:AxisDouble x:Name="VerticalAxis" Orientation="Vertical" >                   
                    <ni:AxisDouble.MajorDivisions>
                        <ni:RangeLabeledDivisions>
                            <ni:RangeLabeledDivisions.LabelPresenter>
                                <ni:GeneralValueFormatter Format="0.000" />
                            </ni:RangeLabeledDivisions.LabelPresenter>
                        </ni:RangeLabeledDivisions>
                    </ni:AxisDouble.MajorDivisions>
                </ni:AxisDouble>
            </ni:Graph.Axes>

 

0 Kudos
Message 5 of 5
(6,659 Views)