Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

MultiPlotCursor Formatting

Solved!
Go to solution

Hi,

 

I'm trying to format a MultiPlotCursor for a graph with multiple plots on an AxisDouble and an AxisPrecisionDateTime. Here is a basic version of my xaml:

 

        <ni:Graph>
            <ni:Graph.Axes>
                <ni:AxisDouble x:Name="_yAxis" Orientation="Vertical" MinorDivisions="{x:Null}"/>
                <ni:AxisPrecisionDateTime x:Name="_xAxis" Orientation="Horizontal" Label="Time"/>
            </ni:Graph.Axes>
            <ni:Graph.Children>
                <ni:MultiPlotCursor Name="_mpCursor" Visibility="Hidden" TargetBrush="Red">
                    <ni:MultiPlotCursor.ValuePresenter>
                        <ni:ValueFormatterGroup>
                            <ni:ValueFormatterGroup.DefaultFormatter>
                                <ni:GeneralValueFormatter Format="0.00"/>
                            </ni:ValueFormatterGroup.DefaultFormatter>
                        </ni:ValueFormatterGroup>
                    </ni:MultiPlotCursor.ValuePresenter>
                </ni:MultiPlotCursor>
            </ni:Graph.Children>
        </ni:Graph>

 The GeneralValueFormatter seems to be trying to apply the 0.00 format to both x and y points, however this isn't a valid format for PrecisionDateTime objects.

What I want is something like: 

 

Format="yy-MM-dd HH:mm:ss, 0.00"

 When I have this as my format however, it tries to apply this format to both x and y values, which ends up looking something like: "13-05-14 14:32:20, 0.00, yy-MM-dd HH:mm:ss, 60.41".

 

How can I set the format of this cursor to properly show the PrecisionDateTime and double values?

 

Thanks for your help.

0 Kudos
Message 1 of 5
(5,916 Views)

Hey jsacks, 

 

Can you post a picture of what this looks like in when it is all rendered? What about if you define each of the cursors independently? That way you can define what values you want them to display. 

 

Regards,

 

-KP

Kurt P
Automated Test Software R&D
0 Kudos
Message 2 of 5
(5,904 Views)

Here is a screenshot of what I'm seeing when I set the format as:

 

<ni:GeneralValueFormatter Format="yy-MM-dd HH:mm:ss 0.00"/>

 

cursor.jpg

 

I'm not sure what you mean by "define each of the cursors independently". If I had two cursors, wouldn't I have the same problem with each one? Plus the user would have to drag around two cursors to get the values of a single point. Ultimately, I'd like to have a single cursor on each point displaying the date and time in the format that I'm using. Thanks for your help.

0 Kudos
Message 3 of 5
(5,897 Views)
Solution
Accepted by jsacks

A ValueFormatterGroup represents a collection of formatters for each value displayed by the cursor. Setting only DefaultFormatter will apply that single formatter to each value.


You can use this inline property syntax to apply a different formatter for each value, separating the formatters by a semicolon:


    <ni:MultiPlotCursor ValuePresenter="Group: yy-MM-dd HH:mm:ss; 0.00" />


Or, using the full element syntax:


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

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

Thanks, Paul. That's exactly what I was looking for.

0 Kudos
Message 5 of 5
(5,891 Views)