Page 1 of 1

Programatically set Bar Color, Pattern

Posted: Sun Nov 29, 2009 12:07 pm
by 10547084
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

Re: Programatically set Bar Color, Pattern

Posted: Sun Nov 29, 2009 1:18 pm
by 10547084
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.