I need to creat a terrorseries with tpointseries, like what appears in this link: http://www.teechart.net/support/viewtopic.php?p=46388

In each 'X' will have some of error series, but they need to be drawn side by side for each XValue. I managed to put the error series, but how can i put the pointseries without overlap???

I found something like that: "Having a TErrorSeries with XValues 0, 1, 2,... the ErrorBars are drawn exactly in the X=0, X=1,... but when you have two TErrorSeries, they are drawn one next to the other so the first is drawn some pixels at the left side of X=0, X=1,... and the second TErrorSeries is drawn some pixels at the right side of X=0, X=1,... This is made to fit as many TErrorSeries as one would like to draw without overlapping. On the other hand, TPointSeries doesn't do this job. They don't prevent this overlapping. So, before proceeding with proposing you a workaround, we would need to know if you want your TErrorSeries to overlap or you want them to be drawn side by side for each XValue."

And I need drawn side by side, can someone help me?

I put the code like you suggested, but still continue the series overlapped on the X axis (I wanted the series stay side by side)

procedure TForm1.BtnGraphClick(Sender: TObject);
var
i, j        : Integer;
Series1     : TErrorPointSeries;
x, y        : Double;
Top, Bottom : Double;
max, min, k :array of array of integer;
ndecisor, ncri: integer;

begin
  //Atribuindo valores na Matriz MAX, MIN, K
   SetLength(Max, 3, 3);
   max[0,0]:= 9;
   max[0,1]:= 12;
   max[0,2]:= 14;
   max[1,0]:= 10;
   max[1,1]:= 8;
   max[1,2]:= 13;
   max[2,0]:= 11;
   max[2,1]:= 7;
   max[2,2]:= 10;

    SetLength(Min, 3, 3);
    min[0,0]:= 2;
    min[0,1]:= 0;
    min[0,2]:= 3;
    min[1,0]:= 3;
    min[1,1]:= 1;
    min[1,2]:= 4;
    min[2,0]:= 1;
    min[2,1]:= 2;
    min[2,2]:= 0;

   SetLength(k, 3, 3);
   k[0,0]:= 5;
   k[0,1]:= 8;
   k[0,2]:= 4;
   k[1,0]:= 7;
   k[1,1]:= 5;
   k[1,2]:= 6;
   k[2,0]:= 6;
   k[2,1]:= 7;
   k[2,2]:= 5;

   ndecisor:=3;
   ncri:=3;

 ErrorPointChart.View3D:=False;
 ErrorPointChart.Axes.Left.MinimumOffset:=1;
 ErrorPointChart.Axes.Left.MaximumOffset:=1;

  for i := 0 to ndecisor -1 do
  begin
    Series1:=TErrorPointSeries.Create(ErrorPointChart);
    Series1.Pen.Width:=3;
    ErrorPointChart.AddSeries(Series1);

    Randomize;

   for j := 0 to ncri -1 do
   begin
     x:=j;
     y:=k[j,i];;
     Top:= max[j,i]-k[j,i];
     Bottom:= k[j,i]-min[j,i];
   Series1.Add(x,y,0,0,Top,Bottom);
  end;
end;
end;
有帮助吗?

解决方案

The easiest option might be using new TErrorPointSeries which would handle this automatically. You can find examples at the What's New?\Welcome!\New Series\Error Point section in the new features demo, available at TeeChart's program group. Here you have an example:

uses TeeErrorPoint;

procedure TForm1.FormCreate(Sender: TObject);
var
  i, j        : Integer;
  Series1     : TErrorPointSeries;
  x, y        : Double;
  Top, Bottom : Double;
begin
  Chart1.View3D:=False;

  for i := 0 to 3 do
  begin
    Series1:=TErrorPointSeries.Create(Self);
    Series1.Pen.Width:=3;
    Chart1.AddSeries(Series1);

    Randomize;

    for j := 0 to 10 do
    begin
      x:=j;
      y:=Random(100);
      Top:= Random(10);
      Bottom:= Random(10);
      Series1.Add(x,y,0,0,Top,Bottom);
    end;
  end;
end;

Also, we found an issue that, with big error values, vertical axes are not calculated correctly. We are investigating it but we found setting vertical axes offset solves the problem for example

  Chart1.Axes.Left.MinimumOffset:=1;
  Chart1.Axes.Left.MaximumOffset:=1;

Using your code I get this image:

"Stacked" TErrorPointSeries

I guess this is what you mean by "stacked". I thought the problem was series were overlapping, not stacking. Since TErrorPointSeries doesn't support stacking options as bar, area or line series do, you should populate TErrorPointSeries with slightly different X values to simulate this behaviour, for example:

for j := 0 to ncri -1 do
begin
  x:=j + i*0.3; //Side by side offset.
  y:=k[j,i];;
  Top:= max[j,i]-k[j,i];
  Bottom:= k[j,i]-min[j,i];
  Series1.Add(x,y,0,0,Top,Bottom);
end;

Changing the code snippet above in your example produces this chart:

Side by side TErrorPonitSeries

Which I guess it's something similar to what you were looking for.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top