请问如何在Tchart中绘制带有一定弧度的曲线,两点确定一条直线,我想知道怎样在两点间绘制一条带弧度的曲线

解决方案 »

  1.   

    好像不能直接画,你可以参考DELPHI  demo中的例子画,例子中画的是直线,你用ELLIPSE(X',Y',X2,Y2)就可以画圆弧了
      

  2.   

    参考一下吧:
    procedure TDrawForm.FormCreate(Sender: TObject);
    begin
      Percent:=50;  { <-- used for this demo only }
      LineSeries1.FillSampleValues(20);
    end;procedure TDrawForm.LineSeries1BeforeDrawValues(Sender: TObject);
    Const
       MyColors:array[1..5] of TColor=
        ( clNavy,
          clGreen,
          clYellow,
          clRed,
          $00000080 { very red }
          );
    var t,partial:Longint;
        tmpRect:TRect;
        YPosition:Longint;
        tmpYCenterValue:Double;
    begin
      With Chart1 do
      Begin
        { we will divide the total chart width by 5 }
        tmpRect:=ChartRect;
        tmpRect.Right:=tmpRect.Left;
        partial:=ChartWidth div 5;    { change the brush style }
        Canvas.Brush.Style:=bsDiagCross;
        Canvas.Pen.Style:=psClear;    { for each section, fill with a specific color }
        for t:=1 to 5 do
        Begin
          { adjust the rectangle dimension }
          tmpRect.Right :=tmpRect.Right+partial+1 ;      { set the brush color }
          Canvas.Brush.Color:=MyColors[t];      { paint !!! }
          With tmpRect do
            Canvas.Rectangle( Left+Width3D,Top-Height3D,Right+Width3D,Bottom-Height3D );      { adjust rectangle }
          tmpRect.Left:=tmpRect.Right;
        end;    { first calculate the middle vertical value (based on LineSeries points) }
        With LineSeries1.YValues do
             tmpYCenterValue:=MinValue+Percent*(MaxValue-MinValue)/100.0;    { then calculate the Screen Pixel coordinate of the above value }
        YPosition:=LeftAxis.CalcYPosValue(tmpYCenterValue);    With Canvas do
        begin
          { change pen and draw the line }
          Pen.Width:=3;
          Pen.Style:=psSolid;
          Pen.Color:=clRed;
          MoveTo(ChartRect.Left,YPosition);
          LineTo(ChartRect.Left+Width3D,YPosition-Height3D);
          LineTo(ChartRect.Right+Width3D,YPosition-Height3D);
        end;
      end;
    end;procedure TDrawForm.LineSeries1AfterDrawValues(Sender: TObject);
    Var YPosition:Longint;
        tmpYCenterValue:Double;
    begin
      With Chart1,Canvas do
      Begin
        { first calculate the middle vertical value (based on LineSeries points) }
        With LineSeries1.YValues do
             tmpYCenterValue:=MinValue+Percent*(MaxValue-MinValue)/100.0;    { 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:=clRed;
        MoveTo(ChartRect.Left,YPosition);
        LineTo(ChartRect.Right,YPosition);
        LineTo(ChartRect.Right+Width3D,YPosition-Height3D);    { 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:=-24;   { <-- express font size in "Height", NOT "Size" }    Font.Color:=clYellow;
        Font.Style:=[fsBold];    { Set transparent background... }
        Brush.Style:=bsClear;    { Output some text... }
        TextOut( ChartRect.Left+20,
                 YPosition-24 ,
                 'This is '+FloatToStr(tmpYCenterValue));
      end;
    end;
      

  3.   

    wudi_1982(简单就是美): 我说的是象股票曲线那样,绘制出的曲线非常平滑,不出现大的突起,平稳的升起,平稳的落下,因该怎样处理呢
      

  4.   

    你在TCHART上看到的曲线,因为两个点之间的距离比较远,所以看起来是直线,不好看,你把距离拉近了,就可以了。我认为你可以在paintbox上自己画,而不用tchart,这样控制起来方便一些。