Hi,
(Im using Teechart through Digital Metaphors Report Builder.)
How do I count the number of records against a certain field parameter.
IE: if I have a table with 5 ford records, 2 volvo records, 3 saab records and so on. I want a bar chart with bar levels 5, 2, 3.
BUT If there are 4 red fords and 1 yellow one, I get two bars for ford (values 4 and 1).
And this happens even if I do not include the colour column in my table.
Thanks
Red
Grouping and counting data
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Red,
You can retrieve every bar value doing something like:
You can retrieve every bar value doing something like:
Code: Select all
for i:=0 to Series1.Count-1 do
Chart1.Title.Text.Add(FloatToStr(Series1.YValue[i]));
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi.
First thing to do is check what component are listed in the form IDE generated section. For example, if you drop a TChart on the (empty) form, the following classes will be added to form (published) section:
This means that if you later in your code do:
it will work fine, while on the other hand, if you do:
it will fail because Series1 (class) is NOT declared. I think in your case not Series1 nor Chart1 are declared (perhaps ppChart1 is declared). The code Narcis posted is ok, but you can't simpyl copy&paste it as you're most likely using different names. For example, the following code does te same thing, but it's adapted for my test application:
First thing to do is check what component are listed in the form IDE generated section. For example, if you drop a TChart on the (empty) form, the following classes will be added to form (published) section:
Code: Select all
type
TForm1 = class(TForm)
Chart1: TChart;
private
Code: Select all
Chart1.Title.Text.Clear;
Code: Select all
Series1.FillSampleValues(5);
Code: Select all
for i:=0 to DBTeeChart1.Series[0].Count-1 do
DBTeeChart1.Title.Text.Add(FloatToStr(DBTeeChart1.Series[0].YValue[i]));
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Hi Marjan,
Im a beginner but I do realise that I can not copy and paste your object names.
The only IDE object I have is "DPTeeChart1". No series listed.
Within my design tab I can edit my object. In there I have just one series called Series1.
Anyway I now get the error
"Undeclared identifier 'i'"
I really think Im missing a step somewhere.
Thanks
Red
Im a beginner but I do realise that I can not copy and paste your object names.
The only IDE object I have is "DPTeeChart1". No series listed.
Within my design tab I can edit my object. In there I have just one series called Series1.
Anyway I now get the error
"Undeclared identifier 'i'"
I really think Im missing a step somewhere.
Thanks
Red
Hi.
"i" should be declared as integer. You can do this in form private section or in the procedure where you call the code posted above.
"i" should be declared as integer. You can do this in form private section or in the procedure where you call the code posted above.
Code: Select all
var i: Integer;
begin // your procedure
for i:=0 to DPTeeChart1.Series[0].Count-1 do
DPTeeChart1.Title.Text.Add(FloatToStr(DPTeeChart1.Series[0].YValue[i]));
end;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com