码迷,mamicode.com
首页 > 数据库 > 详细

Delphi DBChart

时间:2014-07-16 17:22:44      阅读:397      评论:0      收藏:0      [点我收藏+]

标签:delphi

一:属性相关:
Series选项:

(1)Format页(数据柱的风格)

在Color Each中打勾,就可使用多种颜色显示,
color按钮用于设置颜色,
Style用于设置图表的风格(Rectangle长方体,Pyramid三角体,Invert.PyramId倒三角体,Cylinder圆柱体,Ellipse圆形,Arrow箭头,

(2)Marks页(标记,数据内容显示设置)

数据内容显示设置:在Style中选相关的选项,标记的类型:Value值、Percent百分率、Label字段内容、Label and Percet字段内容+百分率、Label and Value
     字段内容+值、Legend与右上角的数据说明一样、Percent Total百分率+值、Label&Percent Total字段内容+百分率+值。

二:数据库绑定
1、绑定数据

ADOQuery1.Active := True;

DBChart1.Series[0].DataSource := ADOQuery1;

DBChart1.Series[0].XLabelSource := ‘FieldName’;

DBChart1.Series[0].YValues.ValueSource := ‘FieldName’;

2、切换图表类型

tmpChart := DBChart1.Series[0];

ChangeSeriesType(tmp, TLineSeries);

tmpChart.Active := true;

tmpChart.RefreshSeries;

3、设置分页

DBChart1.ScaleLastPage := true;

DBChart1.MaxPointsPerPage := 10;

DBChart1.Page := 1;

DBChart1.PreviousPage;

DBChart1.NextPage;

DBChart1.Page := NumPages;

4.导出图表
SaveToBitmapFile(FileName);

5.打印图表
uses TeePrevi;
ChartPreview(Parent,DBChart1);
TeePreview(Parent,DBChart1);

6.数据源
ADODataSet1.CreateDataSet;
AdoDataSet1.Insert;
AdoDataSet1.FieldByName(‘Value‘).AsFloat:=200000;
AdoDataSet1.FieldByName(‘Info‘).AsString:=‘05-02‘;
AdoDataSet1.Post;


三:实例

①:我用的是FASTLINE,里面需要动态的绑定x,y轴,在DBCHART中可以直接设置,那么在程序中如何设置呢?

          sSql := ‘select scan_start_time,sum‘+‘(‘+trim(adoQtarget.FieldByName(‘name‘).Value)+‘)‘+‘ as c1‘;
          sSql := sSql + ‘ from pm_radio ‘;
          sSql := sSql + ‘ where scan_start_time >=‘+#39+ FormatDateTime(‘YYYY-MM-DD HH:00:00‘,wwDBDateTimePicker1.DateTime)+#39;
          sSql := sSql + ‘ and scan_start_time <=‘+#39+ FormatDateTime(‘YYYY-MM-DD 23:00:00‘,wwDBDateTimePicker1.DateTime)+#39;
          sSql := sSql + ‘ group by scan_start_time‘;
          adoQChart.Close;
          adoQChart.SQL.Clear;
          adoQChart.SQL.Text :=sSql;
          adoQChart.Open;
         
          Series1.XValues.ValueSource := ‘scan_start_time‘;//adoQchart.FieldByName(‘scan_start_time‘).AsString;
          series1.YValues.ValueSource := ‘c1‘;//adoQchart.FieldValues[‘c1‘];//.fieldbyname(‘c1‘).AsString;

 

 ②:

uses Series,TeeEdiGene;

private
    Series1: TPieSeries; 

procedure TnPOP_check_model.insertcurrve_model_tot;
var
    curve_today_tot:array [0..30] of string;
begin
    Series1:=TPieSeries.Create(dbchart1);
    Series1.ParentChart:= dbChart1;
    Series1.Clear;
    Series1.Marks.Visible:=true;
    Series1.Marks.Style:=smsValue;
    Series1.SeriesColor:=cxcolorcombobox1.ColorValue;
    Series1.Title:=‘SUM_‘+‘-‘+‘Q‘;

    qry_temp1.Close;
    qry_temp1.SQL.Text:=‘select type,bad_count from press_check2‘;
    qry_temp1.Open;
      if qry_temp1.RecordCount>0 then
       begin
             if length(trim(qry_temp1.fieldbyname(‘bad_count‘).AsString))=0 then
                    curve_today_tot[i-1]:=‘0‘
              else
                  Series1.DataSource:= qry_temp1;
                  Series1.xlabelsSource:=‘type‘;
                  Series1.YValues.valuesource:=‘bad_count‘;
                  Series1.Active:=True;
        end;

    cxcombobox1.Properties.Items.Add(trim(series1.Title));
end;

Delphi DBChart,布布扣,bubuko.com

Delphi DBChart

标签:delphi

原文地址:http://blog.csdn.net/lailai186/article/details/37809551

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!