Bug in TErrorBarSeries

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
David
Newbie
Newbie
Posts: 5
Joined: Tue Jan 29, 2013 12:00 am

Bug in TErrorBarSeries

Post by David » Tue Jun 11, 2013 5:36 am

Hello, I am using TChart 2012.6.120613

TErrorBarSeries seems to have a bug that if I don't specify an error bar size, the bar itself does not appear.

For example, the following code does not show any bars at all

Code: Select all

  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TErrorBarSeries;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  series1.AddErrorBar(1,10,0,'foo',clRed);
  series1.AddErrorBar(2,20,0,'fee',clRed);
end;
but if I change Button1Click to

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  series1.AddErrorBar(1,10,1,'foo',clRed);
  series1.AddErrorBar(2,20,1,'fee',clRed);
end;
then both the bars and the error bars appear. I looked in the release notes and did not see any fixes regarding errorBars. Has this been fixed, or if not, what fix should I apply to my own code.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Bug in TErrorBarSeries

Post by Sandra » Wed Jun 12, 2013 1:40 pm

Hello David,

Seems the problem appears in latest version and it occurs only when the Error Value of ErrorBar Series is 0. I have added it in bug list report with number [TV52016601]. We will try to fix it to upcoming versions of TeeChartVCL.


Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

david
Newbie
Newbie
Posts: 1
Joined: Tue Jan 29, 2013 12:00 am

Re: Bug in TErrorBarSeries

Post by david » Wed Jun 12, 2013 3:05 pm

Can you please let me know the point in the code to fix it. I will fix it myself. We need this functionality quite a bit, and the user has the option in our software to not show the error bars. In that case, we put them as zero, but now that is making the whole bar disappear.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bug in TErrorBarSeries

Post by Narcís » Thu Jun 13, 2013 9:35 am

Hi David,

Most likely the error will be in TCustomErrorSeries.DrawBar method at ErrorBar.pas. A fix suggestion is implementing mentioned method like this:

Code: Select all

Procedure TCustomErrorSeries.DrawBar(BarIndex,StartPos,EndPos:Integer);
Var tmp         : Integer;
    tmpWidth,
    tmpBarWidth : {$IFDEF FMX}Single{$ELSE}Integer{$ENDIF};
    tmpError    : Double;
    tmpHeight   : Integer;
    tmpVal      : Double;
    tmpHeight2  : Integer;
Begin
  tmpError:=FErrorValues.Value[BarIndex];

  if ErrorPen.Visible and (tmpError<>0) then
  Begin
    tmpBarWidth:=BarBounds.Right-BarBounds.Left;

    if FErrorWidth=0 then tmpWidth:=tmpBarWidth
    else
    if FErrorWidthUnits=ewuPercent then
       tmpWidth:=Round(1.0*FErrorWidth*tmpBarWidth*0.01)
    else
       tmpWidth:=FErrorWidth;

    tmpVal:=YValues.Value[BarIndex];
    tmp:=CalcYPosValue(tmpVal);

    { MS : simplified and allows vertical/horizontal style 5.01 }
    Case FErrorStyle of
      essLeft,
      essRight,
      essLeftRight :
      begin
        tmpHeight:=GetHorizAxis.CalcSizeValue(Abs(tmpVal)) -
                    GetHorizAxis.CalcSizeValue(Abs(tmpVal-tmpError));

        if GetHorizAxis.Logarithmic then
          tmpHeight2:=GetHorizAxis.CalcSizeValue(Abs(tmpError+tmpVal)) -
                      GetHorizAxis.CalcSizeValue(Abs(tmpVal))
        else
          tmpHeight2:=tmpHeight;

        if GetHorizAxis.Inverted then
          SwapInteger(tmpHeight, tmpHeight2);
      end;
    else
      begin
        tmpHeight:=GetVertAxis.CalcSizeValue(tmpError+Abs(tmpVal)) -
                      GetVertAxis.CalcSizeValue(Abs(tmpVal));

        if GetVertAxis.Logarithmic then
          tmpHeight2:=GetVertAxis.CalcSizeValue(Abs(tmpVal)) -
                    GetVertAxis.CalcSizeValue(Abs(tmpVal-tmpError))
        else
          tmpHeight2:=tmpHeight;

        if GetVertAxis.Inverted then
          SwapInteger(tmpHeight, tmpHeight2);
      end;
    end;

    if MultiBar=mbStacked100 then   // 7.06 TV52010945
       tmp:=CalcYPosValue(100);

    if IDrawBar and (YValues.Value[BarIndex]<YOrigin) then
    begin
      tmpHeight:=-tmpHeight;

      PrepareErrorPen(BarIndex);

      DrawError((BarBounds.Right+BarBounds.Left) {$IFDEF FMX}*0.5{$ELSE}div 2{$ENDIF},tmp,
                 tmpWidth,tmpHeight,tmpHeight2,ParentChart.View3D);

      inherited;
    end
    else
    begin
      if IDrawBar then
         inherited;

      PrepareErrorPen(BarIndex);

      DrawError((BarBounds.Right+BarBounds.Left) {$IFDEF FMX}*0.5{$ELSE}div 2{$ENDIF},tmp,
                 tmpWidth,tmpHeight,tmpHeight2,ParentChart.View3D);
    end;
  end
  else
  if IDrawBar then
     inherited;
end;
I'll check if there's any other problem with the fix and can be included in the next maintenance release.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Newbie
Newbie
Posts: 5
Joined: Tue Jan 29, 2013 12:00 am

Re: Bug in TErrorBarSeries

Post by David » Fri Jul 19, 2013 7:15 pm

HI Narcis,

Before we apply this change to the source, is this the final form the fix will take in the next maintenance release?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bug in TErrorBarSeries

Post by Narcís » Mon Jul 22, 2013 7:01 am

Hello David,

Yes, that was implemented as the final fix for this issue.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Newbie
Newbie
Posts: 5
Joined: Tue Jan 29, 2013 12:00 am

Re: Bug in TErrorBarSeries

Post by David » Mon Jul 22, 2013 9:30 pm

Hi Narcis,

In that case, do you know when this release is slated to appear. If its just in a short time, we will just update at that time. If its going to be a long time, we will make the fix and recompile the source.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bug in TErrorBarSeries

Post by Narcís » Tue Jul 23, 2013 7:05 am

Hi David,

A date hasn't been confirmed yet. A few days ago a beta version was published. It includes many new features and changes. If you are a source-code customer you should receive an email with information on how to get it.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Newbie
Newbie
Posts: 5
Joined: Tue Jan 29, 2013 12:00 am

Re: Bug in TErrorBarSeries

Post by David » Tue Jul 23, 2013 1:41 pm

HI Narcis,

And this fix was in the beta?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bug in TErrorBarSeries

Post by Narcís » Tue Jul 23, 2013 1:48 pm

Hi David,

Yes.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply