界面代码:
object Form1: TForm1 Left = 568 Top = 393 Width = 725 Height = 408 Caption = '对象观察器' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnActivate = FormActivate OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object Chart1: TChart Left = 0 Top = 0 Width = 505 Height = 330 Border.Width = 2 Border.Visible = True BottomWall.Gradient.EndColor = 6308951 BottomWall.Gradient.MidColor = 13529477 BottomWall.Gradient.StartColor = 2514871 BottomWall.Gradient.Visible = True Gradient.Balance = 74 Gradient.Direction = gdBottomTop Gradient.EndColor = clWhite Gradient.StartColor = clAqua Gradient.Visible = True LeftWall.Gradient.Balance = 74 LeftWall.Gradient.Direction = gdBottomTop LeftWall.Gradient.EndColor = clBlack LeftWall.Gradient.MidColor = 16744576 LeftWall.Gradient.StartColor = clBlack LeftWall.Gradient.Visible = True Legend.CheckBoxesStyle = cbsRadio Title.Font.Color = clBlack Title.Text.Strings = ( '组件测试:水果产量') BottomAxis.Title.Caption = '品名' Chart3DPercent = 30 LeftAxis.Title.Caption = '数量' Align = alLeft BevelOuter = bvNone TabOrder = 0 Anchors = [akLeft, akTop, akRight, akBottom] PrintMargins = ( 15 13 15 13) object Series1: TBarSeries ColorEachPoint = True Marks.Callout.Brush.Color = clBlack Marks.Gradient.Visible = True Marks.Style = smsLabelValue Marks.Visible = True PercentFormat = '##0,## %' BarStyle = bsRectGradient Gradient.Direction = gdTopBottom Gradient.MidColor = 16059031 Gradient.StartColor = 14540754 XValues.Name = 'X' XValues.Order = loAscending YValues.Name = 'Bar' YValues.Order = loNone end end object TeeInspector1: TTeeInspector Left = 505 Top = 0 Width = 212 Height = 330 Align = alClient FixedCols = 1 RowCount = 8 FixedRows = 0 Options = [goFixedVertLine, goVertLine, goHorzLine, goColSizing, goThumbTracking] TabOrder = 1 Items = < item Caption = '3D' Value = True OnChange = TeeInspector1Items0Change end item Caption = '标签' Value = True OnChange = TeeInspector1Items1Change end item Caption = '图例' Value = True OnChange = TeeInspector1Items2Change end item Caption = '横坐标' Style = iiString Value = '品名' OnChange = TeeInspector1Items3Change end item Caption = '纵坐标' Style = iiString Value = '数量' OnChange = TeeInspector1Items4Change end item Caption = '字颜色' Style = iiColor Value = 0 OnChange = TeeInspector1Items5Change end item Caption = '图表标题' Style = iiString Value = '组件测试:水果产量' OnChange = TeeInspector1Items6Change end> Header.Font.Color = clNavy Header.Font.Gradient.Visible = True ColWidths = ( 82 126) RowHeights = ( 19 19 19 19 19 19 19 19) end object Panel1: TPanel Left = 0 Top = 330 Width = 717 Height = 41 Align = alBottom TabOrder = 2 object Label1: TLabel Left = 16 Top = 11 Width = 49 Height = 13 AutoSize = False Caption = '种类:' end object ComboFlat1: TComboFlat Left = 72 Top = 8 Width = 153 BevelKind = bkSoft Color = clWhite ItemIndex = 0 TabOrder = 0 Text = '苹果' OnChange = ComboFlat1Change Items.Strings = ( '苹果' '桔子' '梨' '葡萄' '甘蔗' '西瓜') end object Button1: TButton Left = 344 Top = 8 Width = 75 Height = 25 Caption = '&R.返回' TabOrder = 1 OnClick = Button1Click end object Button2: TButton Left = 264 Top = 8 Width = 75 Height = 25 Caption = '&P.打印' TabOrder = 2 OnClick = Button2Click end end object ChartPreviewer1: TChartPreviewer Chart = Chart1 Title = '打印...' Left = 232 Top = 201 end end
功能代码
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, TeeEdit, StdCtrls, TeCanvas, ExtCtrls, Grids, TeeInspector, TeEngine, Series, TeeProcs, Chart; type TForm1 = class(TForm) Chart1: TChart; Series1: TBarSeries; TeeInspector1: TTeeInspector; Panel1: TPanel; Label1: TLabel; ComboFlat1: TComboFlat; Button1: TButton; Button2: TButton; ChartPreviewer1: TChartPreviewer; procedure Button1Click(Sender: TObject); procedure ComboFlat1Change(Sender: TObject); procedure FormActivate(Sender: TObject); procedure TeeInspector1Items0Change(Sender: TObject); procedure TeeInspector1Items1Change(Sender: TObject); procedure TeeInspector1Items2Change(Sender: TObject); procedure TeeInspector1Items3Change(Sender: TObject); procedure TeeInspector1Items4Change(Sender: TObject); procedure TeeInspector1Items6Change(Sender: TObject); procedure TeeInspector1Items5Change(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin Close; end; procedure TForm1.ComboFlat1Change(Sender: TObject); begin (* 苹果 桔子 梨 葡萄 甘蔗 西瓜 *) with Series1 do begin Clear; case ComboFlat1.ItemIndex of 0: AddXY(1, 300, '苹果'); 1: AddXY(1, 280, '桔子'); 2: AddXY(1, 450, '梨'); 3: AddXY(1, 340, '葡萄'); 4: AddXY(1, 780, '甘蔗'); 5: AddXY(1, 280, '习惯'); 6: AddXY(1, 890, '柿子'); end; end; end; procedure TForm1.FormActivate(Sender: TObject); begin Series1.AddXY(1, 300, '苹果'); end; procedure TForm1.TeeInspector1Items0Change(Sender: TObject); begin Chart1.View3D := TeeInspector1.Items[0].Value; end; procedure TForm1.TeeInspector1Items1Change(Sender: TObject); begin Series1.Marks.Visible := TeeInspector1.Items[1].Value; end; procedure TForm1.TeeInspector1Items2Change(Sender: TObject); begin Chart1.Legend.Visible := TeeInspector1.Items[2].Value; end; procedure TForm1.TeeInspector1Items3Change(Sender: TObject); begin Chart1.BottomAxis.Title.Caption := TeeInspector1.Items[3].Value; end; procedure TForm1.TeeInspector1Items4Change(Sender: TObject); begin Chart1.LeftAxis.Title.Caption := TeeInspector1.Items[4].Value; end; procedure TForm1.TeeInspector1Items5Change(Sender: TObject); begin Chart1.Title.Font.Color := TeeInspector1.Items[5].Value; Chart1.BottomAxis.Title.Font.Color := TeeInspector1.Items[5].Value; Chart1.LeftAxis.Title.Font.Color := TeeInspector1.Items[5].Value; Chart1.Refresh; end; procedure TForm1.TeeInspector1Items6Change(Sender: TObject); begin Chart1.Title.Text.Text := TeeInspector1.Items[6].Value; end; procedure TForm1.Button2Click(Sender: TObject); begin ChartPreviewer1.Execute; end; procedure TForm1.FormCreate(Sender: TObject); begin Self.Position := poScreenCenter; end; end.