From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure the Range property of IntensityGraph in WPF?

I am trying to configure the Range property of ColorScale in XAML for the IntensityGraph.

Is there any way I can do that? I am not seeing any Range property for ColorScale. Below is the sample XAML code which i have written. I am looking for a property where I can set the Range="0,65355" similar to what we have for the Intensity Graph  <ni:AxisInt32 Range="0,2047" Label="Horizontal Axis" Orientation="Vertical">

 

<ni:IntensityGraph.ColorScale>
<ni:ColorScale >
<ni:ColorScaleMarker Color="#FFFF8000" Value="255"/>
<ni:ColorScaleMarker Color="#FFFF8000" Value="128"/>
<ni:ColorScaleMarker Color="#FFFF8000" Value="0"/>
</ni:ColorScale>
</ni:IntensityGraph.ColorScale>

0 Kudos
Message 1 of 17
(3,458 Views)

The range of the ColorScale is determined by the marker values. In your example XAML, the color scale has a range of 0 to 255. To change the range maximum to 65355, you would need to either change the value of one of the markers, or add a new marker with that value.

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

Thank you Paul.

Yes, just did play around and found that I have to change the Value of the ColorScaleMarker to 65355.

<ni:ColorScaleMarker Color="#FFFF8000" Value="65535"/>
<ni:ColorScaleMarker Color="Black" Value="0"/>

 

0 Kudos
Message 3 of 17
(3,436 Views)

Does the IntensityGraph in WPF has a default Plot? We have a IntensityPlot Collection Editor in Winforms, but I am trying to find a similar way to add a plot to the Intensity Graph.

 

0 Kudos
Message 4 of 17
(3,399 Views)

Below is my XAML code for IntensityGraph

 

<ni:IntensityGraph x:Name="PatternIntensityGraph" HorizontalAlignment="Left" Height="600" VerticalAlignment="Center" Width="1000"
 PlotAreaCursor="Cross" Cursor="Cross"
PlotAreaMouseRightButtonUp="IntensityGraph_PlotAreaMouseRightButtonUp" Interactions="Pan, Zoom, ZoomIn, ZoomHorizontal, ZoomVertical, ZoomOut, PanVertical, PanHorizontal" >

<ni:IntensityGraph.Children>
        <ni:Cursor x:Name="intensityCursor2" TargetShape="Plus" VerticalCursor="Cross" Cursor="Cross"                              PositionChanged="intensityCursor2_PositionChanged" />
</ni:IntensityGraph.Children>
<ni:IntensityGraph.HorizontalAxis>
<ni:AxisInt32 Range="0,2047" LabelVisibility="Collapsed" Label="Horizontal Axis" Orientation="Horizontal" Adjuster="FitExactly">
<ni:AxisInt32.MajorGridLines>
<ni:GridLines Visibility="Collapsed"/>
</ni:AxisInt32.MajorGridLines>
<ni:AxisInt32.MinorGridLines>
<ni:GridLines Visibility="Collapsed"/>
</ni:AxisInt32.MinorGridLines>
</ni:AxisInt32>
</ni:IntensityGraph.HorizontalAxis>
<ni:IntensityGraph.VerticalAxis>
<ni:AxisInt32 Range="0,2047" LabelVisibility="Collapsed" Label="Horizontal Axis" Orientation="Vertical" Adjuster="FitExactly" LabelOrientation="Natural">
<ni:AxisInt32.MajorGridLines>
<ni:GridLines Visibility="Collapsed"/>
</ni:AxisInt32.MajorGridLines>
<ni:AxisInt32.MinorGridLines>
<ni:GridLines Visibility="Collapsed"/>
</ni:AxisInt32.MinorGridLines>
</ni:AxisInt32>
</ni:IntensityGraph.VerticalAxis>
<ni:IntensityGraph.PlotAreaBackground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FFFF8000" Offset="1"/>
</LinearGradientBrush>
</ni:IntensityGraph.PlotAreaBackground>
<ni:IntensityGraph.ColorScale>
<ni:ColorScale x:Name="IntensityGraph1_ColorScale1" HighColor="#FFFF8000" BaselineStrokeThickness="1" Location="Far">
<ni:ColorScale.BaselineStroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FFFF8000" Offset="1"/>
</LinearGradientBrush>
</ni:ColorScale.BaselineStroke>
<ni:ColorScaleMarker Color="#FFFF8000" Value="65535"/>
<ni:ColorScaleMarker Color="Black" Value="0"/>
</ni:ColorScale>
</ni:IntensityGraph.ColorScale>
</ni:IntensityGraph>

 

Not sure if this xaml has a Plot or do i need to add any explicitly in XAML

0 Kudos
Message 5 of 17
(3,398 Views)

Generally speaking, all of the WPF controls are designed to function with minimal configuration: given data, they will display it in a reasonable manner by default. For graph controls, this means default plots will be auto-generated if more data is passed to the graph than there are plots.

 

For the specific case of the IntensityGraph, the WPF control fulfills the basic use case of a single plot of intensity data that covers the entire plot area. Since only one plot is allowed, the graph does not include the option to add more plots beyond the default (instead, all the configuration is exposed through properties on the graph, like ColorScale).

 

(To achieve more advanced scenarios with multiple intensity plots or mixing different types of plots, you can use an IntensityPlotRenderer with the Graph control.)

~ Paul H
0 Kudos
Message 6 of 17
(3,396 Views)

Thanks Paul.

 

all my intention was to invoke the InverserMapDataPoint() on the IntensityPlot. which to some extent i did through code behind as given below.

 

PlotObserverCollection allplots = PatternIntensityGraph.AllPlots;
IntensityPlot intensityPlot =(IntensityPlot) allplots.FirstOrDefault();
intensityPlot.InverseMapDataPoint();

 

But the real problem is with the parameters of InverseMapDataPoint which accepts the following parameters

(Rectangle bounds, PointF point, out double xData, out double yData)

 

I don't see a property called PlotAreaBounds property in WPF which I can see in Winforms as given below

 

intensityPlot1.InverseMapDataPoint(intensityGraph1.PlotAreaBounds, mouseClickPoint,
out xValue, out yValue);

 

How do i get the Rectangle bounds of my IntensityGraph in WPF?

0 Kudos
Message 7 of 17
(3,393 Views)

Also, what is the equivalent Paint event of IntensityGraph in WPF? I have the below in Winforms

 

this.intensityGraph1.Paint += new System.Windows.Forms.PaintEventHandler(this.intensityGraph1_Paint);

 

 

0 Kudos
Message 8 of 17
(3,390 Views)

I believe the most direct equivalent of InverserMapDataPoint is the ScreenToData method on the graph. (The WPF graphs already know their plot area size, so that does not have to be specified separately.)

 

Depending on what you are trying to accomplish, the answer to the wpf location question may also be useful.


WPF uses a retained graphics model, so there is no equivalent to the Windows Forms Paint event. The name "intensityGraph1_Paint" does not indicate the purpose of the event handler, so we would need more information to suggest an alternative.

~ Paul H
0 Kudos
Message 9 of 17
(3,384 Views)

Thank you Paul.

intensityGraph1 is an instance of my IntensityGraph in Winforms. Since I was able to add a event handler for Paint event in Winforms. I am not able to find a similar event handler for IntensityGraph in WPF.

I wanted to draw a rectangle by declaring a pen in the Paint event handler in WPF IntensityGraph

0 Kudos
Message 10 of 17
(3,379 Views)