(图片地址: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);

解决方案 »

  1.   

    终于完成了,我用了半个小时。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;
      

  2.   

    还有一点要注意,要在Tdbchar的onAfterdraw中引用上面的过程,这样所画的线才不会丢失.
      

  3.   

    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字段?
      

  4.   

    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.