Recent

Author Topic: Paint area  (Read 9395 times)

carmelo81

  • New member
  • *
  • Posts: 7
Paint area
« 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

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Paint area
« Reply #1 on: June 06, 2012, 10:23:35 pm »
Use Chart1.BackColor.

carmelo81

  • New member
  • *
  • Posts: 7
Re: Paint area
« Reply #2 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

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Paint area
« Reply #3 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

carmelo81

  • New member
  • *
  • Posts: 7
Re: Paint area
« Reply #4 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 :-[

carmelo81

  • New member
  • *
  • Posts: 7
Re: Paint area
« Reply #5 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

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Paint area
« Reply #6 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.

carmelo81

  • New member
  • *
  • Posts: 7
Re: Paint area
« Reply #7 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

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Paint area
« Reply #8 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. 

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Paint area
« Reply #9 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.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Paint area
« Reply #10 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.

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: Paint area
« Reply #11 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.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

carmelo81

  • New member
  • *
  • Posts: 7
Re: Paint area
« Reply #12 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.

carmelo81

  • New member
  • *
  • Posts: 7
[SOLVED] Paint area
« Reply #13 on: June 14, 2012, 10:17:43 pm »
Thanks to all!
I solved with TAreaSeries.
;-)
« Last Edit: June 14, 2012, 10:29:35 pm by carmelo81 »

 

TinyPortal © 2005-2018