delphi 畫圖表,曲線圖

黑貝是條狗發表於2018-11-27

dbchart 圖表 連線 datasource

先雙擊dbchart 建立一個 圖表型別 Series[0]

多個則  Series[N]

繫結 列

   DChar.Series[0].Title := '日均人數';
   DChar.Series[0].DataSource := MemReport;


    DChar.Series[0].Marks.ArrowLength := 20;
    DChar.Series[0].XLabelsSource := 'acitemname';
    DChar.Series[0].YValues.ValueSource := 'daysavg';
    DChar.Series[0].marks.Visible := True;
    DChar.Series[0].marks.Style:= smsvalue;

    DChar.Series[0].CheckDataSource;

chart  曲線圖

var
  lcs: TFastLineSeries;

begin


  //畫走勢圖
  cht1.SeriesList.Clear;
  cht1.Title.Text.Text := MemMaster.FieldByName('MOTHERNAME').AsString + '的寶寶:' +
  MemMaster.FieldByName('babyNAME').AsString + '體重走勢圖';
  lcs := TFastLineSeries.Create(cht1);
  lcs.Title := '體重' ;

  lcs.Marks.Style := smsvalue;
  lcs.Marks.Arrow.Visible := True;
  lcs.Marks.Callout.ArrowHead := ahSolid;
  lcs.Marks.Callout.ArrowHeadSize := 10;
  lcs.Marks.Visible := True;
  lcs.SeriesColor := clRed;
  with MemMaster do
  begin
    DisableControls;
    Last;
    while not Bof  do
    begin
      lcs.AddY(FieldByName('weight').AsFloat,  FormatDateTime('yyyymmdd',FieldByName('sodate').AsDateTime), clRed);
      Prior;
    end;
    First;
    EnableControls;
  end;

  cht1.AddSeries(lcs);

 

相關文章