Hi,
I have a ppDBChart on a ppReport (ReportBuilder).
The X Axis of the series represents dates.
The Y Axis a integer values.
I want to give the graph diffrent colours depending on the date range:
ie:
Sept-Oct - Gradient Brown to Green from left to Right
Nov-March - Green
April-May - Gradient from Left to right Green to Brown
June-August - Brown
Where do I set this?
What on-event do I use, as the chart is part of a ppReport that is called as follows:
ppReport1.print;
Any help will be appreciated.
I attach the 'uncoloured' graph below.
Regards
Adrian
Area Series different colours for XAxis values?
Area Series different colours for XAxis values?
- Attachments
-
- dbChart.jpg (231.04 KiB) Viewed 5253 times
Re: Area Series different colours for XAxis values?
The only Events exposed in the object inspector are:
OnDrawCommandClick
OnDrawCommandCreate
OnPrint
How would I get to the Series1AfterAdd event for instance, as I cannot see how to expose it at design time to add code for the event, for the DBChart on the ppReport.
OnDrawCommandClick
OnDrawCommandCreate
OnPrint
How would I get to the Series1AfterAdd event for instance, as I cannot see how to expose it at design time to add code for the event, for the DBChart on the ppReport.
Re: Area Series different colours for XAxis values?
Hello Adrian,
I see you seem to be using Area series with Stairs. I'd recommend you to use Bar series as they have OnGetBarStyle that can help you in this.
However, setting a gradient to a range of values applies the gradient for each bar, and I'm not sure if that's what you expected:
If you would like to have the first value in September in solid brown ... to the last value in October in solid green, you could calculate the color to set to each bar manually. It would be something similar to creating a custom palette.
I see you seem to be using Area series with Stairs. I'd recommend you to use Bar series as they have OnGetBarStyle that can help you in this.
However, setting a gradient to a range of values applies the gradient for each bar, and I'm not sure if that's what you expected:
Code: Select all
procedure Series1GetBarStyle(Sender:TCustomBarSeries; ValueIndex:Integer; var TheBarStyle:TBarStyle);
//...
uses DateUtils, TeCanvas;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
tmpDate: TDateTime;
begin
Chart1.Legend.Visible:=false;
Chart1.Axes.Bottom.LabelsAngle:=90;
Chart1.Axes.Bottom.Increment:=30;
Chart1.Axes.Bottom.DateTimeFormat:='MMM-yyyy';
tmpDate:=StrToDateTime('01/09/2010');
with Chart1.AddSeries(TBarSeries) as TBarSeries do
begin
Marks.Visible:=false;
XValues.DateTime:=true;
Gradient.Visible:=true;
OnGetBarStyle:=Series1GetBarStyle;
for i:=0 to 364 do
begin
AddXY(tmpDate, random*100);
tmpDate:=tmpDate+1;
end;
end;
end;
procedure TForm1.Series1GetBarStyle(Sender:TCustomBarSeries; ValueIndex:Integer; var TheBarStyle:TBarStyle);
begin
case (MonthOfTheYear(Sender.XValue[ValueIndex])) of
9,10:
begin
TheBarStyle:=bsRectGradient;
Sender.Gradient.Direction:=gdLeftRight;
Sender.NormalBarColor:=RGB(128,64,0);
Sender.Gradient.StartColor:=clGreen;
end;
11,12,1,2,3:
begin
TheBarStyle:=bsRectangle;
Sender.Color:=clGreen;
end;
4,5:
begin
TheBarStyle:=bsRectGradient;
Sender.Gradient.Direction:=gdLeftRight;
Sender.NormalBarColor:=clGreen;
Sender.Gradient.StartColor:=RGB(128,64,0);
end;
6,7,8:
begin
TheBarStyle:=bsRectangle;
Sender.Color:=RGB(128,64,0);
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |