Series not showing in TeeChart when created at runtime?

I have a dataset that returns data as shown below

Date, region, sales

01/01/2017, Canteen, 1000
01/01/2017, Gym, 3000
01/01/2017, Salon, 2000
02/01/2017, Canteen, 5000
02/01/2017, gym, 6000
02/01 / 2017, Salon, 7000

I am trying to create a complex bar chart using this data.

The number of episodes will differ

I have the logic below to create a series, but I'm not sure how to add each value for example. I need the X axis to be by date and have 2 bars. Each rod is then folded into 3 rows as above.

while not tblSalesBreakdownByDate.Eof do
begin
  nIndex := objList.IndexOf(tblSalesBreakdownByDateCategory.AsString);
  if nIndex = -1  then
  begin
    objSeries := TBarSeries.Create(Self);
    objSeries.MultiBar := TMultiBar.mbStacked;
    objSeries.Title := tblSalesBreakdownByDateCategory.AsString;

    chrtBreakdownByDate.SeriesList.Add(objSeries);
    objList.AddObject(objSeries.Title, objSeries)
  end
  else
    objSeries := objList.Objects[nIndex];

  objSeries.Add(tblSalesBreakdownByDateTotalSales.AsFloat, tblSalesBreakdownByDateTransactionDate.AsString);

  tblSalesBreakdownByDate.Next;
end;

      

When I run this, even though it doesn't crash, I can't see any of the episodes I added?

Anyone can figure out what is wrong?

Is there an easy way to do this?

Ideally I would prefer to use a DB, but I'm not sure how to do this if the data is not static?

Greetings

Floor

+3


source to share


1 answer


Instead:

chrtBreakdownByDate.SeriesList.Add(objSeries);

      

Calling the AddSeries Method :

chrtBreakdownByDate.AddSeries(objSeries);

      



or without calling the add method, set the ParentChart to a series:

objSeries.ParentChart := chrtBreakdownByDate;

      

The SeriesList collection does not listen for changes to the collection, so the series was not added to the chart.Examples of how to add series at runtime can be found on the TChart page .

+3


source







All Articles