Page 1 of 1

Bug in TColorGridSeries and Inverted Axes in TChart 8.04

Posted: Wed May 06, 2009 1:41 am
by 10047094
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;

Posted: Wed May 06, 2009 8:43 am
by yeray
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.