Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

stacked barSeries... ???????????? ? ? ?

edited March 2004 in End User
I have data in the form of:
division,year, amount
Boise,1991,1000
Boise,1992,2000
California,1991,3000
California,1992,4000
Montana,1992,5000

Using year on the X-axis and amount on the Y-axis, I
need a barSeries that shows, by color, that of the 4000 in 1991 Boise is
responsible for 1000 and California 3000... see what I mean.

The data comes from an VIEW on and MS-SQL database... I'm trying to create
the barSeries at runtime and failing MISERABLY... not sure I understand how
to control it or how my end result should 'really' playout... not managing
to get anything....

something like this...
(don't laugh, I've been hacking away at it for a while)
var
lastCorp : string;
i : integer;
series : TBarseries;
vseries : array of TBarSeries;
color : integer;
begin
dsADOTblrpt.DataSet.Open;
dsADOTblrpt.DataSet.First;
i := 0;
color := random(65535);
lastCorp := dsADOTblrpt.DataSet.FieldByName('description').AsString;
//series := TBarSeries.Create(dbchart1);
SetLength(vseries,20);
while not dsADOTblRpt.DataSet.Eof do
begin
if dsADOTblrpt.DataSet.FieldByName('description').asstring <> lastCorp
then
begin
vseries[i] := TBarSeries.Create(dbchart1);
vseries[i].Title :=
dsADOTblrpt.DataSet.FieldByName('description').asstring;
vseries[i].MultiBar := mbstacked;
vseries[i].Marks.Visible := false;
vseries[i].UseAxis := true;
vseries[i].ColorSource := ColorToString(random(65535));
vseries[i].AutoMarkPosition := false;
vseries[i].XLabelsSource := 'year';
vseries[i].Dark3D := false;
vseries[i].UseYOrigin := False;
vseries[i].XValues.DateTime := False;
vseries[i].XValues.Name := 'Year';
vseries[i].XValues.Multiplier := 1.000000000000000000;
vseries[i].XValues.Order := loAscending;
vseries[i].XValues.ValueSource := 'year';
vseries[i].YValues.DateTime := False;
vseries[i].YValues.Name := 'Bar';
vseries[i].YValues.Multiplier := 1.000000000000000000;
vseries[i].YValues.Order := loNone;
vseries[i].YValues.ValueSource := 'allfees';
i := i + 1;
lastcorp := dsADOTblrpt.DataSet.FieldByName('description').AsString;
//
showmessage(dsADOTblrpt.DataSet.FieldByName('description').asstring);
end;

if dsADOTblrpt.DataSet.FieldByName('description').AsString = lastCorp
then
begin
dbchart1.AddSeries(vseries[i]);

DBChart1.Series[i].AddXY(dsADOTblRpt.DataSet.FieldValues['year'],dm.dsADOTbl
Rpt.DataSet.FieldValues['allfees']);
lastCorp := dsADOTblrpt.DataSet.FieldByName('description').AsString;
// showmessage(inttostr(i) + ' : ' +
dsADOTblrpt.DataSet.FieldByName('description').asstring + ' : ' +
dsADOTblRpt.DataSet.Fieldbyname('year').AsString + ' : ' +
dsADOTblRpt.DataSet.Fieldbyname('allfees').AsString);
end;
DBChart1.Series[i].Active := true;
dsADOTblRpt.DataSet.Next;
end;
end;


//not really quite sure where to put it to make it show... it might be
reading this all alright and it just isn't happening at the right time to
make it show... I've moved it around to respond to a variety of events
including formshow, onclick, etc.

I'm thinking that I want to make a new series for each 'area'... Colifornia,
Montana, etc... and add xy values for each year within that are... am I
right on that thought?

So the data is ordered by 'area/district/state', they year...

How close am I?

thanx so much (Nard... you are the answer-guy)
b

Comments

  • edited March 2004
    getting closer... looks like all I really need to know how to do is to
    create and add a series dynamically at runtime... so that as the data grows
    so do the number of series...

    I'm not finding that in the help files... it tells how to create at run
    time... but I don't know how many I might have so need to do it a little
    differently.

    thanx
    b
  • edited March 2004
    something like this... thanx! just knowing you were there for me was so
    helpful...

    I can modify this to suit my purposes.

    procedure TForm1.ADOTable1AfterOpen(DataSet: TDataSet);
    var
    bsArray : array of TBarSeries;
    i : integer;
    color : Tcolor;
    begin

    color := 0202020;
    SetLength(bsArray,30);
    DBChart1.SeriesList.Clear;

    bsArray[0] := TBarSeries.Create(dbchart1);
    bsArray[1] := TBarSeries.Create(dbchart1);
    bsArray[2] := TBarSeries.Create(dbchart1);
    bsArray[3] := TBarSeries.Create(dbchart1);

    for i := 0 to 3 do
    begin
    bsArray[i].MultiBar := mbStacked;
    bsArray[i].ParentChart := dbchart1;
    bsArray[i].Title := 'take that ' + inttostr(i);
    bsArray[i].SeriesColor := color;
    bsArray[i].Marks.Visible := false;
    bsArray[i].AddXY(1991,2000,'1991');
    bsArray[i].AddXY(1992,3000,'1992');
    bsArray[i].AddXY(1993,4000,'1993');
    bsArray[i].AddXY(1994,5000,'1994');
    bsArray[i].AddXY(1995,2000,'1995');
    bsArray[i].AddXY(1996,3000,'1996');
    bsArray[i].AddXY(1997,4000,'1997');
    bsArray[i].AddXY(1998,5000,'1998');
    color := color + 5555;
    end;

    end;
  • edited March 2004

    I think you need to direct this question to TeeChart tech support.

    ReportBuilder simply enables TeeChart to be used within a report.

    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.