Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

different colors for items in MultiPlot Cursor

Solved!
Go to solution

Hi Folks.

 

I've got a chart with up to 10 traces. I'm using a MultiPlotCursor to show the values along the trace. Is there a way to show the cursor values of each trace in different colors? I assumed that the values would be shown in the color assigned to the LinePlotRenderer, but that appears to not be the case. And, is there a way to use different value formatting for the X and Y axes?

 

I've tried this, but it doesn't seem to be working. That is, the chart and cursor are working, just not the coloring and data formatting.

 

<ni:Graph.Children>
   <ni:MultiPlotCursor Name="plotCursor" Label="Multi-Plot Cursor"> 
      <ni:MultiPlotCursor.ValuePresenter>
         <ni:ValueFormatterGroup FontSize="14" Background="#99FFFFFF" >
            <ni:GeneralValueFormatter Foreground="Green" Format="0.0" />
            <ni:GeneralValueFormatter Foreground="Magenta" Format="0.00" />
            <ni:GeneralValueFormatter Foreground="Cyan" Format="0.000" />
         </ni:ValueFormatterGroup>
      </ni:MultiPlotCursor.ValuePresenter>
   </ni:MultiPlotCursor>
</ni:Graph.Children>

 

I can make adjustments in the code-behind too, if there is a better solution that way.

 

 

Thanks.

Don

0 Kudos
Message 1 of 3
(1,066 Views)
Solution
Accepted by topic author dontt

The formatters in the group are for each dimension of data (e.g. so you could set a different format if you were showing time values on one axis and numeric values on another). The same formatters are used for every plot value.

 

Unfortunately, the formatter is only passed the axis for a given data value and not the associated plot, so some manual searching is required. Attached is a custom value presenter that applies the plot renderer Stroke to the Foreground of each cursor value visual:

<ni:Graph.Children>
    <ni:MultiPlotCursor>
        <ni:MultiPlotCursor.ValuePresenter>
            <local:CustomGroupFormatter FontSize="14" Background="#99FFFFFF" />
        </ni:MultiPlotCursor.ValuePresenter>
    </ni:MultiPlotCursor>
</ni:Graph.Children>

 

(Note that internally the values are still presented with a ValueFormatterGroup. My example code uses a default value, but you can customize it or expose it as a configurable property to suit your needs.)

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

Thanks Paul! That's very cool.

0 Kudos
Message 3 of 3
(1,027 Views)