(圖片地址:www.bioringmed.com\download\bp-001.gif)
橫坐標顯示時間,取的是數據庫中的Time字段,這個字段里放的只是時間,沒有日期。
縱坐標顯示血壓,取的是數據庫中的Pressure(血壓)字段,整數型的。
如圖所示,DBChart 的橫軸設置為Time字段, 縱軸設置為Pressure字段,一切都正常,
現在想畫一條如圖所示的綠色的橫線,起點和終點根據Time來定,比如說起點為16:00:00,
終點為22:00:00,(圖中綠色的圓圈)。縱坐標比如就用60吧。
問題是:我要怎樣找到16:00:00這個時刻所對應的在DBChart上的橫坐標值,即綠色橫線的
起點的橫坐標。 和22:00:00這個時刻所對應的,即綠色橫線終點的橫坐標值。
我試了很多函數都不行,也不知道這些函具體什么意思,比如下面的這些,請問誰能幫忙告訴我
該怎么辦?
GetVertAxis.LabelValue
BottomAxis.CalcXPosValue
bottomaxis.LabelValue
MoveTo(BottomAxis.CalcXPosValue(StrToFloat(bottomaxis.LabelValue(HourOf(NightStart)))),YPosition);
LineTo(BottomAxis.CalcXPosValue(StrToFloat(bottomaxis.LabelValue(HourOf(NightStart)))),ChartRect.Bottom);
5 个解决方案
終於完成了,我用了半個小時。
procedure TfrmMain.DrawLine;
var
YPosition1,YPosition2,X1:Integer ;
begin
with dbc_waterchar,Canvas do
begin
Title.Text.Text:='檢測分析曲線';//+'<<'+datetostr(now)+'>>';
Pen.Width:=3;
Pen.Style:=psSolid;
Pen.Color:=clRed;
X1 := LeftAxis.CalcyPosValue(20);//取得此線距圖形頂部的距離.
YPosition1:=BottomAxis.CalcXPosValue(Encodetime(6,00,00,00));
YPosition2:=BottomAxis.CalcXPosValue(Encodetime(12,00,00,00));
MoveTo(YPosition1,x1);
LineTo(YPosition2,x1);
end;
end;
還有一點要注意,要在Tdbchar的onAfterdraw中引用上面的過程,這樣所畫的線才不會丟失.
To saien:
開始用你的方法不行,畫出來的線很短,明顯的坐標不對, 沒有以橫軸上的時間為准,
我檢查了一下,Series1...Series4的屬性這樣設置的,如圖:www.bioringmed.com\download\bp-002.bmp
后來我改成了這樣:www.bioringmed.com\download\bp-003.bmp
畫線就畫對了,如圖:www.bioringmed.com\download\bp-004.bmp
但是橫軸不能顯示時間字段了,而顯示的是實數值,這又該怎么辦呢?
怎么讓橫軸的Label顯示數據表的Time字段?
procedure TfrmMain.DrawLine;
var
YPosition1,YPosition2,X1:Integer ;
begin
with dbc_waterchar,Canvas do
begin
Title.Text.Text:='檢測分析曲線';//+'<<'+datetostr(now)+'>>';
Pen.Width:=3;
Pen.Style:=psSolid;
Pen.Color:=clRed;
X1 := LeftAxis.CalcyPosValue(120);//取得此線距圖形頂部的距離.
YPosition1:=BottomAxis.CalcXPosValue(Encodetime(6,00,00,00));//"6,00,00,00"表示時間6:00:00.
YPosition2:=BottomAxis.CalcXPosValue(Encodetime(12,00,00,00));
MoveTo(YPosition1,x1);
LineTo(YPosition2,x1);
end;
end;
//說明:上面"6,00,00,00"表示時間6:00:00.