Custom Chart Shape

The the attached demo, two TChartShape series are used to create the green area below. But I need a shape that will fill in the dotted area (dotted lines added with an editor) with green.

Can that be done?

I’ve attached a simple demo of the app.

Thank you,

Ed Dressel
Shape Series.rar (1.58 KB)

Hi Ed,

I can think on two alternatives.

  1. Use a third TChartShape, with chasInvertTriangle Style. The problem here is that you’ll be drawing a shape bigger than the area you highlighted. In this case it works, but won’t work as you wish in a different situation.
  lSrs := TChartShape.Create(self);
  lSrs.ParentChart := Chart1;
  lSrs.Style := chasInvertTriangle;
  lSrs.SeriesColor := clGreen;
  lSrs.Pen.Visible := false;
  lSrs.X0 := 23;
  lSrs.X1 := 37;
  lSrs.Y0 := 15;
  lSrs.Y1 := 25;
  1. Manually draw your shape at OnAfterDraw event. Ie:
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var points: array of TPoint;
begin
  setLength(points, 3);
  with Chart1.Axes do
  begin
    points[0]:=Point(Bottom.CalcPosValue(23), Left.CalcPosValue(25));
    points[1]:=Point(Bottom.CalcPosValue(30), Left.CalcPosValue(25));
    points[2]:=Point(Bottom.CalcPosValue(30), Left.CalcPosValue(15));
  end;

  with Chart1.Canvas do
  begin
    Pen.Style:=psClear;
    Brush.Style:=bsSolid;
    Brush.Color:=clGreen;
    Polygon(points);
  end;
end;