Go to Post I firmly believe that it's within your power to aspire instead of lament. - Alan Anderson [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-01-2011, 09:49
max_22 max_22 is offline
Registered User
no team
 
Join Date: Jan 2011
Location: russia
Posts: 1
max_22 is an unknown quantity at this point
Question Delphi DBGrid and Tchart

hi!I have a problem. There's the Access database embedded into dbrid using ADO.
In db there is a list of goods,quantity and countries where goods were produced

Now I have to build a diagram for db, for example for countries.

It works quite well but the diagram shows EVERY good, writes a country name and makes a column for each good.

I wonder if there's a way to make one column for each country.
Code:
procedure TForm4.BitBtn1Click(Sender: TObject);
var
m: array of string;
  bb: array of integer;
  I: integer;

begin
chart1.show;
  Chart1.Series[0].Clear;
   SetLength(m, Form2.adotable1.RecordCount);     // changes mas size
   SetLength(bb, Form2.adotable1.RecordCount);
   I := 0;
  while not  Form2.adotable1.Eof do
  begin
    if Form2.adotable1.FieldByName('country').AsString <> '' then
    begin
      m[i] := Form2.adotable1.FieldByName('country').AsString;
      bb[i] := 0;
      I := I + 1;
    end;
     form2.adotable1.Next;
  end;
  Form2.adotable1.First;
  I := 0;
  Form2.adotable1.First;
  while not Form2.adotable1.Eof do
  begin
    for I := 0 to length(m)-1 do   
      if m[i] = Form2.adotable1.FieldByName
        (Form2.DBGrid1.Columns.Items[4].DisplayName).AsString then
        bb[i] := bb[i] + Form2.adotable1.FieldByName
          (Form2.DBGrid1.Columns.Items[6].DisplayName).AsInteger;
    Form2.adotable1.Next;
  end;
  Form2.adotable1.First;
  for I := 0 to length(m)-1 do
    if m[i] <> '' then
    begin
      Chart1.Series[0].Add(bb[i], m[i], clTeeColor);
end;
end;
Here is the image of my diagram.

Will be grateful for any help!
  #2   Spotlight this post!  
Unread 23-01-2011, 02:46
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: Delphi DBGrid and Tchart

First:

Your question is very specific and will thought-out

Second: This is not a Delphi forum. People here that know delphi may help you, but its doubtful

This is a forum for the First Robotics Competitons (http://usfirst.org).

Sorry, but there's most likely no help here
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 23:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi