DBChart 实现多个字段 柱状态图表显示

3 篇文章 0 订阅

开发环境 Delphi XE2  

最近做一个项目 需要显示每个部门的收发件数,

数据集如下 

类型总件数已结算件数未结算件数
客户500030002000
业务员300020001000
unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,   VCLTee.TeEngine,
  VCLTee.Series, Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.DBChart;

type
  TForm2 = class(TForm)
    DBChart1: TDBChart;
    Series2: TBarSeries;
    Series3: TBarSeries;
    Series1: TBarSeries;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin

  Series1.ManualData:=True;
  Series2.ManualData:=True;
  Series3.ManualData:=True;

  Series1.Add(3000,'业务员'); //总件数
  Series1.Add(5000,'客户');

  Series2.Add(2000,'业务员');  //已结算件数
  Series2.Add(3000,'客户');

  Series3.Add(1000,'业务员');//未结算件数
  Series3.Add(2000,'客户');




end;

end.

dfm单元

object Form2: TForm2
  Left = 0
  Top = 0
  Caption = 'Form2'
  ClientHeight = 466
  ClientWidth = 647
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object DBChart1: TDBChart
    Left = 0
    Top = 0
    Width = 647
    Height = 466
    AllowPanning = pmNone
    Title.AdjustFrame = False
    Title.Shadow.Visible = False
    Title.Text.Strings = (
      'TDBChart')
    DepthAxis.Title.Transparent = False
    LeftAxis.Title.Caption = #21333#20301#65306#20803
    LeftAxis.Title.ShapeStyle = fosRoundRectangle
    Legend.Alignment = laBottom
    Legend.Font.Shadow.Visible = False
    Legend.Title.Font.Shadow.Visible = False
    Legend.Title.Shadow.Visible = False
    RightAxis.LabelsExponent = True
    View3D = False
    Align = alClient
    TabOrder = 0
    PrintMargins = (
      15
      18
      15
      18)
    ColorPaletteIndex = 13
    object Series1: TBarSeries
      Marks.Arrow.Visible = False
      Marks.Callout.Brush.Color = clBlack
      Marks.Callout.Arrow.Visible = False
      Marks.Emboss.Color = 8553090
      Marks.Font.Emboss.Visible = True
      Marks.Font.Gradient.Outline = True
      Marks.Shadow.Color = 8684676
      Marks.Style = smsValue
      Marks.Symbol.Visible = True
      Marks.Visible = True
      Title = #24635#20214#25968
      Emboss.Color = 8816262
      Shadow.Color = 8816262
      Shadow.Visible = False
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Bar'
      YValues.Order = loNone
      Data = {0000000000}
    end
    object Series2: TBarSeries
      Marks.Arrow.Visible = True
      Marks.Callout.Brush.Color = clBlack
      Marks.Callout.Arrow.Visible = True
      Marks.Style = smsValue
      Marks.Visible = True
      Title = #24050#32467#31639#20214#25968
      Emboss.Color = 8947848
      Shadow.Color = 8947848
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Bar'
      YValues.Order = loNone
      Data = {0000000000}
    end
    object Series3: TBarSeries
      Marks.Arrow.Visible = True
      Marks.Callout.Brush.Color = clBlack
      Marks.Callout.Arrow.Visible = True
      Marks.Style = smsValue
      Marks.Visible = True
      Title = #26410#32467#31639#20214#25968
      Emboss.Color = 8947848
      Shadow.Color = 8947848
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Bar'
      YValues.Order = loNone
      Data = {0000000000}
    end
  end
end

效果图如下 

如果需要代码 请去资源里面下载 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值