Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 2088

Summary: Switching from a large maximum to a small maximum for an axis can result in an Range Check Error
Product: VCL TeeChart Reporter: Thomas Mueller <teechart>
Component: ToolsAssignee: Steema Issue Manager <issuemanager>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description Thomas Mueller 2018-09-17 09:14:18 EDT
Create a chart with one series that has at least one very large Y-Value (>100 Million)
Set LeftAxis scaling to Automatic.
Add a Cursor Tool

Add code to remove the above series and add one with small Y-Values (0<y<1).

You will get a RangeCheckError here:

Function TChartAxis.YPosValueCheck(Const Value:TChartValue):Integer;
var tmp : TAxisValue;
begin
  if IRangeZero then result:=ICenterPos
  else
  begin
    tmp:=(Value-IMinimum)*IAxisSizeRange;

    if IUseTeeMaxPixelPos then
    begin
      if FInverted then tmp:=IStartPos+tmp
                   else tmp:=IEndPos-tmp;

      if tmp> TeeMaxPixelPos then
        result:= TeeMaxPixelPos
      else
      if tmp<-TeeMaxPixelPos then
        result:=-TeeMaxPixelPos
      else
         result:=Round(tmp);
    end
    else
    if FInverted then result:=IStartPos+Round(tmp) // <== here
                 else result:=IEndPos-Round(tmp);  // <== or here
  end;
end;

That's because tmp becomes much larger than MaxInt.

This does not happen if IUseTeeMaxPixelPos is true (but there is no way to do that without subclassing TAxis). Or if Chart1.Axes.FastCalc is true (which calls  the method YPosValue instead of YPosValueCheck).