954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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.

Here is also a pic of diagram - image

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;


And are there any other ways to make such diagram?

Will be grateful for any help!

max_22
Newbie Poster
1 post since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: