With the Chart component, as with WindowsForms in general, I worked very little, but the search for information on your subject led to one of the solutions.
Pick up all the points that define your shape in the GraphicsPath , and then display them using Graphics.FillPath
Example:
Series some = new Series("Some"); some.ChartType = SeriesChartType.Line; some.Color = Color.Red; some.BorderWidth = 3; //коллекция точек some.Points.AddXY(10, 10); some.Points.AddXY(40, 10); some.Points.AddXY(40, 60); some.Points.AddXY(40, 70); some.Points.AddXY(10, 60); some.Points.AddXY(10, 10); chart.Series.Add(some);
...
private void Chart_Paint(object sender, PaintEventArgs e) { var graphics = e.Graphics; GraphicsPath gp = new GraphicsPath(FillMode.Winding); Axis ax = chart.ChartAreas[0].AxisX; Axis ay = chart.ChartAreas[0].AxisY; PointF[] points = chart .Series["Some"] .Points .Select(x => new PointF { X = (float)ax.ValueToPixelPosition(x.XValue), Y = (float)ay.ValueToPixelPosition(x.YValues[0]) }) .ToArray(); gp.AddLines(points); using (SolidBrush brush = new SolidBrush(Color.Green)) graphics.FillPath(brush, gp); gp.Dispose(); }
Result:
