0

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;
Narcís Calvet
  • 7,304
  • 5
  • 27
  • 47
  • 1
    is that part of the War on TError? or some sort of new Axis? – Sam Sep 11 '13 at 23:08
  • @Sam this is an "error series", an error charting tool: http://en.wikipedia.org/wiki/Error_bar. For compliance with Delphi types a "T" is added and so the type is called TErrorSeries. A coincided probably oversighted. :P – Narcís Calvet Sep 16 '13 at 13:32

1 Answers1

0

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.

Narcís Calvet
  • 7,304
  • 5
  • 27
  • 47
  • Yes, this is kind of graphic!!! Thank you =) But I'm having doubts about the parameters add(x,y,left,right,top,botton,label,color) In the chart of normal error, I put a series of error add(x,y,error,label,color) plus a pointseries add(x,y,label, color) Ps: The point is not necessarily the average / median interval error I still can not identify how I could put the parameters in this series (sorry, I'm still beginner with this) – Amanda Fenerich Sep 13 '13 at 13:59
  • @AmandaFenerich X and Y are where the point will be plotted. The other parameters are for each error: left error, right error, top error and bottom error. Finally, label and color, are optional arguments and provide a text label and color for each point. – Narcís Calvet Sep 13 '13 at 14:09
  • I did my code like this: for i := 0 to ndecisor - 1 do  begin     serie0:=terrorpointseries.Create(errorpointchart);  //cria série tipo erro     serie0.pen.width:=3;     ErrorPointChart.AddSeries(serie0);       //adiciona a serie no gráfico 2     for j := 0 to ncri - 1 do   //define os pontos xy no gráfico     begin       x:=i;       y:=k[j,i];       top:= max[j,i]-k[j,i];       botton:= k[j,i]-min[j,i];       serie0.Add(x,y,0,0,top,botton,'',clTeeColor);       serie0.Visible:=true;     end;  end; but the series are appearing superimposed how do they not get overlapping? – Amanda Fenerich Sep 16 '13 at 11:38
  • @AmandaFenerich the code snippet I just posted at my answer works fine for me. Does it work for you? Can you modify it so that we can reproduce the problem here? Thanks in advance. – Narcís Calvet Sep 16 '13 at 13:29
  • I put the code like you suggested, but still continue the series overlapped on the X axis =( – Amanda Fenerich Sep 17 '13 at 12:52
  • @AmandaFenerich just updated my answer and edited your question. Please consider removing your answer which, IMHO, is an extension of your question. – Narcís Calvet Sep 17 '13 at 13:28
  • @AmandaFenerich you're very welcome! Feel free to vote and accept my answer if you think it was helpful and solved your problem. ;-) – Narcís Calvet Sep 17 '13 at 14:16