请教用DBChart画直线的问题(30分)

  • 主题发起人 主题发起人 jianghui
  • 开始时间 开始时间
J

jianghui

Unregistered / Unconfirmed
GUEST, unregistred user!
我用DBChart中的Line画了几条投资曲线,其中X轴为时间,Y轴为投资额,现在我需要在同
一张图中X轴、Y轴上再分别画一条直线,我不知道该怎样定义series的X、Y值,请大虾指正。
我已经定义了2个series(类型为Line):
DBchart1.Series[0].DataSource :=query1;
DBchart1.Series[0].YValues.ValueSource:='tzjd';
DBchart1.Series[0].xlabelssource:='stadate';

DBchart1.Series[1].DataSource :=query1;
DBchart1.Series[1].YValues.ValueSource:='htj';
DBchart1.Series[1].xlabelssource:='stadate';
 
给你我作的一个类似程序
procedure Drawhorilines(AChart:TChart;tmpYCenterValue:Double);
Var YPosition:Longint;
begin
With AChart,Canvas do
Begin
{ then calculate the Screen Pixel coordinate of the above value }

YPosition:=LeftAxis.CalcYPosValue(tmpYCenterValue);

{ change pen and draw the line }
Pen.Width:=3;
Pen.Style:=psSolid;
Pen.Color:=clBlack;
MoveTo(ChartRect.Left,YPosition);
LineTo(ChartRect.Right,YPosition);
//LineTo(ChartRect.Right+Width3D,YPosition-Height3D); {if view3D is true}

{ change font and draw some text above the line }

Font.Name:='Arial';

{ VERY IMPORTANT !!!!!! }
{ THIS IS NECESSARY IF YOU'RE GOING TO PRINT !!!! }
{ IT MAKES FONT SIZES TO WORK FINE BOTH AT SCREEN AND PRINTER. }

Font.Height:=-16; { <-- express font size in "Height", NOT "Size" }

Font.Color:=clBlack;
Font.Style:=[fsBold];

{ Set transparent background... }
Brush.Style:=bsClear;

{ Output some text... }
TextOut(ChartRect.left,
YPosition-18,
FloatToStr(tmpYCenterValue));
end;
end;

procedure Drawvertlines(AChart:TChart; tmpXCenterValue:Double);
var XPosition:Longint;
begin
With AChart,Canvas do
Begin
XPosition:=bottomAxis.CalcXPosValue(tmpXCenterValue);
Pen.Width:=3;
Pen.Style:=psSolid;
Pen.Color:=clBlack;
Moveto(XPosition,chartrect.bottom);
Lineto(XPosition,chartrect.top);
LineTo(XPosition-width3D,chartrect.top+height3D); {if view3D is true}
Font.Name:='Arial';
Font.Height:=-16;
Font.Color:=clBlack;
Font.Style:=[fsBold];
Brush.Style:=bsClear;
TextOut(XPosition-12,chartrect.top-18,floattostr(tmpXcentervalue));
end;
end; //tmpXcentervalue,tmpYcentervalue为你要画线的chart中的坐标值,Achart为目标chart
 
接受答案了.
 

Similar threads

后退
顶部