Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Rounding minimum and maximum ranges

Solved!
Go to solution

Hello all, it would be great to know how also set a rounding precision for the mins and maxs of each axis. As I zoom in they become this odd exponential abbreviation and it would be nice if they always rounded to say 2 decimal places instead of #.##E0. I notice the center tick marks are always to 2 decimal point precision, can that be applied to the min and max for each axis?

 

Thanks,

0 Kudos
Message 1 of 5
(2,678 Views)

If you simply want to avoid seeing the exactly label values, you can change the Mode on the axis to only generate the interior divisions:

 

<ni:AxisDouble.MajorDivisions>
    <ni:RangeLabeledDivisions Mode="AutoWithoutExtremes" />
</ni:AxisDouble.MajorDivisions>

 

 

If you want to keep the extreme divisions, but use a truncated label, then you can change the format used to display the division labels:

<ni:AxisDouble.MajorDivisions>
    <ni:RangeLabeledDivisions>
        <ni:GeneralValueFormatter ShortFormat="0.##" />
    </ni:RangeLabeledDivisions>
</ni:AxisDouble.MajorDivisions>

 

If you want to restrict the actual underlying extremes to rounded numbers, then you can handle the RangeChanged event to coerce the final range value.

~ Paul H
0 Kudos
Message 2 of 5
(2,585 Views)

Thanks for the response, I tried the first method but I get a xaml parser error:

 

An exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll but was not handled in user code

Additional information: 'Failed to create a 'Mode' from the text 'AutoWithoutExtremes'.' Line number '61' and line position '22'.

 

Also, I tried the second method by embedding the xaml but it returns with a build error:

 

Severity Code Description Project File Line Suppression State
Error Cannot add content to object of type 'NationalInstruments.Controls.RangeLabeledDivisions'. Line 62 Position 30. 

 

Thanks,

0 Kudos
Message 3 of 5
(2,570 Views)
Solution
Accepted by topic author gabe0

It looks like the AutoWithoutExtremes mode, and the content property attribute on RangeLabeledDivisions, were added in Measurement Studio 2019.

 

For the second approach, you can just add the explicit property name that the formatter should be assigned to:

 

<ni:AxisDouble.MajorDivisions>
    <ni:RangeLabeledDivisions>
        <ni:RangeLabeledDivisions.LabelPresenter>
            <ni:GeneralValueFormatter ShortFormat="0.##" />
        </ni:RangeLabeledDivisions.LabelPresenter>
    </ni:RangeLabeledDivisions>
</ni:AxisDouble.MajorDivisions>

 

 

For the first approach, you could create a custom RangeDivisionsMode to remove the extremes from the call to get divisions: basically the reverse of the answer to this question.

~ Paul H
0 Kudos
Message 4 of 5
(2,549 Views)

Yes we have an older version it looks. The second solution worked for us thanks!

0 Kudos
Message 5 of 5
(2,543 Views)