TeeChart使用心得(一)_teechart使用心得一
TeeChart使用心得(一)由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“teechart使用心得一”。
慧都控件网
TeeChart使用心得
(一)TeeChart是Delphi里面一个标准的图形显示控件。它可以静态设计(at design time)也可以动态生成。下面是我在使用过程中的一些心得体会,比较杂,但也许对你有用。TeeChart的继承关系
TObject TPersistent TComponent TControl TCustomControl TWedgetControl TChart TCustomPanel TeeChart常见问题及使用技巧
1、TChart中如何实现只有Y轴的放大与缩小功能?
设置BottomAxis或者LeftAxis的Automatic:=false并同时设置Minimum,Maximum属性
2、如何固定TChart中的坐标,不使TChart中的坐标跟随Series的变化而变化? 1 //设置底座标with myChart.BottomAxis do 3 begin 4 Automatic:=false;5 Minimum:=0;6 LabelStyle := talText;7 end;8 //设置左坐标with myChart.LeftAxis do 10 begin 11 Automatic:=false;12 Minimum:=0;13 Title.Angle:=270;14 Title.Font:=Self.Font;15 Title.Font.Charset:=ANSI_CHARSET;16 Title.Font.Name:='@宋体';17 Grid.Visible := False;18 end;
慧都控件网
慧都控件网//设置右坐标 20 with myChart.RightAxis do 21 begin 22 Automatic:=false;23 Title.Font:=Self.Font;24 Title.Font.Charset:=ANSI_CHARSET;25 Title.Font.Name:='@宋体';26 Title.Caption:='累计百分比(%)';27 Maximum:=100;28 Minimum:=0;29 end;
3、如何删除一个图形中的一个点?
使用Series的delete方法
4、如何修改一个点的X或者Y值?LineSeries1.YValue[3] := 27.1;2 {In Bubble Series} 3 BubbleSeries1.RadiusValues.Value[ 8 ] := 8.1;4 {In Pie Series} 5 PieSeries1.PieValues.Value[ 3 ] := 111;
5、如果横坐标是时间(日期),如何进行设置?
{First, you need to set the DateTime property to True in the desired X and/or Y values list.} 1 LineSeries1.XValues.DateTime := True;2 {Second, use the same above described methods, but give the values as 3 Date, Time or DateTime values} 4 LineSeries1.AddXY(EncodeDate(1996 , 1 , 23), 25.4 , 'Barcelona' , clGreen);
6、如何在chart中画出的曲线某个点上标记出该点的值? 1 Series.Marks.Visible:=true;2 Series.Marks.Style:=smsValue;
7、如何设置横轴或者纵轴的增长率?Chart.BottomAxis.Increment := DataTimeStep[ dtOneHour ];2 Chart.RightAxis.Increment := 1000;
8、如何对图象进行缩放?
慧都控件网
慧都控件网
TChart的ZoomRect或者ZoomPercent方法(Pie图可能不支持缩放)
TeeChart可以绘制的图形:
Line(TLineSeries)FastLine(TFastLineSeries)相对Line来说,它损耗了某些属性从而来实现快速绘制 Bar(TBarSeries)Horizontal bar(THorizBarSeries)Area(TAreaSeries)Point(TPointSeries)Pie(TPieSeries)Arrow(TArrowSeries)Bubble(TBubbleSeries)Gantt(TGanttSeries)Sharp(TChartShape)TeeChart的实时绘制
实时绘制对机器性能要求比较高,因此我们在编程的时候要注意下面几个方面:
使用2D图形
是Chart尽可能包含少的点
如果需要,可以移除(remove)chart的legend(?)和Title 使用默认的字体和字体大小 使用FastLineSeries 使用实体(solid)画笔和画刷格式 尽量避免使用圆形和环行bar样式 不要使用背景图片和渐变效果样式
把Chart的BevelInner和BevelOUter属性设置为bcNone 如果需要,把TChart的AxisVisible属性设置为False 把BufferedDisplay设置为false可以加速chart的重绘
滚动
TChart有4种scroll选择(AllowPanning属性),分别是 不允许Scroll(pmNone);水平Scroll(pmHorizontal);垂直Scroll(pmVertical);水平和垂直Scroll(pmBoth)Procedure Scroll(ConstOffset:Double;CheckLimits:Boolean);例子如下:Chart1.BottomAxis.Scroll(1000, True);这段代码也等同于
慧都控件网
慧都控件网With Chart1.BottomAxis do 2 Begin 3 Automatic:=false;4 SetMinMax(Minimum+1000, Maximum+1000);5 End;
慧都控件网