unit Unit1;

interface

uses
  Windows, Messages, PRINTERS,SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, TeEngine, Series, ExtCtrls, TeeProcs, Chart,
  TeeSelectorTool, TeeTools, TeePageNumTool, TeeLegendScrollBar,
  TeeTransposeTool, TeeLighting, TeeSurfaceTool, TeeSeriesBandTool,
  TeePieTool, TeeGanttTool, TeeExtraLegendTool, TeeDragPoint, Grids,
  TeeInspector, TeeLisB, TeeNavigator, TeeEdiGene, TeeEdit;

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Chart1: TChart;
    Label4: TLabel;
    BitBtn3: TBitBtn;
    ChartTool1: TCursorTool;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    ChartTool2: TMarksTipTool;
    BitBtn7: TBitBtn;
    BitBtn8: TBitBtn;
    BitBtn9: TBitBtn;
    BitBtn10: TBitBtn;
    Series1: TBarSeries;
    BitBtn11: TBitBtn;
    Button1: TButton;
    BitBtn12: TBitBtn;
    Series2: TLineSeries;
    BitBtn13: TBitBtn;
    BitBtn14: TBitBtn;
    BitBtn15: TBitBtn;
    Series3: TPointSeries;
    BitBtn16: TBitBtn;
    BitBtn17: TBitBtn;
    BitBtn18: TBitBtn;
    BitBtn19: TBitBtn;
    BitBtn20: TBitBtn;
    BitBtn21: TBitBtn;
    BitBtn22: TBitBtn;
    BitBtn23: TBitBtn;
    BitBtn24: TBitBtn;
    BitBtn25: TBitBtn;
    BitBtn26: TBitBtn;
    BitBtn27: TBitBtn;
    BitBtn28: TBitBtn;
    BitBtn29: TBitBtn;
    BitBtn30: TBitBtn;
    BitBtn31: TBitBtn;
    BitBtn32: TBitBtn;
    BitBtn33: TBitBtn;
    ChartPageNavigator1: TChartPageNavigator;
    BitBtn34: TBitBtn;
    BitBtn35: TBitBtn;
    BitBtn36: TBitBtn;
    BitBtn37: TBitBtn;
    ChartListBox1: TChartListBox;
    GroupBox1: TGroupBox;
    BitBtn38: TBitBtn;
    BitBtn40: TBitBtn;
    BitBtn41: TBitBtn;
    BitBtn42: TBitBtn;
    BitBtn39: TBitBtn;
    BitBtn43: TBitBtn;
    BitBtn44: TBitBtn;
    BitBtn45: TBitBtn;
    BitBtn46: TBitBtn;
    Series4: TLineSeries;
    BitBtn47: TBitBtn;
    BitBtn48: TBitBtn;
    BitBtn49: TBitBtn;
    BitBtn50: TBitBtn;
    Memo1: TMemo;
    BitBtn51: TBitBtn;
    ChartPreviewer1: TChartPreviewer;
    BitBtn52: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Chart1Scroll(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
      ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X,
      Y: Integer);
    procedure Series1Click(Sender: TChartSeries; ValueIndex: Integer;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn6Click(Sender: TObject);
    procedure BitBtn7Click(Sender: TObject);
    procedure BitBtn8Click(Sender: TObject);
    procedure BitBtn9Click(Sender: TObject);
    procedure BitBtn10Click(Sender: TObject);
    procedure BitBtn11Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure BitBtn12Click(Sender: TObject);
    procedure BitBtn13Click(Sender: TObject);
    procedure BitBtn14Click(Sender: TObject);
    procedure BitBtn15Click(Sender: TObject);
    procedure BitBtn16Click(Sender: TObject);
    procedure BitBtn17Click(Sender: TObject);
    procedure BitBtn18Click(Sender: TObject);
    procedure BitBtn19Click(Sender: TObject);
    procedure BitBtn21Click(Sender: TObject);
    procedure BitBtn22Click(Sender: TObject);
    procedure BitBtn23Click(Sender: TObject);
    procedure BitBtn24Click(Sender: TObject);
    procedure BitBtn25Click(Sender: TObject);
    procedure BitBtn26Click(Sender: TObject);
    procedure BitBtn27Click(Sender: TObject);
    procedure BitBtn28Click(Sender: TObject);
    procedure BitBtn29Click(Sender: TObject);
    procedure BitBtn30Click(Sender: TObject);
    procedure BitBtn31Click(Sender: TObject);
    procedure BitBtn32Click(Sender: TObject);
    procedure BitBtn33Click(Sender: TObject);
    procedure BitBtn34Click(Sender: TObject);
    procedure BitBtn35Click(Sender: TObject);
    procedure BitBtn36Click(Sender: TObject);
    procedure BitBtn37Click(Sender: TObject);
    procedure BitBtn38Click(Sender: TObject);
    procedure BitBtn39Click(Sender: TObject);
    procedure BitBtn40Click(Sender: TObject);
    procedure BitBtn41Click(Sender: TObject);
    procedure BitBtn42Click(Sender: TObject);
    procedure BitBtn43Click(Sender: TObject);
    procedure BitBtn44Click(Sender: TObject);
    procedure BitBtn45Click(Sender: TObject);
    procedure BitBtn46Click(Sender: TObject);
    procedure BitBtn47Click(Sender: TObject);
    procedure k(Sender: TObject);
    procedure BitBtn49Click(Sender: TObject);
    procedure BitBtn48Click(Sender: TObject);
    procedure BitBtn50Click(Sender: TObject);
    procedure BitBtn51Click(Sender: TObject);
    procedure BitBtn52Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Label1.Caption := 'CalcXPosValue='+Inttostr(Series1.CalcXPosValue(2));
Label2.Caption := 'CalcYPosValue='+Inttostr(Series1.CalcYPosValue(234.2));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(6);
Series1.YValue[0] := 100.5;
Series1.YValue[1] := 123.6;
Series1.YValue[2] := 234.2;
Series1.YValue[3] := 150.3;
Series1.YValue[4] := 400.4;
Series1.YValue[5] := 600.5;
Series2.FillSampleValues(6);
Series2.YValue[0] := 100.5;
Series2.YValue[1] := 123.6;
Series2.YValue[2] := 234.2;
Series2.YValue[3] := 150.3;
Series2.YValue[4] := 400.4;
Series2.YValue[5] := 600.5;
Series3.FillSampleValues(6);
Series4.FillSampleValues(6);
Series4.YValue[0] := 100.5;
Series4.YValue[1] := 123.6;
Series4.YValue[2] := 234.2;
Series4.YValue[3] := 150.3;
Series4.YValue[4] := 400.4;
Series4.YValue[5] := 600.5;

end;

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
Chart1.LeftAxis.Automatic := true;
Chart1.LeftAxis.Maximum := 1000;
Chart1.LeftAxis.Minimum := 100;
Chart1.LeftAxis.SetMinMax(100,1000);
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin

Label1.Caption := inttostr(Series1.CalcPosValue(100.5));
Label2.Caption := inttostr(Series1.CalcPosValue(234.2));
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin

Label4.Caption := Inttostr(X)+' '+Inttostr(Y);
end;

procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
  Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
Label1.Caption := Inttostr(Series.CalcXPos(ValueIndex));
Label2.Caption := Inttostr(X)+','+Inttostr(Y);
Label3.Caption := Inttostr(ValueIndex)+','+Inttostr(Series.CalcXPos(ValueIndex));
end;

procedure TForm1.Series1Click(Sender: TChartSeries; ValueIndex: Integer;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Label2.Caption := Inttostr(X);
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
begin
Label1.Caption := Inttostr(Series1.CalcXSizeValue(2));
Label2.Caption := Inttostr(Series1.CalcXSizeValue(3));
Label3.Caption := Inttostr(Series1.CalcXSizeValue(4));
end;

procedure TForm1.BitBtn4Click(Sender: TObject);
begin
Label1.Caption := Floattostr(Series1.XScreenToValue(154));
Label2.Caption := Floattostr(Series1.XScreenToValue(208));
end;

procedure TForm1.BitBtn5Click(Sender: TObject);
begin
Label1.Caption := Floattostr(Series1.XValue[2]);
end;

procedure TForm1.BitBtn6Click(Sender: TObject);
begin
Label2.Caption := Floattostr(Series1.YValue[2]);
end;

procedure TForm1.BitBtn7Click(Sender: TObject);
begin
Label1.Caption := Series1.XValueToText(2);
Label2.Caption := Series1.YValueToText(234.2);
end;

procedure TForm1.BitBtn8Click(Sender: TObject);
begin
Label1.Caption := Series1.XLabel[2];
end;

procedure TForm1.BitBtn9Click(Sender: TObject);
begin
Label1.Caption := Inttostr(Series1.ValueColor[2]);
end;

procedure TForm1.BitBtn10Click(Sender: TObject);
begin
Series1.SeriesColor := RGB(0,255,0);
end;

procedure TForm1.BitBtn11Click(Sender: TObject);
begin
Series1.Marks.Visible := TRUE;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Chart1.SaveToBitmapFile('Test.BMP');
Chart1.SaveToBitmapFile('Test_R.BMP',Rect(0,0,500,400));
end;

procedure TForm1.BitBtn12Click(Sender: TObject);
begin
Series2.ShowInLegend := FALSE;
end;

procedure TForm1.BitBtn13Click(Sender: TObject);
begin
Series2.Stairs := true;
Series2.InvertedStairs := true;
end;

procedure TForm1.BitBtn14Click(Sender: TObject);
begin
Label1.Caption := Inttostr(Series1.XValues.Count);
end;

procedure TForm1.BitBtn15Click(Sender: TObject);
begin
Label1.Caption := Series1.LegendString(3,ltsLeftValue);
Label2.Caption := Inttostr(Series1.CountLegendItems);
Label3.Caption :=  Inttostr(Series1.LegendToValueIndex(3));
end;

procedure TForm1.BitBtn16Click(Sender: TObject);
begin
Series1.SetNull(2,true);
if Series1.IsNull(2) then
   ShowMessage('null!')
   else
   ShowMessage('not null!') ;
end;

procedure TForm1.BitBtn17Click(Sender: TObject);
begin
Label1.Caption := Inttostr(Series1.FirstValueIndex);
Label2.Caption := Inttostr(Series2.LastValueIndex);
end;

procedure TForm1.BitBtn18Click(Sender: TObject);
begin
Label1.Caption := Inttostr(Series1.Labels.Capacity);
Label2.Caption := Inttostr(Series2.Labels.Capacity);
end;

procedure TForm1.BitBtn19Click(Sender: TObject);
begin
Label1.Caption :=  Chart1.AxisTitleOrName(Chart1.LeftAxis);
end;

procedure TForm1.BitBtn21Click(Sender: TObject);
begin
Series1.Add(500,'Test',rgb(0,128,0));
Series1.AddBar(300,'Addbar',RGB(0,0,0));
end;

procedure TForm1.BitBtn22Click(Sender: TObject);
begin
Label1.Caption :=  Inttostr(Series1.AddArray([130.0, 260.0, 390.0, 520.0]));
Chart1.Refresh;
end;

procedure TForm1.BitBtn23Click(Sender: TObject);
begin
Series1.AddNull(0.0) ;
end;

procedure TForm1.BitBtn24Click(Sender: TObject);
begin
Series1.AddNull('Null!');
end;

procedure TForm1.BitBtn25Click(Sender: TObject);
begin
Series1.AddNullXY(18,100,'t');
end;

procedure TForm1.BitBtn26Click(Sender: TObject);
begin
Series1.AddX(9.0,'T');
end;

procedure TForm1.BitBtn27Click(Sender: TObject);
begin
Series1.AddXY(8.0, 350.0,'AddXY');
end;

procedure TForm1.BitBtn28Click(Sender: TObject);
begin
Series1.AddY(500.0,'AddY');
end;

procedure TForm1.BitBtn29Click(Sender: TObject);
begin
Series1.SortByLabels(loAscending);
end;

procedure TForm1.BitBtn30Click(Sender: TObject);
begin
Chart1.MarginUnits := muPixels;
Chart1.AxisTitleOrName(Chart1.LeftAxis);
//Chart1.PrintProportional := TRUE;

end;

procedure TForm1.BitBtn31Click(Sender: TObject);
begin
Chart1.MarginUnits := muPixels;
Chart1.MarginBottom := 20;
Chart1.MarginLeft := 20;
Chart1.MarginRight := 20;
Chart1.MarginTop := 20;

end;

procedure TForm1.BitBtn32Click(Sender: TObject);
begin
Chart1.SaveToMetafile('Test.emf');
Chart1.SaveToMetafileEnh('En_Test.emf');
Chart1.SaveToMetafileRect(TRUE,'Test_R.emf',Rect(0,0,500,400));
end;

procedure TForm1.BitBtn33Click(Sender: TObject);
begin
//Chart1.Page;    //当前页号
//Chart1.PreviousPage;  //前一页
//Chart1.NextPage;      //下一页
//Chart1.NumPages;      //总页数
end;

procedure TForm1.BitBtn34Click(Sender: TObject);
begin
//打印图表
Chart1.Print;
//设定打印范围
//Chart1.PrintPages(FromPage:Integer=1,ToPage:Integer=0);
Chart1.PrintPages(1,10);
//设定打印方向
//Chart1.PrintOrientation(poLandscape);
//Printer.Orientation := poLandscape;
//设定打印边距
Chart1.PrintMargins := Rect(10,10,20,20);
//设定打印分辨率
Chart1.PrintResolution := 300;
end;

procedure TForm1.BitBtn35Click(Sender: TObject);
begin
Chart1.Title.Text.Text := 'TestTitle';
Chart1.Title.Text.SetText('12345');
Chart1.Title.Text.Add('ADD');
Label1.Caption := Chart1.Title.Text.Text;

Chart1.SubTitle.Text.SetText('SubTitle');
Label2.Caption := Chart1.SubTitle.Text.GetText;
end;

procedure TForm1.BitBtn36Click(Sender: TObject);
begin
Chart1.ScaleLastPage := true;
end;

procedure TForm1.BitBtn37Click(Sender: TObject);
begin
Chart1.ScaleLastPage := false;

end;

procedure TForm1.BitBtn38Click(Sender: TObject);
begin
Chart1.View3D := TRUE;
//Chart1.View3DWalls := TRUE;

end;

procedure TForm1.BitBtn39Click(Sender: TObject);
begin
Chart1.View3DWalls := FALSE;
end;

procedure TForm1.BitBtn40Click(Sender: TObject);
begin
Chart1.View3DOptions.OrthoAngle  := 20; 
end;

procedure TForm1.BitBtn41Click(Sender: TObject);
begin
Chart1.View3DOptions.Rotation := 50;
end;

procedure TForm1.BitBtn42Click(Sender: TObject);
begin
Chart1.View3DOptions.Zoom := 50;

end;

procedure TForm1.BitBtn43Click(Sender: TObject);
begin
Chart1.View3DOptions.FontZoom := 50;
end;

procedure TForm1.BitBtn44Click(Sender: TObject);
begin
Chart1.Zoomed := true;
Chart1.Zoom.Animated := true;
Chart1.ZoomPercent(50.0);
//Chart1.ZoomRect(Rect(20,20,100,100));
end;

procedure TForm1.BitBtn45Click(Sender: TObject);
begin
Chart1.UndoZoom;
end;

procedure TForm1.BitBtn46Click(Sender: TObject);
begin
Chart1.SeriesDown(Series2);
end;

procedure TForm1.BitBtn47Click(Sender: TObject);
begin
Chart1.SeriesUp(Series4);
end;

procedure TForm1.k(Sender: TObject);
begin
Chart1.AxisBehind :=TRUE;
end;

procedure TForm1.BitBtn49Click(Sender: TObject);
begin
Chart1.Foot.Text.SetText('Foot Test!');
Label1.Caption := Chart1.Foot.Text.GetText;
Chart1.SubFoot.Text.SetText('SubFoot Test!');
Label2.Caption := Chart1.SubFoot.Text.GetText;
end;

procedure TForm1.BitBtn48Click(Sender: TObject);
begin
//Chart1.AxisBehind := true;
Chart1.AxisBehind := false;
end;

procedure TForm1.BitBtn50Click(Sender: TObject);
begin
Label1.Caption := Inttostr(Chart1.AxesList.Count);
end;

procedure TForm1.BitBtn51Click(Sender: TObject);
begin
Chart:=Chart1;
ChartPreviewer1.Execute;
end;

procedure TForm1.BitBtn52Click(Sender: TObject);
begin
Chart1.
end;

end.
