home *** CD-ROM | disk | FTP | other *** search
- {****************************************}
- { TeeChart. TChart Component }
- { Copyright (c) 1995-98 by David Berneda }
- { All Rights Reserved }
- {****************************************}
- unit UMultAxi;
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- TeEngine, Series, ExtCtrls, TeeProcs, Chart, CandleCh, OHLChart,
- StdCtrls, TeeComma;
-
- type
- TFormMultipleAxes = class(TForm)
- Chart1: TChart;
- Series1: TLineSeries;
- Series2: TLineSeries;
- Series3: TCandleSeries;
- Series4: TVolumeSeries;
- Panel1: TPanel;
- CheckBox1: TCheckBox;
- CheckBox2: TCheckBox;
- ScrollBar1: TScrollBar;
- Label1: TLabel;
- CheckBox3: TCheckBox;
- Timer1: TTimer;
- CheckBox4: TCheckBox;
- CheckBox5: TCheckBox;
- CheckBox6: TCheckBox;
- CheckBox7: TCheckBox;
- CheckBox8: TCheckBox;
- CheckBox9: TCheckBox;
- TeeCommander1: TTeeCommander;
- Button1: TButton;
- procedure FormCreate(Sender: TObject);
- procedure Chart1AfterDraw(Sender: TObject);
- procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Chart1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Chart1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Chart1AllowScroll(Sender: TChartAxis; var AMin, AMax: Double;
- var AllowScroll: Boolean);
- procedure CheckBox1Click(Sender: TObject);
- procedure CheckBox2Click(Sender: TObject);
- procedure ScrollBar1Change(Sender: TObject);
- procedure CheckBox3Click(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure CheckBox4Click(Sender: TObject);
- procedure CheckBox6Click(Sender: TObject);
- procedure CheckBox5Click(Sender: TObject);
- procedure CheckBox7Click(Sender: TObject);
- procedure CheckBox8Click(Sender: TObject);
- procedure CheckBox9Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- Axis1,Axis2:TChartAxis;
- DeltaRotation,
- DeltaAxis1,DeltaAxis2,
- DeltaZoom,
- DeltaRight,DeltaLeft:Integer;
- DraggingLine:Boolean;
- Procedure CheckRightAxis;
- end;
-
- var
- FormMultipleAxes: TFormMultipleAxes;
-
- implementation
-
- {$R *.DFM}
- Uses TeCanvas; { <-- only needed for "ZoomText" special Canvas property }
-
- procedure TFormMultipleAxes.FormCreate(Sender: TObject);
- begin
- DeltaRotation:=2;
- DeltaAxis1:=1;
- DeltaAxis2:=1;
- DeltaRight:=2;
- DeltaLeft:=2;
- DeltaZoom:=2;
-
- DraggingLine:=False;
- ScrollBar1.Position:=Chart1.View3DOptions.Rotation;
-
- Chart1.MarginLeft:=10;
- Chart1.ClipPoints:=False;
- Chart1.Gradient.Visible:=Chart1.IsScreenHighColor;
- CheckBox5.Checked:=Chart1.Gradient.Visible;
-
- Axis1:=TChartAxis.Create(Chart1);
- With Axis1 do
- begin
- Horizontal:=False;
- StartPosition:=50;
- EndPosition:=100;
- LabelsFont.Color:=Series2.SeriesColor;
- end;
- Series2.CustomVertAxis:=Axis1;
-
- Axis2:=TChartAxis.Create(Chart1);
- With Axis2 do
- begin
- Horizontal:=False;
- StartPosition:=0;
- EndPosition:=50;
- LabelsFont.Color:=Series3.SeriesColor;
- PositionPercent:=-10;
- Grid.Visible:=False;
- end;
- Series3.CustomVertAxis:=Axis2;
-
- Chart1.LeftAxis.EndPosition:=50;
- Chart1.LeftAxis.LabelsFont.Color:=Series1.SeriesColor;
-
- Series1.FillSampleValues(20);
- Series3.FillSampleValues(20);
- Series4.FillSampleValues(120);
- Series2.FillSampleValues(20);
-
- Series4.VertAxis:=aRightAxis;
-
- With Chart1.RightAxis do
- begin
- StartPosition:=50;
- Maximum:=Series4.YValues.MaxValue*2;
- AutomaticMaximum:=False;
- Grid.Visible:=False;
- LabelsFont.Color:=Series4.SeriesColor;
- end;
-
- Series2.HorizAxis:=aTopAxis;
- Chart1.TopAxis.Grid.Visible:=False;
- Series2.ZOrder:=0;
- end;
-
- procedure TFormMultipleAxes.Chart1AfterDraw(Sender: TObject);
- begin
- { draw an horizontal line at left axis bottom position }
- With Chart1,Canvas do
- begin
- Pen.Color:=clGray;
- Pen.Width:=2;
- Pen.Style:=psSolid;
- MoveTo3D(ChartRect.Left,LeftAxis.IEndPos,0);
- LineTo3D(ChartRect.Right,LeftAxis.IEndPos,0);
- end;
- end;
-
- Procedure TFormMultipleAxes.CheckRightAxis;
- begin
- if CheckBox1.Checked then Chart1.RightAxis.StartPosition:=Axis1.StartPosition;
- end;
-
- procedure TFormMultipleAxes.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- if DraggingLine then
- begin
- Chart1.LeftAxis.EndPosition:=Round((Y-Chart1.ChartRect.Top)*100.0/Chart1.ChartHeight);
- Axis1.StartPosition:=Chart1.LeftAxis.EndPosition;
- Axis2.EndPosition:=Chart1.LeftAxis.EndPosition;
- CheckRightAxis;
- end
- else
- begin
- if Abs(Y-Chart1.LeftAxis.IEndPos)<4 then Chart1.Cursor:=crTeeHand
- else Chart1.Cursor:=crDefault;
- Chart1.OriginalCursor:=Chart1.Cursor;
- end;
- end;
-
- procedure TFormMultipleAxes.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- DraggingLine:=(not Timer1.Enabled) and (Chart1.Cursor=crTeeHand);
- Chart1.CancelMouse:=DraggingLine;
- end;
-
- procedure TFormMultipleAxes.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- DraggingLine:=False;
- Chart1.CancelMouse:=False;
- end;
-
- procedure TFormMultipleAxes.Chart1AllowScroll(Sender: TChartAxis; var AMin,
- AMax: Double; var AllowScroll: Boolean);
- begin
- AllowScroll:=Sender<>Chart1.RightAxis;
- end;
-
- procedure TFormMultipleAxes.CheckBox1Click(Sender: TObject);
- begin
- CheckRightAxis;
- end;
-
- procedure TFormMultipleAxes.CheckBox2Click(Sender: TObject);
- begin
- Chart1.View3D:=CheckBox2.Checked;
- Chart1.View3DOptions.Orthogonal:=False;
- ScrollBar1.Enabled:=Chart1.View3D;
- if not Chart1.View3D then CheckBox9.Checked:=False;
- end;
-
- procedure TFormMultipleAxes.ScrollBar1Change(Sender: TObject);
- begin
- Chart1.View3DOptions.Rotation:=ScrollBar1.Position;
- end;
-
- procedure TFormMultipleAxes.CheckBox3Click(Sender: TObject);
- begin
- Timer1.Enabled:=CheckBox3.Checked;
- CheckBox1.Enabled:=not Timer1.Enabled;
- Chart1.Foot.Visible:=not Timer1.Enabled;
- CheckBox4.Enabled:=Timer1.Enabled;
- CheckBox9.Enabled:=Timer1.Enabled;
- end;
-
- procedure TFormMultipleAxes.Timer1Timer(Sender: TObject);
-
- Procedure CheckDelta(Var D:Integer; Const Value:Double; Min,Max:Integer);
- begin
- if (D<0) and (Value<Min+5) then D:=-D else
- if (D>0) and (Value>Max-5) then D:=-D;
- end;
-
- var MinAngle:Integer;
- begin
- if CheckBox9.Checked then
- begin
- Chart1.View3D:=True;
- With Chart1.View3DOptions do
- begin
- Orthogonal:=False;
- Rotation:=Rotation+DeltaRotation;
- if Chart1.Canvas.SupportsFullRotation then MinAngle:=0
- else MinAngle:=270;
- CheckDelta(DeltaRotation,Rotation,MinAngle,360);
- Zoom:=Zoom+DeltaZoom;
- CheckDelta(DeltaZoom,Zoom,20,120);
- end;
- end;
- Axis1.StartPosition:=Axis1.StartPosition+DeltaAxis1;
- CheckDelta(DeltaAxis1,Axis1.StartPosition,0,75);
-
- Axis2.StartPosition:=Axis2.StartPosition+DeltaAxis2;
- Axis2.EndPosition:=Axis2.EndPosition+DeltaAxis2;
- CheckDelta(DeltaAxis2,Axis2.EndPosition,0,95);
-
- With Chart1.RightAxis do
- begin
- PositionPercent:=PositionPercent+DeltaRight;
- CheckDelta(DeltaRight,PositionPercent,-10,110);
- end;
- With Chart1.LeftAxis do
- begin
- PositionPercent:=PositionPercent+DeltaLeft;
- CheckDelta(DeltaLeft,PositionPercent,-10,110);
- end;
- end;
-
- procedure TFormMultipleAxes.CheckBox4Click(Sender: TObject);
- begin
- Chart1.View3DOptions.ZoomText:=CheckBox4.Checked;
- end;
-
- procedure TFormMultipleAxes.CheckBox6Click(Sender: TObject);
- begin
- Chart1.AxisVisible:=CheckBox6.Checked;
- end;
-
- procedure TFormMultipleAxes.CheckBox5Click(Sender: TObject);
- begin
- Chart1.Gradient.Visible:=CheckBox5.Checked;
- end;
-
- procedure TFormMultipleAxes.CheckBox7Click(Sender: TObject);
- begin
- Chart1.Legend.Visible:=CheckBox7.Checked;
- end;
-
- procedure TFormMultipleAxes.CheckBox8Click(Sender: TObject);
- begin
- Chart1.View3DWalls:=CheckBox8.Checked;
- With Chart1.BackWall.Brush do
- if Chart1.View3DWalls then Style:=bsSolid
- else Style:=bsClear;
- Chart1.BackWall.Pen.Visible:=Chart1.View3DWalls;
- end;
-
- procedure TFormMultipleAxes.CheckBox9Click(Sender: TObject);
- begin
- CheckBox2.Checked:=True;
- end;
-
- procedure TFormMultipleAxes.Button1Click(Sender: TObject);
- begin
- Close;
- end;
-
- end.
-