Page 1 of 1

How to make a gradient fill

Posted: Tue Jul 19, 2016 4:42 am
by 17576646
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.

Re: How to make a gradient fill

Posted: Tue Jul 19, 2016 9:42 am
by yeray
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);