Bug in TColorGridSeries and Inverted Axes in TChart 8.04

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
dave novo
Newbie
Newbie
Posts: 25
Joined: Tue Oct 23, 2007 12:00 am

Bug in TColorGridSeries and Inverted Axes in TChart 8.04

Post by dave novo » Wed May 06, 2009 1:41 am

Hello,

You guys introduced a few new bugs in TChart 8.04 in the TColorGridSeries.

Here is the new method in TeeSurfa.TColorGrid.DrawAllValues. I made 3 corrections.

1,2. You were not considering inverted Axes when drawn the Horiz and Vert Axis
3. You made a copy/paste error and are checking FXStartIndex for the VertAxis instead of FZStartIndex.

If you could confirm that I made the correct fixes, that would be helpful.

Code: Select all

Function CalcDestRectangle(const tmpBounds:TRect):TRect;
  var
    IAxisSizeRange,MaxMin:Double;
    axisEndOffset: double;
  begin
    With GetHorizAxis do
    begin
      If (FXStartIndex=0) Then
      Begin
        if Maximum-Minimum = 0 then MaxMin:=1 else MaxMin := Maximum-Minimum;
        IAxisSizeRange:=IAxisSize/MaxMin;
        Result.Left:=CalcPosValue(MinXValue);
        // begin modifications to handle inverted axes
        axisEndOffset:=IAxisSizeRange*(MaxXValue-MinXValue);
        if Inverted then
          axisEndOffset := 0 - axisEndOffset;

        Result.Right:=Round(Result.Left + axisEndOffset);
        // end modifications
      end
      else
      Begin
        Result.Left:=CalcPosValue(Max(MinXValue,CalcMinValue(tmpBounds.Left)));
        Result.Right:=CalcPosValue(Min(MaxXValue,CalcMaxValue(tmpBounds.Right))){$IFDEF CLX}+1{$ENDIF};
      end;
    end;

    With GetVertAxis do
    begin
      If (FZStartIndex=0) Then // <----------------modified, used to say FXStartIndex
      Begin
        if Maximum-Minimum = 0 then MaxMin:=1 else MaxMin := Maximum-Minimum;
        IAxisSizeRange:=IAxisSize/(MaxMin);
        Result.Top:=CalcPosValue(MinZValue);
        // begin modifications to handle inverted axes
        axisEndOffset := IAxisSizeRange*(MaxZValue-MinZValue);
        if Inverted then
          axisEndOffset := 0 - axisEndOffset;

        Result.Bottom:=Round(Result.Top - axisEndOffset);
      // end modifications
      end
      else
      Begin
        Result.Top:=CalcPosValue(Max(MinZValue,CalcMinValue(tmpBounds.Top)));
        Result.Bottom:=CalcPosValue(Min(MaxZValue,CalcMaxValue(tmpBounds.Bottom))){$IFDEF CLX}+1{$ENDIF};
      end;
    end;
  end;

Yeray
Site Admin
Site Admin
Posts: 9541
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Wed May 06, 2009 8:43 am

Hi dave novo,

1,2. The bug regarding inverted axis (TF02013651) was already corrected in a similar way than what you suggested:

Code: Select all

if Inverted then
          Result.Right:=Round(Result.Left-(IAxisSizeRange*(MaxXValue-MinXValue)))
        else
          Result.Right:=Round(Result.Left+(IAxisSizeRange*(MaxXValue-MinXValue)));
3. Thank you for indicating it to us. I've just corrected it as you suggested.

Thank you very much for you suggestions.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply