Lazarus

Programming => Graphics and Multimedia => TAChart => Topic started by: carmelo81 on June 05, 2012, 05:50:11 pm

Title: Paint area
Post by: carmelo81 on June 05, 2012, 05:50:11 pm
Hi all!!
With this code i draw a graph
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
Chart1.Series.Clear;
  Lser:=TLineSeries.Create(Chart1);
  for x:= 1 to 20 do for y:=0 to 7 do
     Lser.AddXY(strtofloat(stringgrid1.Cells[1,x]),strtofloat(stringgrid1.Cells[2,x]));
      chart1.AddSeries(Lser);
       lser.LinePen.Width:=2;
end;
It's possible to color the surface bounded by this graph?
thank you very much for help me
Title: Re: Paint area
Post by: wp on June 06, 2012, 10:23:35 pm
Use Chart1.BackColor.
Title: Re: Paint area
Post by: carmelo81 on June 07, 2012, 10:33:28 am
Thanks but, chart1.backcolor fill all graph area.
I dont want this.
I want fill only the area inside the graph created.
Thank you
Title: Re: Paint area
Post by: wp on June 07, 2012, 03:19:14 pm
Do you mean something like in the attached screen shot? This is done with Chart1.BackColor := clCream and Chart1.Color := clSkyBlue
Title: Re: Paint area
Post by: carmelo81 on June 07, 2012, 05:48:02 pm
 :) no, i not mean that one...
i attach the picture to better understand ;)
i want fill only area inside my graph.


ps: sorry...my english is very bad :-[
Title: Re: Paint area
Post by: carmelo81 on June 07, 2012, 06:07:47 pm
This is the result of what i want to create.
I want fill only yellow area...
Thanks
Title: Re: Paint area
Post by: wp on June 07, 2012, 06:47:13 pm
You have to use two line series having the same data. Ideally, the series should take their data from a shared ListChartSource. The first line series uses a broad LinePen and black LinePen.Color. The second line series has a narrower LinePen and is yellow. Since both series have the same data they are drawn on top of eatch other. Just make sure that the second series has a higher ZPosition value than the first one, otherwise it will be over-drawn by the black one.
Title: Re: Paint area
Post by: carmelo81 on June 08, 2012, 09:17:22 am
Thanks for your courtesy!
I have also find "FloodFill" procedure.
What do you think?
U have an example for use this procedure?
Thanks
Title: Re: Paint area
Post by: wp on June 08, 2012, 04:54:01 pm
As far as I know, "FloodFill" is a general method of TCanvas. But when you want to apply TCanvas methods you have to do all the coordinate calculations and drawing by yourself, and you lose all the advantages of TAChart. 
Title: Re: Paint area
Post by: Ask on June 09, 2012, 01:09:15 am
I missed this thread since the title does not contain anything about chart.
Please include "TAChart" into the title next time.

Regarding your question -- I think you need to use area series.
Title: Re: Paint area
Post by: wp on June 09, 2012, 02:34:23 pm
What about creating a separate folder for all TAChart related postings (subfolder of Graphics)? There are a lot of positings now, and they are spread all over the entire forum. The search function here is not very powerful, and I often don't find postings any more where I want to read you answer again.
Title: Re: Paint area
Post by: JD on June 09, 2012, 02:37:18 pm
What about creating a separate folder for all TAChart related postings (subfolder of Graphics)? There are a lot of positings now, and they are spread all over the entire forum. The search function here is not very powerful, and I often don't find postings any more where I want to read you answer again.

That is a wonderful suggestion. It is important enough to merit its own child board now.
Title: Re: Paint area
Post by: carmelo81 on June 12, 2012, 10:30:47 pm
I missed this thread since the title does not contain anything about chart.
Please include "TAChart" into the title next time.

Regarding your question -- I think you need to use area series.

Sorry
I'll be more careful next time.
Thanks for your suggestion about area series.
Title: [SOLVED] Paint area
Post by: carmelo81 on June 14, 2012, 10:17:43 pm
Thanks to all!
I solved with TAreaSeries.
;-)
TinyPortal © 2005-2018