Programatically set Bar Color, Pattern

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Doogie
Newbie
Newbie
Posts: 12
Joined: Mon Oct 22, 2007 12:00 am
Contact:

Programatically set Bar Color, Pattern

Post by Doogie » Sun Nov 29, 2009 12:07 pm

I have a Horizontal bar chart 3D
It has 36 series.

Each three series must have the same color.
I achieve this at runtime using the following code:

Code: Select all

     i := 0;
    While i < 34 do
    begin
    DBChartBLUP.Series[i+1].SeriesColor := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+2].SeriesColor := DBChartBLUP.Series[i].SeriesColor;
    i := i + 3;
    end;
Now I want the second of the three series with same color to have a forward diagonal stripe on it.
The Third of the three series with the same color a back diagonal stripe on it.

I try the following:

Code: Select all

i := 0;
    While i < 34 do
    begin
    DBChartBLUP.Series[i+1].SeriesColor := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+1].Brush.Style := bsFDiagonal;
    DBChartBLUP.Series[i+2].SeriesColor := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+2].Brush.Style := bsBDiagonal;
    i := i + 3;
    end;

This gives you three bars with the 2nd and 3rd with a pattern, but without a fill color.

The first bar in the attachment is blue, and by setting the second bars properties in the IDE to Format Rectangle, Color Blue -> then Patttern, then select diagonal, and change both the color and background to blue aswell, I get the desired effect.
But the next two, I don't set in the IDE, I want to set this programatically, but IF I set background color, no effect.
How do I get this right in code?
See attachment
Attachments
barcolor.jpg
barcolor.jpg (35.94 KiB) Viewed 4089 times

Doogie
Newbie
Newbie
Posts: 12
Joined: Mon Oct 22, 2007 12:00 am
Contact:

Re: Programatically set Bar Color, Pattern

Post by Doogie » Sun Nov 29, 2009 1:18 pm

Ok.. a bit wierd, but you have to set both Brush.Color and Brush.BackColor

Code: Select all

    i := 0;
    While i < 34 do
    begin
    DBChartBLUP.Series[i+1].SeriesColor := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+1].Brush.BackColor := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+1].Brush.Color := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+1].Brush.Style := bsFDiagonal;
    DBChartBLUP.Series[i+2].SeriesColor := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+2].Brush.BackColor := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+2].Brush.Color := DBChartBLUP.Series[i].SeriesColor;
    DBChartBLUP.Series[i+2].Brush.Style := bsBDiagonal;
    i := i + 3;
    end;
See attachment for final result.
Attachments
horbarfixed.jpg
horbarfixed.jpg (57.76 KiB) Viewed 4076 times

Post Reply