Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF graphs: area fill to another plot

In WF graphs there was option to make plot fill area from itself to another plot like this:

 

_newPlot.BasePlot = _plot;
_newPlot.FillBase = XYPlotFillBase.Plot;
_newPlot.FillMode = PlotFillMode.FillAndLines;
_newPlot.FillToBaseColor = Color.FromArgb(50, Color.Red);
_newPlot.LineToBaseColor = Color.FromArgb(50, Color.Wheat);
_newPlot.LineToBaseStyle = LineStyle.Dot;

 

Is it possible in WPF graphs? There is AreaPlotRenderer but it seems to be able to fill only to base or infinity, not another plot.

0 Kudos
Message 1 of 3
(4,932 Views)

You are correct, there is not a simple way to do that with the WPF Graph the way there was with Window Forms.

 

The WPF Graph is fairly extensible, so it usually possible to do what you want given enough time and energy. In this case, you can likely create the effect you are looking for by creating a custom renderer (like AreaRenderer, deriving from PlotRenderer but rendering differently so that you can get the area fill you want) or by deriving from the FillBaseline class and implementing its abstract methods.

0 Kudos
Message 2 of 3
(4,922 Views)

Note that it is possible to provide the area renderer with data corresponding to that of multiple plots, though it may not be practical for your situation:


    var plotA = new[] { 0, 3, 2, 4 };
    var plotB = new[] { 5, 4, 7, 6 };

    var areaPlot = new Point3D[plotA.Length];
    for( int i = 0; i < areaPlot.Length; ++i )
        areaPlot[i] = new Point3D( i, plotA[i], plotB[i] );

    graph.Data[0] = areaPlot;
    graph.Data[1] = plotA;
    graph.Data[2] = plotB;


If that approach does not work, then the suggested custom PlotRenderer or FillBaseline implementation would be the best approach.

~ Paul H
0 Kudos
Message 3 of 3
(4,878 Views)