Saving a TAchart doesn't show footer in png but in jpeg lazarus / 31-LCL ---------------------------------------------------------------------- hakelm · 2014-11-20 13:15 When i save a tachart as a .PNG file the footer doesn't show up but when I save it as a .JPG the footer nicely appears. The code I use is shown below. This time I am using Lazarus 1.2.2 on Windows 7. What can I do? Thanks for any tip Håkan ...   Chart1.SaveToFile(TPortableNetworkGraphic, 'test.png');   Chart1.SaveToFile(TJpegImage, 'test.jpg'); ... ---------------------------------------------------------------------- wp · 2014-11-20 13:31 QuoteWhat can I do? Upgrade to Laz 1.2.6 I added a dummy text to the footer of the "save" demo and saved as png - no issue. If, after upgrading to 1.2.6, the issue still exists please upload a small compilable demo which shows the error (.lpi, .lpr, pas and lfm files only, packed into a zip). ---------------------------------------------------------------------- hakelm · 2014-11-20 16:42 Thanks for your prompt reply. I upgraded to 1.2.6 but my problem is still there. It turns out to be a bit interesting. In a simple program such as procedure TForm1.FormCreate(Sender: TObject); begin   self.Chart1.Foot.Text.Text:='Hello TAchart';   self.Chart1.Foot.Visible:=true;   self.Chart1.SaveToFile(TPortableNetworkGraphic,'bug.png'); end; the footer shows up. In my program, however, it turns out, that whether the footer shows or not depends on savetofile history. If I change the order of savetofile as in: ...   Chart1.SaveToFile(TJpegImage, 'test2.jpg');   Chart1.SaveToFile(TPortableNetworkGraphic,'test2.png'); ... the footer doesn't show in the jpg. Likewise, if I do:   Chart1.SaveToFile(TPortableNetworkGraphic,'test2.png');   Chart1.SaveToFile(TPortableNetworkGraphic,'test2.png'); the footer shows in the png. Funny isn't it? Håkan ---------------------------------------------------------------------- wp · 2014-11-20 16:51 OK, we'll fix it. At first I need a project which shows the problem, as I said *.pas, *.lfm, lpr, and lpi files packed into a zip which you can upload here. Based on that I can dive into the depths of TAChart. ---------------------------------------------------------------------- hakelm · 2014-11-20 18:24 Very nice! Please find a zip enclosed. I have tried to distil my program down to the bare minimum that still exhibits the nofoot feature. Please note that the footer is set by the Chart1ExtentChanged event. If you uncomment line 48 the footer will show up. The footer will also appear in foot.txt. I also have one question: My program is really intended for a linux- server nongui application but I find the TAchart component structure so complex that I plan to use gui programming and xpra. Is there any utility to transform the .lfm file to pascal code? Thanks and good luck H ---------------------------------------------------------------------- wp · 2014-11-20 21:42 Yes I can reproduce the problem with the program that you provided. I think the issue is due to the unconventional usage of the OnExtentChanged event. If you look at the source code (procedure TChart.Draw in TAGraph) you'll see that this event is fired during the onDraw event. But altering the footer is retriggering another drawing process again. In worst cases, the system could crash upon this iteration, but there are some precautions built into the LCL and TAChart. In particular you are calling SavePng in the FormCreate event even before the Chart has been painted on the screen. In this very first painting action the footer is still empty. I don't know how the png painter handles the repaint request initiated by the OnExtentChanged event, probably the file is already saved before that second repaint has a chance to start - no idea on details, and on why jpg behaves differently. What I tried, is to delay the SavePng until the Chart has had a chance to paint onto the screen. A good candidate is the FormActivate event. And in fact, if I copy your FormCreate code into FormActivate (and remove FormCreate) the png file is correct. But still this workaround appears rather fragile to me. I ask you to reconsider the design of this part of your program: Why do you have to use the OnExtentChanged event of the chart to display the footer? Can't you assign the footer somewhere else? Can you use some other event? The extent is not changing upon nothing, there must some other event that triggers the event change. maybe you can use this one to do the footer task. ---------------------------------------------------------------------- hakelm · 2014-11-20 22:05 Thanks a lot. I have no problems redesigning my program following your guidelines. The reason I used OnExtentChanged is that I copypasted the code from another old program I wrote. That the code ended up in FormCreate is only due to my laziness. Thanks again for putting your time to this. H ---------------------------------------------------------------------- wp · 2014-11-21 00:10 QuoteIs there any utility to transform the .lfm file to pascal code?I forgot to answer this question. Sorry, I don't know such a utility. Maybe, if nobody else answers in reasonable time, you could repost this particular question under a more specific title - I guess you'll get a greater audience for that without the TAChart in the title.