📄 teetoolsgallerydemos.pas
字号:
{**********************************************}
{ TeeChart Tools Gallery Demos }
{ Copyright (c) 2006-2007 by David Berneda }
{**********************************************}
unit TeeToolsGalleryDemos;
{$I TeeDefs.inc}
interface
implementation
uses
Classes,
{$IFDEF D6}
Variants,
{$ENDIF}
{$IFDEF CLX}
QControls, QGraphics, QStdCtrls, QDialogs, QButtons,
{$ELSE}
Controls, Graphics, StdCtrls, Buttons, Dialogs,
{$ENDIF}
Math,
TeCanvas,
TeeProcs, TeeConst, TeeProCo, TeEngine, Chart, Series,
// EditChar,
TeeToolsGallery, TeeTools, TeeThemes, TeeGanttTool, GanttCh, TeePieTool,
TeeBrushDlg, TeeExtraLegendTool, TeeSurfaceTool, TeeSurfa, TeeDragPoint,
TeeAntiAlias, TeeSeriesStats, TeeSeriesBandTool, TeeSelectorTool,
TeeLighting, TeeIsoSurface, TeePageNumTool, TeeDataTableTool,
TeeTransposeTool, TeeTransposeSeries, TeeLegendScrollBar, TeeFrameTool,
TeeLegendPalette, TeeSeriesRegion, TeeBannerTool, TeeText3D,
{$IFDEF CLR}
System.Reflection,
{$ELSE}
TeeVideo, TeeVideoPlayer,
{$ENDIF}
TeeMagnifyTool, TeeFaderTool, TeeSubChart, TeeLinkTool, TeeFibonacci,
CandleCh;
type
TToolDemos=class
private
procedure ChartDblClick(Sender: TObject);
procedure CreateGallery(Gallery:TTeeToolsGallery);
procedure Animation(Sender:TObject);
procedure FadeChart(Sender:TObject);
procedure FullScreen(Sender:TObject);
procedure OutlineChecked(Sender:TObject);
{$IFNDEF CLR}
procedure PlayChartVideo(Sender:TObject);
procedure RecordChartVideo(Sender:TObject);
procedure StepAnimation(Sender:TSeriesAnimationTool; Step:Integer);
procedure StopRecordVideo(Sender:TObject);
{$ENDIF}
procedure Transpose3DSeries(Sender:TObject);
procedure TransposeSeries(Sender:TObject);
end;
TControlAccess=class(TControl)
{$IFDEF CLR}
public
property Caption;
property OnClick;
end
{$ENDIF}
;
const
TeeMsg_RecordVideo = '&Record Video !';
procedure TToolDemos.ChartDblClick(Sender: TObject);
begin
// EditChartTool(nil,(Sender as TCustomChart).Tools[0]);
// (Sender as TCustomChart).CancelMouse:=True;
end;
{$IFDEF CLX}
type
TControlClass=class of TControl;
{$ENDIF}
procedure TToolDemos.CreateGallery(Gallery:TTeeToolsGallery);
function CreateChart(ATool:TTeeCustomToolClass;
const ATitle:String='';
const ASeries:TChartSeriesClass=nil):TChart;
var c : TChart;
begin
c:=TChart.Create(Gallery);
c.Align:=alClient;
c.Parent:=Gallery.PanelDemos;
if ASeries=nil then
c.AddSeries(TLineSeries).FillSampleValues
else
c.AddSeries(ASeries).FillSampleValues;
c.Legend.Hide;
c.Zoom.Allow:=False;
c.AllowPanning:=pmNone;
c.Title.Text.Text:=ATitle;
with c.Title.Font.Shadow do
begin
Visible:=True;
Size:=3;
Color:=clDkGray;
SmoothBlur:=2;
end;
ApplyChartTheme(TWebTheme,c);
if ATool<>nil then
c.Tools.Add(ATool);
c.OnDblClick:=ChartDblClick;
c.Shadow.Visible:=True;
c.Shadow.Color:=clDkGray;
c.Shadow.Size:=8;
result:=c;
end;
var
tmpY : Double;
tmpRange : Integer;
procedure RandomColorLine(ATool:TTeeCustomTool);
begin
with (ATool as TColorLineTool) do
begin
Axis:=ParentChart.Axes.Left;
Value:=tmpY+Random(tmpRange);
Pen.Color:=TRandomTheme.RandomColor;
Pen.Width:=2;
end;
end;
procedure RandomColorBand(ATool:TTeeCustomTool);
begin
with (ATool as TColorBandTool) do
begin
Axis:=ParentChart.Axes.Left;
StartValue:=tmpY+Random(tmpRange);
EndValue:=StartValue+Random(tmpRange);
tmpY:=EndValue;
Color:=TRandomTheme.RandomColor;
ResizeEnd:=True;
ResizeStart:=True;
end;
end;
function AddControl(AClass:TControlClass; Chart:TCustomChart;
const AText:String):TControl;
begin
result:=AClass.Create(Gallery.PanelDemos);
result.Left:=20;
result.Top:=Chart.Height-50;
result.Parent:=Chart;
{$IFDEF CLR}
result.SetText(AText);
{$ELSE}
TControlAccess(result).Caption:=AText;
{$ENDIF}
result.Width:=Max(result.Width,6*Length(AText));
result.Tag:={$IFDEF CLR}Variant{$ELSE}Integer{$ENDIF}(Chart.Tools[0]);
end;
function AddButton(Chart:TCustomChart;
const AText:String; AEvent:TNotifyEvent):TButton;
begin
result:=AddControl(TButton,Chart,AText) as TButton;
result.OnClick:=AEvent;
end;
function AddBitButton(Chart:TCustomChart; Element:TCustomChartElement;
const AText:String; AEvent:TNotifyEvent):TBitBtn;
var tmpBitmap : TBitmap;
begin
result:=AddControl(TBitBtn,Chart,AText) as TBitBtn;
result.OnClick:=AEvent;
tmpBitmap:=TBitmap.Create;
try
TeeGetBitmapEditor(Element,tmpBitmap);
result.Width:=result.Width+tmpBitmap.Width+2;
result.NumGlyphs:=1;
result.Glyph:=tmpBitmap;
finally
tmpBitmap.Free;
end;
end;
function AddCheck(Chart:TCustomChart;
const AText:String; AEvent:TNotifyEvent):TCheckBox;
begin
result:=AddControl(TCheckBox,Chart,'') as TCheckBox;
result.OnClick:=AEvent;
result.Width:=16;
with TLabel.Create(Gallery.PanelDemos) do
begin
Transparent:=True;
Caption:=AText;
FocusControl:=result;
Font.Style:=[fsBold];
Left:=result.Left+2;
Top:=result.Top+2;
Parent:=result.Parent;
AutoSize:=True;
end;
end;
var tmp : TTeeCustomToolClass;
tmpS : TStringList;
c : TChart;
b : TBannerTool;
begin
tmp:=Gallery.SelectedTool;
if tmp=TClipSeriesTool then
with CreateChart(tmp,'Drag chart to scroll Series'+TeeLineSeparator+'that does not display outside axes') do
begin
View3D:=False;
AllowPanning:=pmBoth;
Axes.Left.StartPosition:=20;
Axes.Left.EndPosition:=80;
Axes.Bottom.StartPosition:=25;
Axes.Bottom.EndPosition:=70;
(Tools[0] as TClipSeriesTool).Series:=Series[0];
end
else
if tmp=TCursorTool then
with CreateChart(tmp,'Click and drag cursor lines') do
begin
with (Tools[0] as TCursorTool) do
begin
ScopeStyle:=scsCamera;
ScopeSize:=20;
Style:=cssScope;
end;
end
else
if tmp=TAnnotationTool then
with CreateChart(tmp) do
begin
(Tools[0] as TAnnotationTool).Text:='This is an Annotation tool';
Tools.Add(tmp);
with (Tools[1] as TAnnotationTool) do
begin
Text:='Another Annotation';
Left:=150;
Top:=80;
Shape.Font.Size:=18;
Shape.Gradient.Visible:=True;
end;
end
else
if tmp=TRotateTool then
begin
c:=CreateChart(tmp,'Click and drag to rotate');
with c do
begin
(Tools[0] as TRotateTool).Inertia:=75;
View3DOptions.Orthogonal:=False;
View3DOptions.Perspective:=100;
Chart3DPercent:=75;
end;
AddCheck(c,TeeMsg_Outline,OutlineChecked).Left:=4;
end
else
if tmp=TDragMarksTool then
with CreateChart(tmp,'Click Series Marks to drag') do
begin
Series[0].FillSampleValues(5);
Series[0].Marks.Show;
Series[0].Marks.Font.Size:=14;
Series[0].Marks.Callout.Arrow.Color:=clBlack;
(Tools[0] as TDragMarksTool).Series:=Series[0];
Axes.Left.MinimumOffset:=20;
Axes.Left.MaximumOffset:=20;
Axes.Bottom.MinimumOffset:=20;
Axes.Bottom.MaximumOffset:=20;
end
else
if tmp=TDrawLineTool then
with CreateChart(tmp,'Click and drag to draw lines') do
begin
with Series[0].MandatoryValueList do
tmpY:=(MinValue+MaxValue)*0.5;
with (Tools[0] as TDrawLineTool) do
Selected:=Lines.AddLine(1.5,tmpY,2.8,tmpY-tmpY*0.5);
end
else
if tmp=TChartImageTool then
with CreateChart(tmp,'Drag chart to scroll axes and image') do
begin
View3D:=False;
Series[0].Color:=clGreen;
Series[0].Pen.Width:=4;
AllowPanning:=pmBoth;
Zoom.Allow:=True;
Zoom.Brush.Style:=bsSolid; // ??
(Tools[0] as TChartImageTool).Series:=Series[0];
Tools[0].Pen.Show;
with TBrushDialog.Create(nil) do
try
(Tools[0] as TChartImageTool).Picture.Graphic:=ImageFire.Picture.Graphic;
finally
Free;
end;
end
else
if tmp=TNearestTool then
with CreateChart(tmp,'Move the mouse over Series points') do
begin
Series[0].FillSampleValues(8);
(Series[0] as TLineSeries).Pointer.Show;
(Tools[0] as TNearestTool).Series:=Series[0];
with (Series[0] as TLineSeries).Pointer.Shadow do
begin
Visible:=True;
Color:=clDkGray;
HorizSize:=8;
VertSize:=4;
end;
with (Tools[0] as TNearestTool).Pen do
begin
Color:=clBlue;
Width:=2;
end;
end
else
if tmp=TSeriesAnimationTool then
begin
c:=CreateChart(tmp,'Series points display animated',TBarSeries);
with c do
begin
Series[0].ColorEachPoint:=True;
(Series[0] as TBarSeries).Shadow.Visible:=True;
(Series[0] as TBarSeries).Shadow.Size:=5;
(Tools[0] as TSeriesAnimationTool).Series:=Series[0];
with (Tools[0] as TSeriesAnimationTool) do
begin
//Loop:=salCircular;
StartValue:=0;
StartAtMin:=False;
Steps:=100;
DrawEvery:=1;
end;
end;
AddButton(c,'&Animate !',Animation);
end
else
if tmp=TMarksTipTool then
with CreateChart(tmp,'Move mouse over Series points to display hints') do
begin
Series[0].FillSampleValues(5);
(Series[0] as TLineSeries).Pointer.Show;
(Tools[0] as TMarksTipTool).Series:=Series[0];
(Tools[0] as TMarksTipTool).MouseAction:=mtmMove;
Series[0].Cursor:=crHandPoint;
Axes.Bottom.MinimumOffset:=20;
Axes.Bottom.MaximumOffset:=20;
end
else
if tmp=TColorLineTool then
with CreateChart(tmp,'Several Color lines displayed'+TeeLineSeparator+'at random positions') do
begin
tmpY:=Series[0].MandatoryValueList.MinValue;
tmpRange:=Round(Series[0].MandatoryValueList.Range);
RandomColorLine(Tools[0]);
RandomColorLine(Tools.Add(tmp));
RandomColorLine(Tools.Add(tmp));
end
else
if tmp=TColorBandTool then
with CreateChart(tmp,'Color bands to fill axes background') do
begin
View3D:=False;
tmpY:=Series[0].MandatoryValueList.MinValue;
tmpRange:=Round(Series[0].MandatoryValueList.Range*0.2);
RandomColorBand(Tools[0]);
RandomColorBand(Tools.Add(tmp));
RandomColorBand(Tools.Add(tmp));
end
else
if tmp=TGridBandTool then
with CreateChart(tmp,'Two bands fill axes grid lines space') do
begin
(Tools[0] as TGridBandTool).Axis:=Axes.Left;
(Tools[0] as TGridBandTool).Band1.Color:=TRandomTheme.RandomColor;
(Tools[0] as TGridBandTool).Band2.Color:=TRandomTheme.RandomColor;
end
else
if tmp=TAxisArrowTool then
with CreateChart(tmp,'Click axes arrow to scroll') do
begin
View3D:=False;
(Tools[0] as TAxisArrowTool).HeadWidth:=30;
(Tools[0] as TAxisArrowTool).Length:=60;
(Tools[0] as TAxisArrowTool).Axis:=Axes.Bottom;
end
else
if tmp=TAxisScrollTool then
with CreateChart(tmp,'Drag axes to scroll') do
begin
View3D:=False;
(Tools[0] as TAxisScrollTool).Axis:=Axes.Left;
(Tools.Add(tmp) as TAxisScrollTool).Axis:=Axes.Bottom;
end
else
if tmp=TRectangleTool then
with CreateChart(tmp,'Annotations that can be'+TeeLineSeparator+'dragged and resized') do
begin
with (Tools[0] as TRectangleTool) do
begin
AutoSize:=True;
Text:='Drag and'+TeeLineSeparator+'resize me ';
Shape.Color:=clRed;
Shape.Font.Size:=16;
Shape.Transparency:=30;
Left:=80;
Top:=90;
end;
end
else
if tmp=TSurfaceNearestTool then
with CreateChart(tmp,'Move mouse over Surface to highlight cells',TSurfaceSeries) do
begin
View3DOptions.Orthogonal:=False;
View3DOptions.Perspective:=100;
Chart3DPercent:=75;
View3DOptions.Zoom:=75;
(Series[0] as TSurfaceSeries).HideCells:=True;
// (Series[0] as TSurfaceSeries).Palette. ??
Series[0].FillSampleValues(20);
(Tools[0] as TSurfaceNearestTool).Series:=Series[0];
tmp:=TRotateTool;
Tools.Add(tmp);
Walls.Left.Hide;
Walls.Back.Hide;
end
else
if tmp=TDragPointTool then
with CreateChart(tmp,'Click and drag Series points',TPointSeries) do
begin
Series[0].FillSampleValues(10);
Series[0].ColorEachPoint:=True;
Series[0].Cursor:=crHandPoint;
(Tools[0] as TDragPointTool).Series:=Series[0];
with (Series[0] as TPointSeries).Pointer.Shadow do
begin
Visible:=True;
Size:=6;
end;
end
else
if tmp=TExtraLegendTool then
with CreateChart(tmp,'Show additional Legend panels',TBarSeries) do
begin
AddSeries(TBarSeries).FillSampleValues;
Legend.Show;
Legend.Title.Caption:=TeeMsg_Legend;
(Tools[0] as TExtraLegendTool).Series:=Series[1];
(Tools[0] as TExtraLegendTool).Legend.Title.Caption:='Extra Legend';
(Tools[0] as TExtraLegendTool).Legend.Left:=Width-100;
(Tools[0] as TExtraLegendTool).Legend.Top:=100;
end
else
if tmp=TGanttTool then
with CreateChart(tmp,'Click Gantt bars to drag and resize',TGanttSeries) do
begin
View3D:=False;
Series[0].FillSampleValues(10);
with (Series[0] as TGanttSeries).Pointer do
begin
VertSize:=10;
Shadow.Visible:=True;
end;
(Tools[0] as TGanttTool).Series:=Series[0];
end
else
if tmp=TPieTool then
with CreateChart(tmp,'Move mouse over Pie slices',TPieSeries) do
begin
Chart3DPercent:=70;
(Tools[0] as TPieTool).Series:=Series[0];
Series[0].Pen.Color:=clDkGray;
Series[0].Pen.Width:=3;
with (Series[0] as TPieSeries).Shadow do
begin
Size:=20;
Visible:=True;
end;
//tmp:=TAntiAliasTool;
//Tools.Add(tmp);
end
else
if tmp=TSeriesStatsTool then
with CreateChart(tmp,'Statistics of Series data') do
begin
(Tools[0] as TSeriesStatsTool).Series:=Series[0];
tmp:=TAnnotationTool;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -