### Bookstore

 Computer Math and Games in Pascal Lazarus, the complete guide (only a few left)

### Author Topic: Paint area  (Read 6022 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: 3538
##### Re: Paint area
« Reply #1 on: June 06, 2012, 10:23:35 pm »
Use Chart1.BackColor.
Lazarus trunk / fpc 3.0.0 / Win32

#### 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: 3538
##### 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
Lazarus trunk / fpc 3.0.0 / Win32

#### 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: 3538
##### 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.
Lazarus trunk / fpc 3.0.0 / Win32

#### carmelo81

• New member
• Posts: 7
##### Re: Paint area
« Reply #7 on: June 08, 2012, 09:17:22 am »
I have also find "FloodFill" procedure.
What do you think?
U have an example for use this procedure?
Thanks

#### wp

• Hero Member
• Posts: 3538
##### 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.
Lazarus trunk / fpc 3.0.0 / Win32

• 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: 3538
##### 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.
Lazarus trunk / fpc 3.0.0 / Win32

#### JD

• Hero Member
• Posts: 1565
##### 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 (10, 7) - Lazarus 1.6.4/FPC 3.0.2 (also Delphi occasionally)
Linux Mint Cinnamon  - Lazarus 1.4/FPC 2.6.4
Indy 10.6 series; Zeos 7.2.1; SQLite, Firebird, PostgreSQL & MariaDB

#### 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.

#### 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 »