home *** CD-ROM | disk | FTP | other *** search
- unit USurlab;
- {$P-} { <--- VERY IMPORTANT FOR Delphi 1.0 }
-
-
- { This example draws custom Labels for the Bottom Axis of
- a Surface Chart.
- It also draws custom text as Surface Z legends.
- }
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, TeEngine, TeeSurfa, ExtCtrls, TeeProcs, Chart, StdCtrls,
- Buttons, TeeComma;
-
- type
- TSurfaceLabelsForm = class(TForm)
- Chart1: TChart;
- Series1: TSurfaceSeries;
- TeeCommander1: TTeeCommander;
- Panel1: TPanel;
- CheckBox1: TCheckBox;
- Button1: TButton;
- BitBtn1: TBitBtn;
- procedure FormCreate(Sender: TObject);
- procedure Chart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
- ValueIndex: Longint; var LabelText: String);
- procedure BitBtn1Click(Sender: TObject);
- procedure CheckBox1Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- SurfaceLabelsForm: TSurfaceLabelsForm;
-
- implementation
-
- {$R *.DFM}
- Uses EditChar,EditPro;
-
- { Arrange some properties for this demo... }
- procedure TSurfaceLabelsForm.FormCreate(Sender: TObject);
- begin
- Series1.FillSampleValues(0); { <-- random values for surface }
-
- { this forces GetAxisLabel to call for each "ValueIndex" in the Series.. }
- Series1.XLabel[0]:='dummy';
- Chart1.BottomAxis.LabelStyle:=talText;
-
- { extra space to draw labels... }
- Chart1.MarginRight:=10;
- end;
-
- { This event supplies the Labels for the X Axis (Bottom) }
- procedure TSurfaceLabelsForm.Chart1GetAxisLabel(Sender: TChartAxis;
- Series: TChartSeries; ValueIndex: Longint; var LabelText: String);
- Var X,Z:Integer;
- begin
- if ValueIndex>=0 then
- if Sender=Chart1.BottomAxis then
- begin
- { calculate the X and Z for the ValueIndex }
- X:=ValueIndex div Series1.NumZValues;
- Z:=ValueIndex mod Series1.NumZValues;
-
- { Z=0 means we are at the front row of the surface,
- so we can draw a X label:
- }
- if Z=0 then LabelText:=Chr(Ord('a')+X) { <-- example }
- else LabelText:='';
- end
- else
- if Sender.IsDepthAxis then
- LabelText:='='+FloatToStr(Series1.ZValues[ValueIndex]);
- end;
-
- procedure TSurfaceLabelsForm.BitBtn1Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TSurfaceLabelsForm.CheckBox1Click(Sender: TObject);
- begin
- if CheckBox1.Checked then Chart1.DepthAxis.LabelStyle:=talText
- else Chart1.DepthAxis.LabelStyle:=talValue;
- end;
-
- procedure TSurfaceLabelsForm.Button1Click(Sender: TObject);
- begin
- EditChart(Self,Chart1);
- end;
-
- end.
-