如何在chart上显示鼠标处的曲线坐标?
我做了一个图表想鼠标放到曲线上就能显示该点坐标
要怎么做呢

解决方案 »

  1.   

    没明白是鼠标的坐标值还是鼠标在chart上的横坐标数据和纵坐标数据值
      

  2.   

    看看安装程序自带的demo,Teechart里面有个feature项,研究一下吧
      

  3.   

    //以下是BCB代码:void __fastcall TBU_CIDeterFrm::Chart1MouseMove(TObject *Sender,
          TShiftState Shift, int X, int Y)
    {
     int tmpX, intY;
     POINT pXY;
     pXY.x=X-Chart1->Width3D;
     pXY.y=Y+Chart1->Height3D;
     if (PtInRect(&(Chart1->ChartRect), pXY))
        {
        Chart1->Series[0]->GetCursorValues(tmpX,tmpY); 
        }
    }
      

  4.   

    procedure FormCreate(Sender: TObject);
    begin
      LineSeries1.FillSampleValues(30);  { <-- some random values }
      OldX:=-1;                          { initialize variables }
      CrossHairColor:=clYellow;
      CrossHairStyle:=psSolid;
    end;procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);  { This procedure draws the crosshair lines }
      Procedure DrawCross(AX,AY:Integer);
      begin
        With Chart1,Canvas do
        begin
          Pen.Color:=CrossHairColor;
          Pen.Style:=CrossHairStyle;
          Pen.Mode:=pmXor;
          Pen.Width:=1;
          MoveTo(ax,ChartRect.Top-Height3D);
          LineTo(ax,ChartRect.Bottom-Height3D);
          MoveTo(ChartRect.Left+Width3D,ay);
          LineTo(ChartRect.Right+Width3D,ay);
        end;
      end;Var tmpX,tmpY:Double;
    begin
      if (OldX<>-1) then
      begin
        DrawCross(OldX,OldY);  { draw old crosshair }
        OldX:=-1;
      end;  { check if mouse is inside Chart rectangle }
      if PtInRect( Chart1.ChartRect, Point(X-Chart1.Width3D,Y+Chart1.Height3D)  ) then
      begin
        DrawCross(x,y);  { draw crosshair at current position }
        { store old position }
        OldX:=x;
        OldY:=y;
        { set label text }
        With LineSeries1 do
        begin
          GetCursorValues(tmpX,tmpY);  { <-- get values under mouse cursor }
          Label1.Caption:=GetVertAxis.LabelValue(tmpY)+
                          ' '+
                          GetHorizAxis.LabelValue(tmpX);
        end;
      end;
    end;procedure chart1AfterDrawValues(Sender: TObject);
    begin
      OldX:=-1;  { Reset old mouse position }
    end;
    ////////////////////////////
    LineSeries1: TLineSeries;
      

  5.   

    X值:chart1.Series[0].XLabel[round(chart1.Series[0].XScreenToValue(x))]
    Y值:(round(chart1.Series[0].YScreenToValue(y)*1000)/1000)