05-14-2013 01:33 PM
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.
Solved! Go to Solution.
05-15-2013 08:44 AM
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
05-15-2013 10:47 AM
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"/>
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.
05-15-2013 10:51 AM
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>
05-15-2013 10:54 AM
Thanks, Paul. That's exactly what I was looking for.