Need to fill line graph area with background color.

Apr 23, 2013 at 7:28 AM
Hi All,

i have created a chart using dynamic data display dll. I need to fill the graph area with background color. In the code below

               new Pen(Brushes.Green, 1),
               new CirclePointMarker { Size = 0.0, Fill = Brushes.Black },
               new PenDescription("Volts"));

i am not seeing the option to set background color for plotted graph reagion.
Any suggestion where i am missing.
May 20, 2013 at 3:48 AM

As per my knowledge, There is no direct way to do area graphs(Area region) using DDD.
DDD has only VericalRange and HorizontalRange, these are to add horizontal and vertical rectangle regions.

The line graph has(the return type of plotter.AddLineGraph(......)) point data collection.
Since this is WPF chart control, you can always add polygon with the point data collection.
you can do some thing like this
                System.Windows.Media.PointCollection polygonPoints = new System.Windows.Media.PointCollection();
                System.Windows.Media.SolidColorBrush yellowBrush = new System.Windows.Media.SolidColorBrush();
                yellowBrush.Color = System.Windows.Media.Colors.Yellow;
                System.Windows.Media.SolidColorBrush blackBrush = new System.Windows.Media.SolidColorBrush();
                blackBrush.Color = System.Windows.Media.Colors.Black;

                System.Windows.Shapes.Polygon polygon = new System.Windows.Shapes.Polygon();
                polygon.Stroke = blackBrush;
                polygon.Fill = yellowBrush;
                polygon.StrokeThickness = 3;
                var points = lineGraph.DataSource.GetPoints().ViewportToScreen(plotter1.Viewport.Transform).ToList();
                foreach (var pnt in points)
                    polygonPoints.Add(new Point(pnt.X, pnt.Y));

                //Here you have to add two more points to complete the loop
                polygonPoints.Add(new Point(0, hightOfChart));
                polygonPoints.Add(new Point(widthOfChart, hightOfChart));
               polygon.Points = polygonPoints;

                //yourPrentGridOrPlot is parent grid where you plan to add ploygon
I didn't try this code, But this code should work.