我想用TCHAR控件画一圆柄图,由于对TCHAT不熟求TCHART使用例子。或TDBCHART,不用太复杂的,解决问题就行我要解决的问题很简单:就是把七种数据按各自的百分比显示成原柄图(各个部分用不同颜色填充)
  

解决方案 »

  1.   

    4      [问题极其使用技巧]
    1.4.1            TChart中如何实现只有Y轴的放大与缩小功能?
    设置BottomAxis或者LeftAxis的Automatic:=false并同时设置Minimum,Maximum属性1.4.2            如何固定TChart中的坐标,不使TChart中的坐标跟随Series的变化而变化?
    //设置底座标  with myChart.BottomAxis do  begin    Automatic:=false;    Minimum:=0;    LabelStyle := talText;  end;  //设置左坐标  with myChart.LeftAxis do  begin    Automatic:=false;    Minimum:=0;    Title.Angle:=270;    Title.Font:=Self.Font;    Title.Font.Charset:=ANSI_CHARSET;    Title.Font.Name:='@宋体';    Grid.Visible := False;  end;  //设置右坐标  with myChart.RightAxis do  begin    Automatic:=false;    Title.Font:=Self.Font;    Title.Font.Charset:=ANSI_CHARSET;    Title.Font.Name:='@宋体';    Title.Caption:='累计百分比(%)';    Maximum:=100;    Minimum:=0;  end;1.4.3            如何删除一个图形中的一个点?
    使用Series的delete 方法1.4.4            如何修改一个点的X或者Y 值?
    LineSeries1.YValue[3] := 27.1 ;{In Bubble Series}BubbleSeries1.RadiusValues.Value[ 8 ] := 8.1 ;{In Pie Series}PieSeries1.PieValues.Value[ 3 ] := 111 ;1.4.5            如果横坐标是时间(日期),如何进行设置?
    {First, you need to set the DateTime property to True in the desired X and/or Y values list.}LineSeries1.XValues.DateTime := True ;{Second, use the same above described methods, but give the values as Date, Time or DateTime values}LineSeries1.AddXY( EncodeDate( 1996 , 1 , 23 ) , 25.4 , 'Barcelona' , clGreen );1.4.6            如何在chart中画出的曲线某个点上标记出该点的值?
    Series.Marks.Visible:=true;Series.Marks.Style:=smsValue;1.4.7            如何设置横轴或者纵轴的增长率?
    Chart.BottomAxis.Increment := DataTimeStep[ dtOneHour ] ;Chart.RightAxis.Increment := 1000;1.4.8            如何对图象进行缩放?
    TChart的ZoomRect或者ZoomPercent方法 (Pie图可能不支持缩放) 
      

  2.   

    TChart使用方法 1、问题:通过Addxy方法给TChart添加标记(Mark)时,发现在TChart的横坐标会随着Mark而变化,后来发现通过以下方法可避免这种情况:双击TChart,点击Axis-> top or bottom ->labels,在styles中将labels的形式改为Value即可! 2、几个有用的属性: 
    图表上的每个点都是有索引的,就象一个数组一样,在OnClickSeries事件中有个ValueIndex属性,该属性可以得到鼠标所点击的点的索引值(必须将Series的Point设置为可见,鼠标点击到那个点时才可以触发该事件)。 xValue[index]、yValue[index]分别表示图表的索引为index的横纵坐标值,用这两个属性可以读取和设置索引为index的点的值,注意:不要用xValues和yValues,这两个属性也可以达到同样的目的,但是速度非常的慢。因为后两个在进行操作的时候可能要遍历整个图表上的值(个人观点) 在MouseDown,MouseMove,Mouseup中,可以利用xScreentoValue(x),yScreentoValue(y)得到鼠标当时所在点对应在图表上的横纵坐标值。 e.g. ....... private 
    Nowindex:Integer; 
    Cantuo:boolean; ........ procedure TfrmMain.Chart1ClickSeries(Sender: TCustomChart; 
    Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton; 
    Shift: TShiftState; X, Y: Integer); 
    begin 
    NowIndex:=ValueIndex; 
    end; procedure TfrmMain.Chart1MouseDown(Sender: TObject; Button: TMouseButton; 
    Shift: TShiftState; X, Y: Integer); 
    begin 
    Cantuo:=true; end; procedure TfrmMain.Chart1MouseUp(Sender: TObject; Button: TMouseButton; 
    Shift: TShiftState; X, Y: Integer); 
    begin 
    Cantuo:=false; 
    end; procedure TfrmMain.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X, 
    Y: Integer); 
    begin 
    if Cantuo then 
    begin 
    Series1.yValue[NowIndex]:= Series1.yScreenToValue(y) ; 
    end; 
    end; 这里即实现了可以在图表中拖动某一个点使其在纵轴上变化位置 
      

  3.   

    看看 Delphi Demo下面的
    X:\Borland\Delphi7\Demos\TeeChart
    里面有你所要的例子
      

  4.   

    上述问题暂不解决!换一个小问题,解决就揭贴!!!
    如下:
    n:real;n1,n2,n3,n4,n5,n6,n7:integer;
    count:integer;
    .....
    count:=n1+n2+n3+n4+n5+n6+n7;
    求各个数的百分比???例如:n1/count(但如果n1=1而count=110时,如何得到百分比,我用整形得到的是0;但用REAL也不行???n:=int(n1/count)得到的也是0;
    请赐教!!!
      

  5.   

    n1/count得到的就是Real型的了,再用int就又一次把它四舍五入转换成整型
      

  6.   

    看看 Delphi Demo下面的例子