Custom Chart Shape

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Custom Chart Shape

Post by TestAlways » Mon Apr 21, 2014 6:05 pm

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.

Image

Can that be done?

I've attached a simple demo of the app.

Thank you,

Ed Dressel
Attachments
Shape Series.rar
(1.58 KiB) Downloaded 540 times

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Custom Chart Shape

Post by Yeray » Tue Apr 22, 2014 9:48 am

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.

Code: Select all

  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;
2. Manually draw your shape at OnAfterDraw event. Ie:

Code: Select all

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply