How to make a gradient fill

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
riskassessor
Newbie
Newbie
Posts: 29
Joined: Tue Oct 13, 2015 12:00 am

How to make a gradient fill

Post by riskassessor » Tue Jul 19, 2016 4:42 am

I'm drawing rectangles on a chart in the OnBeforeDrawSeries event. To draw a rectangle with a solid fill, I define a brush with (for example)

Chart1.Canvas.Brush.Color:=clRed;

and then draw a rectangle in the OnBeforeDrawSeries event with (for example)

Chart1.Canvas.Rectangle(X0,Y0,X1,Y1).

If I want a gradient fill in the rectangle, say clRed at the top right and clYellow at the bottom left, how would I achieve that?

I'm using the latest TeeChart Pro for VCL. Thank you.

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

Re: How to make a gradient fill

Post by Yeray » Tue Jul 19, 2016 9:42 am

Hello,

You could use gradients as follows:

Code: Select all

  Chart1.Canvas.Gradient.Visible:=true;
  Chart1.Canvas.Gradient.StartColor:=clYellow;
  Chart1.Canvas.Gradient.EndColor:=clRed;
  Chart1.Canvas.Gradient.Direction:=gdDiagonalUp;

  Chart1.Canvas.Rectangle(X0,Y0,X1,Y1);
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