Tchart分析报告

类别:Delphi 点击:0 评论:0 推荐:
1          Tchart分析报告 1.1      [概述]

   TChart是delphi里面一个标准的图形显示控件。它可以静态设计(at design time)也可以动态生成。

1.2      [继承关系]

   

TObject

TPersistent

TComponent

TControl

TCustomControl

TWedgetControl

TChart

TCustomPanel

1.3      [tips] 1.3.1            Pro Version支持Bezier , Contour , Radar 和  point3D 曲线 1.3.2            支持jpeg文件的导出 1.3.3            Chart中的Series 可以连接到Table , Query , RemoteDataset(其他数据集) 1.3.4            TChart里的series的active属性可以实现对已绘制图形的显示或者隐藏 1.3.5            在TChart中, tchartSeries是所有具体series的父类,没有画出什么来的,用一个具体的series类来创建就可以了,比如用TLineSeries、TPieSeries、 TPointSeries、 TPointSeries等等都行 1.3.6            TTeeFunction Component可以实现在同一个TChart里面,一个Serries对另一个Serries的统计

 

1.4      [问题极其使用技巧] 1.4.1            TChart中如何实现只有Y轴的放大与缩小功能?

设置BottomAxis或者LeftAxis的Automatic:=false并同时设置Minimum,Maximum属性

1.4.2            如何固定TChart中的坐标,不使TChart中的坐标跟随Series的变化而变化?

//设置底座标

  with myChart.BottomAxis do

  begin

    Automatic:=false;

    Minimum:=0;

    LabelStyle := talText;

  end;

  //设置左坐标

  with myChart.LeftAxis do

  begin

    Automatic:=false;

    Minimum:=0;

    Title.Angle:=270;

    Title.Font:=Self.Font;

    Title.Font.Charset:=ANSI_CHARSET;

    Title.Font.Name:='@宋体';

    Grid.Visible := False;

  end;

  //设置右坐标

  with myChart.RightAxis do

  begin

    Automatic:=false;

    Title.Font:=Self.Font;

    Title.Font.Charset:=ANSI_CHARSET;

    Title.Font.Name:='@宋体';

    Title.Caption:='累计百分比(%)';

    Maximum:=100;

    Minimum:=0;

  end;

1.4.3            如何删除一个图形中的一个点?

使用Series的delete 方法

1.4.4            如何修改一个点的X或者Y 值?

LineSeries1.YValue[3] := 27.1 ;

{In Bubble Series}

BubbleSeries1.RadiusValues.Value[ 8 ] := 8.1 ;

{In Pie Series}

PieSeries1.PieValues.Value[ 3 ] := 111 ;

1.4.5            如果横坐标是时间(日期),如何进行设置?

{First, you need to set the DateTime property to True in the desired X and/or Y values list.}

LineSeries1.XValues.DateTime := True ;

{Second, use the same above described methods, but give the values as Date, Time or DateTime values}

LineSeries1.AddXY( EncodeDate( 1996 , 1 , 23 ) , 25.4 , 'Barcelona' , clGreen );

1.4.6            如何在chart中画出的曲线某个点上标记出该点的值?

Series.Marks.Visible:=true;

Series.Marks.Style:=smsValue;

1.4.7            如何设置横轴或者纵轴的增长率?

Chart.BottomAxis.Increment := DataTimeStep[ dtOneHour ] ;

Chart.RightAxis.Increment := 1000;

1.4.8            如何对图象进行缩放?

TChart的ZoomRect或者ZoomPercent方法 (Pie图可能不支持缩放)

 

 

1.5      [TChart可以绘制的图形] 1.5.1            Line ( TLineSeries)

1.5.2            FastLine (TFastLineSeries) 相对Line来说,它损耗了某些属性从而来实现快速绘制 1.5.3            Bar (TBarSeries)

1.5.4            Horizontal bar (THorizBarSeries)

1.5.5            Area (TAreaSeries)

1.5.6            Point (TPointSeries)

1.5.7            Pie (TPieSeries)

1.5.8            Arrow (TArrowSeries)

1.5.9            Bubble (TBubbleSeries)

1.5.10         Gantt (TGanttSeries)

1.5.11         Sharp (TChartShape)

1.6      [TChart的实时绘制]

  实时绘制对机器性能要求比较高,因此我们在编程的时候要注意下面几个方面:

ü         使用2D图形

ü         是Chart尽可能包含少的点

ü         如果需要,可以移除(remove)chart的legend(?????)和Title

ü         使用默认的字体和字体大小

ü         使用FastLineSeries

ü         使用实体(solid)画笔和画刷格式

ü         尽量避免使用圆形和环行bar样式

ü         不要使用背景图片和渐变效果样式

ü         把Chart的BevelInner和BevelOUter属性设置为bcNone

ü         如果需要,把TChart的AxisVisible属性设置为False

ü         把BufferedDisplay设置为false可以加速chart的重绘

 

1.7      [Scrolling]

   TChart有4中scroll选择(AllowPanning属性),分别是 不允许Scroll ( pmNone) ; 水平Scroll (pmHorizontal) ; 垂直Scroll (pmVertical)  ;  水平和垂直Scroll (pmBoth)

Procedure Scroll(Const Offset:Double; CheckLimits:Boolean);

例子如下:

 Chart1.BottomAxis.Scroll(  1000, True );这段代码也等同于

With Chart1.BottomAxis do

Begin

 Automatic:=false;

 SetMinMax( Minimum+1000, Maximum+1000 );

    End;

 

 

1.8      [TChart中的全局变量]

ü         TeeScrollMouseButton := mbRight;设置鼠标右键为TChart滚动键(默认)

ü         TeeScrollKeyShift    := [ ssCtrl ]; 要按住Control键才可以使Scroll滚动

 

1.9      [TChartSerries使用技巧] 1.9.1            运行时候创建一个Serries, 三种方法:

1.Var MySeries : TBarSeries ;

MySeries := TBarSeries.Create( Self );

MySeries.ParentChart := Chart1 ;

            2.Chart1.AddSeries( TBarSeries.Create( Self ) );

                3.Var MyClass : TChartSeriesClass;

MyClass := TBarSeries ;

Chart1.AddSeries( MyClass.Create( Self ) );

1.9.2            获得TChart中的Serries数组,也有三种方法

1.MySeries := Chart1.SeriesList [ 0 ]

2.MySeries := Chart1.Series [ 0 ]

3.MySeries := Chart1 [ 0 ]

1.9.3            SerriesCount属性获得SeriesList中Series的个数 1.9.4            隐藏TChart中的Series有三种方法,但是效果不等价

1.  Series1.Active:=False; 仅仅隐藏,当设置为true的时候还可以显示出来

2.  Series1.ParentChart:=nil ; 隐藏,重新设置ParentChart为TChart时候可以显示

3.  Series1.Free; 删除了Series. 不可以恢复

1.9.5            TChart中的数据排序

    With Series1 do

begin

    YValues.Order:=loAscending;

    YValues.Sort;

    Repaint;

end;

Ø         定位一个点(Loacate a point)

Series1.XValues.Locate(123);

Ø         XValue和YValue都拥有的属性Total , TotalABS , MaxValue , MinValue

 

 

 

 

本文地址:http://com.8s8s.com/it/it4774.htm