I have a simple DBChart attached to a crosstab showing values by calendar month (labelled as 1-12 on the bottom axis). My chart has several series on it (automatically drawn from the data as it is grouped by calendar year.) This all displays correctly. If I smooth all of the series and hide all of the original series by setting visible to False, (so that only the smoothed series show) then my bottom axis re-labelles itself from 0-11. Why is this and how do I stop this from happening?
Simon
Bottom axis resetting
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Bottom axis resetting
Hi Simon,
This is probably because your smoothed series are not set to DateTime values. You should probably do someting like the code below for all your series:
And also set bottom axis DateTimeFormat if necessary:
If problem persists please attach a simple example project we can run "as-is" to reproduce the problem here.
Thanks in advance.
This is probably because your smoothed series are not set to DateTime values. You should probably do someting like the code below for all your series:
Code: Select all
Chart1[0].XValues.DateTime:=True;
Code: Select all
Chart1.Axes.Bottom.DateTimeFormat:='dd/MM/yyyy';
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Bottom axis resetting
Hmm, I don't want the date shown on the bottom axis. I just want the month - I have this integer value in the table and I want to group by year (I have this integer value in the table too) so that I get one series for each year appearing on my chart. Are you saying that I can't smooth a crosstab chart unless I have a dateTime field on the bottom axis?
Simon
Simon
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Bottom axis resetting
Hi Simon,
Sorry, my fault, I got it wrong. In that case the easiest thing you could do would be using the OnGetAxisLabel event manually parsing the labels, for example:
Sorry, my fault, I got it wrong. In that case the easiest thing you could do would be using the OnGetAxisLabel event manually parsing the labels, for example:
Code: Select all
procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
var tmp: Double;
begin
if Sender = Chart1.Axes.Bottom then
begin
tmp:=StrToFloat(LabelText) + 1;
LabelText:=FloatToStr(tmp);
end;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Bottom axis resetting
Thanks Narcis, I can get it to work doing what you suggest, but of course the axis is then wrong for a non-smoothed series! I can get around this but it all seems like a bit of a bodge. Is this behaviour likely to be fixed at sometime?
Simon
Simon
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Bottom axis resetting
Hi Simon,
An alternative could be using TLineSeries.Smoothed property, for example:
Anyway, using a line series with an associated smoothing function doesn't change bottom axis labels either. In the code snippet Series1 is a line series and Series2 is the line series of a smoothing function with Series1 as a datasource. Could you please attach a simple example project we can run "as-is" to reproduce the problem here?
Thanks in advance.
An alternative could be using TLineSeries.Smoothed property, for example:
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var Series1: TLineSeries;
i: Integer;
begin
Series1:=TLineSeries.Create(Self);
Chart1.AddSeries(Series1);
for i:=1 to 12 do
Series1.AddXY(i, random);
Series1.Smoothed:=True;
end;
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:=1 to 12 do
Series1.AddXY(i, random);
Series2.CheckDataSource;
Series1.Visible:=False;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |