ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

MultiPlotCursor value formatting in C# code

How to change MultiPlotCursor value format in C# code?

thanks

Theo

0 Kudos
Message 1 of 3
(2,730 Views)

The display of the multi-plot cursor's Values are controlled by the ValuePresenter property. Generally you would use a ValueFormatterGroup, which supports specifying a different formatter for each dimension (i.e. the X and Y data for each value). If the ValueFormatters collection is empty or missing a value, the DefaultFormatter, will be used in its place.

 

Here is the answer from another question that wanted to display one dimension as time and another as numeric:

<ni:MultiPlotCursor.ValuePresenter> 
    <ni:ValueFormatterGroup DefaultFormatter="0.00" Separator=" — "> 
        <ni:GeneralValueFormatter Format="yy-MM-dd HH:mm:ss" /> 
    </ni:ValueFormatterGroup> 
</ni:MultiPlotCursor.ValuePresenter>

The equivalent in code:

cursor.ValuePresenter = new ValueFormatterGroup( " — ", new GeneralValueFormatter( "0.00" ) ) {
    ValueFormatters = { new GeneralValueFormatter( "yy-MM-dd HH:mm:ss" ) }
};

 

~ Paul H
0 Kudos
Message 2 of 3
(2,711 Views)

It worked.

Thank you Paul !

0 Kudos
Message 3 of 3
(2,702 Views)