delphi通过TChart实现各种图表功能

本文介绍了如何使用TChart组件创建实时图表,包括产量、进货对比、月度产量变化和热值分析,通过实例展示了如何从数据库读取数据并动态更新图表,以可视化关键业务指标。


procedure TFrmScsjkb.FormShow(Sender: TObject);
var
  Chart: TChart;  //test
  L,S,F: TChartSeries;//test

  seriesCl,seriesJh: TBarSeries;//TLineSeries;
  seriesQncl,SeriesQnjh,seriesJcZb: TPieSeries;
  seriesMycl,seriesLz,seriesS,seriesF:TLineSeries;
  na:Integer;

  TmpFile: string;

begin


          Image3.Parent.DoubleBuffered:=true;
          Image4.Parent.DoubleBuffered:=true;
          Image5.Parent.DoubleBuffered:=true;
          Image6.Parent.DoubleBuffered:=true;
          Image7.Parent.DoubleBuffered:=true;
          Image8.Parent.DoubleBuffered:=true;
          Image9.Parent.DoubleBuffered:=true;
          Image10.Parent.DoubleBuffered:=true;

      Label24.Caption :=FormatDateTime('yyyy-mm-dd hh:mm',Now());

      proc_c_Chart_Cl14.close;
      proc_c_Chart_Cl14.prepared:=true;
      proc_c_Chart_Cl14.open;


    


      Chart := TChart.Create(nil);
      try

          Chart.Parent := Application.MainForm;
          Chart.Height:=407;
          Chart.Width:=597;
          Chart.Visible := False;


          //Chart.Title.Text.Text := '测试图表';
          S := TBarSeries.Create(Chart);

          Chart.AddSeries(S);

          TBarSeries(Chart.Series[0]).BarWidthPercent:=35;
          TBarSeries(Chart.Series[0]).BarStyle:=bsRectGradient;

          //将数据显示在上面
          S.Marks.Style:=smsValue;
          //不显示数据边框,强制显示数值
          S.Marks.Transparent:=True;
          S.Marks.AutoPosition:=True;
          S.Marks.FontSeriesColor:=True;
          S.Marks.Angle:=45;
          //S.BarStyle:= bsRectGradient;
          //S.Format.BarStyle:=bsRectGradient;

          //S.Title := '嘿嘿';
          proc_c_Chart_Cl14.First;

          while not proc_c_Chart_Cl14.Eof  do
          begin                                                   
              S.Add(proc_c_Chart_Cl14.FieldByName('mrcl').AsFloat,Copy(proc_c_Chart_Cl14.FieldByName('mmdd').AsString,5,4),clMoneyGreen );//clMoneyGreen

              proc_c_Chart_Cl14.Next;
          end;

          Chart.Legend.Visible := False; //数据框隐藏
          Chart.View3D := False;
          Chart.BackColor := $0032060C;//clBlue;   $00DB6817  $0032060C
          Chart.Gradient.StartColor := $0032060C;
          Chart.Gradient.EndColor := $0032060C;
          Chart.Gradient.Visible := True;
          Chart.Walls.Back.Transparent:=True;
          Chart.BevelOuter:=bvNone;

          Chart.LeftAxis.LabelsFormat.Font.Color:=clAqua; //$0000FF80
          Chart.BottomAxis.LabelsFormat.Font.Color:=clAqua;

          Chart.LeftAxis.Grid.Visible:=False;
          Chart.BottomAxis.Grid.Visible:=False;
          Chart.Walls.Visible:=False;


          Chart.LeftAxis.Axis.Color:=clBlue;
          Chart.BottomAxis.Axis.Color:=clBlue;
          //Chart.BottomAxis.LabelsAngle:=270;
          Chart.BottomAxis.LabelsAlternate:=True;
          TmpFile := Application.ExeName + '4.bmp';
          Chart.SaveToBitmapFile(TmpFile);
          Image4.Picture.LoadFromFile(TmpFile);
      finally
          Chart.Free;
      end;


    proc_c_Chart_Jh14.close;
      proc_c_Chart_Jh14.prepared:=true;
      proc_c_Chart_Jh14.open;


      Chart := TChart.Create(nil);
      try
          Chart.Parent := Application.MainForm;
          Chart.Hei

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值