Chart.Draw with LabelStyle talText - BottomAxis missing
Chart.Draw with LabelStyle talText - BottomAxis missing
Hi,
I have recently updated to TeeChart 2022.36 with Delphi 10.4.
Now that I have updated TChart I find that all my "Chart.Draw" calls now have a missing BottomAxis.
This is affecting several different applications, which I have been maintaining for years, through multiple previous upgrades of TeeChart.
This turns out to be because I am using "BottomAxis.LabelStyle := talText;" and GetAxisLabel to populate the labels.
Even with simple, short, test code I cannot get the BottomAxis to display anything at all when using Chart.Draw with talText.
Please find a sample attached. In this example I can step through the GetAxisLabel code and see a value being assigned to LabelText, but the bottom axis is still entirely missing.
Thanks,
Jamie
I have recently updated to TeeChart 2022.36 with Delphi 10.4.
Now that I have updated TChart I find that all my "Chart.Draw" calls now have a missing BottomAxis.
This is affecting several different applications, which I have been maintaining for years, through multiple previous upgrades of TeeChart.
This turns out to be because I am using "BottomAxis.LabelStyle := talText;" and GetAxisLabel to populate the labels.
Even with simple, short, test code I cannot get the BottomAxis to display anything at all when using Chart.Draw with talText.
Please find a sample attached. In this example I can step through the GetAxisLabel code and see a value being assigned to LabelText, but the bottom axis is still entirely missing.
Thanks,
Jamie
- Attachments
-
- Project2.zip
- (1.48 KiB) Downloaded 900 times
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
I have tried everything I can think of to get the axis to draw, so far to no avail.
I have found a sort-of-workaround using "Chart.BottomAxis.Items.Add", which does display. But I am using GetAxisLabel to dynamically vary the number of labels displayed on a whole DrawGrid full of charts, as the form resizes. So it would be far from ideal to have to repopulate the bottom axis of every chart on the fly!
I have found a sort-of-workaround using "Chart.BottomAxis.Items.Add", which does display. But I am using GetAxisLabel to dynamically vary the number of labels displayed on a whole DrawGrid full of charts, as the form resizes. So it would be far from ideal to have to repopulate the bottom axis of every chart on the fly!
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hello,
LabelStyle talText forces the axes to show the labels from the first series assigned to the axis. However, in that example you have no labels in your series. That's why no labels are drawn.
Assigning labels to the series, you don't even need to use
LabelStyle talText forces the axes to show the labels from the first series assigned to the axis. However, in that example you have no labels in your series. That's why no labels are drawn.
Assigning labels to the series, you don't even need to use
OnGetAxisLabel
event:
Code: Select all
procedure TForm2.Button2Click(Sender: TObject);
var
Rect: TRect;
i: Integer;
begin
Chart := TChart.Create(Self);
Chart.View3D := False;
Chart.BottomAxis.LabelStyle := talText;
//Chart.OnGetAxisLabel := ChartGetAxisLabel;
Chart.AddSeries(TBarSeries.Create(Chart));
Chart.SeriesList[0].FillSampleValues(48);
for i:=0 to Chart[0].Count-1 do
Chart[0].Labels[i]:='Idx '+IntToStr(i);
Rect := Image1.ClientRect;
Chart.Draw(Image1.Canvas, Rect);
Chart.Free;
Image1.Refresh;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hi Yeray,
Thanks, but as I said in my second post this doesn't help me.
The change to TeeChart breaks existing code, which needs to dynamically adjust the bottom axis for sometimes over 100 charts on the screen at any time. OnGetAxisLabel is fired as the chart gets redrawn, whereas clearing and repopulating the axis for each chart is more cumbersome and less flexible.
If I assign any items to Chart.BottomAxis.Items then the string returned by OnGetAxisLabel is not shown.
What is the point of OnGetAxisLabel if it cannot change what is displayed?
Thanks,
Jamie
Thanks, but as I said in my second post this doesn't help me.
The change to TeeChart breaks existing code, which needs to dynamically adjust the bottom axis for sometimes over 100 charts on the screen at any time. OnGetAxisLabel is fired as the chart gets redrawn, whereas clearing and repopulating the axis for each chart is more cumbersome and less flexible.
If I assign any items to Chart.BottomAxis.Items then the string returned by OnGetAxisLabel is not shown.
What is the point of OnGetAxisLabel if it cannot change what is displayed?
Thanks,
Jamie
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hello Jamie,
My suggestion is to populate the series labels instead of using
This should internally recalculate the labels to be drawn depending on the axis size.
My suggestion is to populate the series labels instead of using
OnGetAxisLabel
or Chart.BottomAxis.Items
.This should internally recalculate the labels to be drawn depending on the axis size.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hi Yeray,
Thanks, but because some of the labels are times and other values that have meaning the automatically calculated increments do not always make sense and customers have said so - hence I overrode it with my own algorithm, which my customers are happy with.
I say again though: why has OnGetAxisLabel stopped working? It now serves no purpose!
Why has this changed and broken my existing code, which has worked this way for over 10 years?
In that time I have upgraded TChart several times without it breaking before.
Thanks, but because some of the labels are times and other values that have meaning the automatically calculated increments do not always make sense and customers have said so - hence I overrode it with my own algorithm, which my customers are happy with.
I say again though: why has OnGetAxisLabel stopped working? It now serves no purpose!
Why has this changed and broken my existing code, which has worked this way for over 10 years?
In that time I have upgraded TChart several times without it breaking before.
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
OK, further to my last post, I just checked the latest Help chm file I downloaded and the description for OnGetAxisLabel still matches what I am trying to do.
Surely this is a bug, as this function no longer works?
I can see my code assigning values to LabelText, as shown, but they do no appear.
Surely this is a bug, as this function no longer works?
I can see my code assigning values to LabelText, as shown, but they do no appear.
- Attachments
-
- GetAxisLabel.png (31.96 KiB) Viewed 14903 times
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
... third post!
I should also point out, in answer to your point that the axis doesn't display because I have not added any labels, that OnGetAxisLabel is not called at all if I add even a single label to "BottomAxis.Items".
I should also point out, in answer to your point that the axis doesn't display because I have not added any labels, that OnGetAxisLabel is not called at all if I add even a single label to "BottomAxis.Items".
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hello Jamie,
I've been trying your test app with previous TeeChart versions (v2021.33 to v2022.36) with the same results. In what version do you find it behaved differently?
I'll be glad to investigate any braking change you may identify.
Indeed, if I add a custom item to the bottom axis,
I've been trying your test app with previous TeeChart versions (v2021.33 to v2022.36) with the same results. In what version do you find it behaved differently?
I'll be glad to investigate any braking change you may identify.
Indeed, if I add a custom item to the bottom axis,
OnGetAxisLabel
is not being fired, but the custom item is drawn, so you should be able to implement your algorithm with custom items. Ie:Code: Select all
procedure TForm2.Button2Click(Sender: TObject);
var
Chart: TChart;
Rect: TRect;
begin
Chart := TChart.Create(Self);
Chart.View3D := False;
//Chart.BottomAxis.LabelStyle := talText;
Chart.BottomAxis.Items.Add(5, 'five');
Chart.BottomAxis.Items.Add(10, 'ten');
Chart.BottomAxis.MinorTicks.Hide;
//Chart.OnGetAxisLabel := ChartGetAxisLabel;
Chart.AddSeries(TBarSeries.Create(Chart));
Chart.SeriesList[0].FillSampleValues(48);
Rect := Image1.ClientRect;
Chart.Draw(Image1.Canvas, Rect);
Chart.Free;
Image1.Refresh;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hi Yeray,
I assign the same OnGetAxisLabel procedure to between 50 and 1000 charts in a grid, which automatically refresh the axis labels as the grid scrolls/resizes and the charts redraw, which seems a nice solution. I would prefer, if possible, not to risk introducing any bugs by changing the method, as the software runs 24/7, recording data.
Unfortunately in my many attempts to get the latest TeeChart version working with QuickReport I uninstalled all my previous versions of TeeChart for the other Delphi versions I have on my current development machines, so I can't say what the latest version was that OnGetAxisLabel was working with. I daren't try reinstalling any older versions, in case it breaks what took me weeks to get working!
I have booted up some older versions of Delphi on an old PC and my previous laptop and can confirm that the code I uploaded works as expected on the following TeeChart versions :-
Delphi XE2 : "TeeChart Standard v2011.03.32815 32bit VCL"
Delphi XE7 : "TeeChart Pro v2017.22.170619 32bit VCL"
Thanks,
Jamie
I assign the same OnGetAxisLabel procedure to between 50 and 1000 charts in a grid, which automatically refresh the axis labels as the grid scrolls/resizes and the charts redraw, which seems a nice solution. I would prefer, if possible, not to risk introducing any bugs by changing the method, as the software runs 24/7, recording data.
Unfortunately in my many attempts to get the latest TeeChart version working with QuickReport I uninstalled all my previous versions of TeeChart for the other Delphi versions I have on my current development machines, so I can't say what the latest version was that OnGetAxisLabel was working with. I daren't try reinstalling any older versions, in case it breaks what took me weeks to get working!
I have booted up some older versions of Delphi on an old PC and my previous laptop and can confirm that the code I uploaded works as expected on the following TeeChart versions :-
Delphi XE2 : "TeeChart Standard v2011.03.32815 32bit VCL"
Delphi XE7 : "TeeChart Pro v2017.22.170619 32bit VCL"
Thanks,
Jamie
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hello Jamie,
We'll check if there's anything wrong with it.
Thanks to this I found the issue you are experiencing was introduced with the fix for #1899.
We'll check if there's anything wrong with it.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hello Jamie,
I've added it to the public tracker and already fixed it for the next maintenance release:
https://www.steema.com/bugs/show_bug.cgi?id=2565
Since you own the sources, you can apply the fix to your copy without waiting for the next release. At TeEngine.pas, substitute the
I've added it to the public tracker and already fixed it for the next maintenance release:
https://www.steema.com/bugs/show_bug.cgi?id=2565
Since you own the sources, you can apply the fix to your copy without waiting for the next release. At TeEngine.pas, substitute the
CalcFirstLastAllSeries
method for this:
Code: Select all
procedure CalcFirstLastAllSeries(out tmpFirst,tmpLast:Integer);
var t : Integer;
begin
tmpFirst:=High(Integer);
tmpLast:=-1;
for t:=0 to ISeriesList.Count-1 do
with ISeriesList[t] do
begin
if (FLabels.Count>0) or (LabelStyle=talPointValue) or Assigned(ParentChart.FOnGetAxisLabel) then
begin
CalcFirstLastVisibleIndex;
if (FFirstVisibleIndex<tmpFirst) and (FFirstVisibleIndex<>-1) then
tmpFirst:=FFirstVisibleIndex;
if FLastVisibleIndex>tmpLast then
tmpLast:=FLastVisibleIndex;
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hi Yeray,
Many thanks for your help. Unfortunately that doesn't seem to have solved the problem for me, but perhaps I'm missing something?
I made the change you suggested in TeEngine.pas and VCLTee.TeEngine.pas (just to be sure) and ran TeeRecompile, but I'm not seeing any change in the behaviour of my Project2 test code.
Is there something else I need to do?
Thanks again,
Jamie
Many thanks for your help. Unfortunately that doesn't seem to have solved the problem for me, but perhaps I'm missing something?
I made the change you suggested in TeEngine.pas and VCLTee.TeEngine.pas (just to be sure) and ran TeeRecompile, but I'm not seeing any change in the behaviour of my Project2 test code.
Is there something else I need to do?
Thanks again,
Jamie
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hello Jamie,
This is how your project looks for me after the change: Make sure you are rebuilding the project after applying the change.
This is how your project looks for me after the change: Make sure you are rebuilding the project after applying the change.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Chart.Draw with LabelStyle talText - BottomAxis missing
Hi Yeray,
Apologies, I made a silly mistake!
I edited the files, as stated, I ran TeeRecompile, I rebuilt the project ... but I had put the modified TeEngine.pas in the same directory as VCLTee.TeEngine.pas!
Hence TeeRecompile was still finding the old version of TeEngine.pas.
The project now works as expected and I can finally issue a product update.
Thanks again for your continued help.
All the best,
Jamie
Apologies, I made a silly mistake!
I edited the files, as stated, I ran TeeRecompile, I rebuilt the project ... but I had put the modified TeEngine.pas in the same directory as VCLTee.TeEngine.pas!
Hence TeeRecompile was still finding the old version of TeEngine.pas.
The project now works as expected and I can finally issue a product update.
Thanks again for your continued help.
All the best,
Jamie