Jump to content
Sign in to follow this  
RTollison

dbchart lines, not getting results desired

Recommended Posts

user wants a chart to show the records in a table. the tables structure is quite simple:

date, value1, value2,... value10

a date and then 10 numbers, the numbers are not in any order and that is fine. they max out at 200.

11/01/23, 101, 12, 32, 157, 1, 77, 18, 182, 45, 133

11/02/23,....

11/03/23,...

in a mock up of the chart i put the series titles as the date and the data values i entered all down in 10 rows and showed him the sample and he said that was exact what he wanted. now in my dataset query i am pulling * with date range but now matter what i try to do in the dbchart i cant seem to replicate.

there is no correspondence between the numbers start/end from date to date. even if the numbers are the exact same and in the same order then so be it. 

select * from table1 is basic query with a date range and that is working fine just not sure how to tie that data into the chart to get the same results.

chartdata.JPG

chartview.JPG

Share this post


Link to post

here is what i found and tested. works to a degree (no series titles but he seems ok with it) just a mess looking to me.

 

begin
  DBChart1.View3D:=false;
  DBChart1.Legend.Visible:=false;

  with DBChart1.AddSeries(TFastLineSeries) as TFastLineSeries do
  begin
    XValues.Order:=loNone;
    TreatNulls:=tnDontPaint;
    adodataset1.First;
    while not adodataset1.Eof do
    begin
      AddNullXY(0,0);  //start a new line
      AddXY(0,adodataset1.FieldByName('num_1').AsInteger);
      AddXY(1, adodataset1.FieldByName('num_2').AsInteger);
      AddXY(2, adodataset1.FieldByName('num_3').AsInteger);
      AddXY(3, adodataset1.FieldByName('num_4').AsInteger);
      AddXY(4, adodataset1.FieldByName('num_5').AsInteger);
      AddXY(5, adodataset1.FieldByName('num_6').AsInteger);
      AddXY(6, adodataset1.FieldByName('num_7').AsInteger);
      AddXY(7, adodataset1.FieldByName('num_8').AsInteger);
      AddXY(8, adodataset1.FieldByName('num_9').AsInteger);
      AddXY(9, adodataset1.FieldByName('num_10').AsInteger);
      adodataset1.Next;
    end;
  end;
end;

Share this post


Link to post

Here's sample of updating lineseries and legend in real time   I think the data points should the numbers and be in the legend Second the time axis is usually bottom axis. For old data pass in the datetime of the record and field name of number.    

 

 

    s := FormatDateTime('ss', Frac(aSimTime));
    Ptp := Chart1.Series[0];
    if Ptp.Count > 300 then
      Ptp.Delete(0, 100);

    Chart1.Series[0].AddXY(now, FXY.y, s, clRed);
    Chart1.Series[0].Title := 'A ' + FXY.y.ToString;

    if Chart1.SeriesCount > 1 then
    begin
      Ptp := Chart1.Series[1];
      Chart1.Series[1].AddXY(now, FXY.y + 5, '', clBlue);
      Chart1.Series[1].Title := 'A dgr ' + (FXY.y + 5).ToString;

      if Ptp.Count > 150 then

        Ptp.Delete(0, 50);
    end;

  end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×