ColorEachPoint and Gradient?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jim Green
Newbie
Newbie
Posts: 43
Joined: Thu Aug 03, 2006 12:00 am

ColorEachPoint and Gradient?

Post by Jim Green » Mon Aug 20, 2012 8:33 pm

Hello, is it possible to use BarSeries.ColorEachPoint and have a gradient?

Thanks.

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

Re: ColorEachPoint and Gradient?

Post by Yeray » Tue Aug 21, 2012 12:33 pm

Hi,

Yes, you can. Ie:

Code: Select all

  with Chart1.AddSeries(TBarSeries) as TBarSeries do
  begin
    FillSampleValues;
    ColorEachPoint:=true;
    BarStyle:=bsRectGradient;
  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

Jim Green
Newbie
Newbie
Posts: 43
Joined: Thu Aug 03, 2006 12:00 am

Re: ColorEachPoint and Gradient?

Post by Jim Green » Tue Aug 21, 2012 2:34 pm

Yeray, I should have mentioned that I'm specifying the colors - positive values in green and negative in red, but a gradient version of each color. So I have:

Code: Select all

      if series.ColorEachPoint then
        if y < y0 then
          color := clRed
        else
          color := clGreen
      else
        color := clDefault;
      series.AddXY(x, y, '', color);
Where would you supply the 2nd color for the gradient?

Thanks,
Jim

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

Re: ColorEachPoint and Gradient?

Post by Yeray » Wed Aug 22, 2012 7:36 am

Hi Jim,
Jim Green wrote:Where would you supply the 2nd color for the gradient?
You should set the series' Gradient.StartColor property.
However this is a color for the whole series. If you want to set a different StartColor for each point, you could use the OnGetPointerStyle/OnGetBarStyle event to change that color each time a point/bar is going to be drawn.

Code: Select all

Procedure TForm1.GetBarStyle(Sender:TCustomBarSeries; ValueIndex:Integer; var TheBarStyle:TBarStyle);
begin
  Sender.Gradient.StartColor:=ApplyBright(Sender.ValueColor[ValueIndex], 128);
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