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 601 - Property 'ChartRect' is not updated correctly
Summary: Property 'ChartRect' is not updated correctly
Status: RESOLVED FIXED
Alias: None
Product: .NET TeeChart
Classification: Unclassified
Component: Chart (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- major
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-25 06:23 EST by christian.naglhofer
Modified: 2014-03-19 11:07 EDT (History)
2 users (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description christian.naglhofer 2014-02-25 06:23:29 EST
Hello Steema team, 

We are testing the latest version of TeeChart for .Net (4.1.2014.02240, February 24th 2014) and the behavior of this version is different to the version we are using up to now (4.1.2012.05100, May 10th 2012).
In our application we are using custom axis where the start and end position is recalculated and set everytime the chart is resized:
In the SizeChanged or Resize EventHandler of the TChart the calculation of start and end position of the custom axis is done.
For the calculation we are using the property 'ChartRect' (see Steema.TeeChart.TChart.Chart.ChartRect).

With the old version of TeeChart (4.1.2012.05100) the values of property 'ChartRect' were already updated when delegate of SizeChanged/Resize EventHandler was executed.
But with the new version of TeeChart (4.1.2014.02240) the values of property 'ChartRect' are not updated. Consequently our calculations are wrong because 'ChartRect' contains still old values.

We want to upgrade to the latest version of TeeChart but it is not possible because: 
With the different behavior of TeeChart we would have to change our implementation somehow and this would cause some incompatibilities.

I ask you to fix this issue to have the same behavior of 'ChartRect' in the latest version as it was in older versions.

Example code:

    public Form1()
    {
      InitializeComponent();

      tChart1.Axes.Custom[0].StartEndPositionUnits = Steema.TeeChart.PositionUnits.Pixels;
      tChart1.Axes.Left.StartEndPositionUnits = Steema.TeeChart.PositionUnits.Pixels;
      tChart1.Axes.Right.StartEndPositionUnits = Steema.TeeChart.PositionUnits.Pixels;
      tChart1.Axes.Bottom.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
    }

    private void tChart1_SizeChanged(object sender, EventArgs e)
    {
      Rectangle chartRect = tChart1.Chart.ChartRect;

      tChart1.Axes.Left.StartPosition = 0;
      tChart1.Axes.Left.EndPosition = chartRect.Bottom - 50;

      tChart1.Axes.Right.StartPosition = tChart1.Axes.Left.StartPosition;
      tChart1.Axes.Right.EndPosition = tChart1.Axes.Left.EndPosition;

      tChart1.Axes.Custom[0].StartPosition = tChart1.Axes.Left.EndPosition;
      tChart1.Axes.Custom[0].EndPosition = chartRect.Bottom;

      tChart1.Axes.Bottom.RelativePosition = 50;
    }
Comment 1 christopher ireland 2014-02-26 15:58:22 EST
Hello Christian,

I'm afraid I'm having some difficultly reproducing this problem with TeeChart.dll_4.1.2014.02240 and TeeChart.dll_4.1.2012.05100. I'm using the following code:

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      tChart1.Series.Add(typeof(Bar)).FillSampleValues();
      tChart1.SizeChanged += tChart1_SizeChanged;
    }

    private void tChart1_SizeChanged(object sender, EventArgs e)
    {
      Rectangle chartRect = tChart1.Chart.ChartRect;
      Debug.WriteLine("chartRect " + chartRect.ToString());
    }

I think slowly resize the form and the Chart in a vertical direction only. With TeeChart.dll_4.1.2014.02240, the first ten output lines are:

chartRect {X=55,Y=52,Width=460,Height=437}
chartRect {X=55,Y=52,Width=460,Height=436}
chartRect {X=55,Y=52,Width=460,Height=435}
chartRect {X=55,Y=52,Width=460,Height=433}
chartRect {X=55,Y=52,Width=460,Height=430}
chartRect {X=55,Y=52,Width=460,Height=429}
chartRect {X=55,Y=52,Width=460,Height=427}
chartRect {X=55,Y=52,Width=460,Height=425}
chartRect {X=55,Y=52,Width=460,Height=423}
chartRect {X=55,Y=52,Width=460,Height=421}

with TeeChart.dll_4.1.2012.05100 they are:

chartRect {X=55,Y=52,Width=460,Height=437}
chartRect {X=55,Y=52,Width=460,Height=436}
chartRect {X=55,Y=52,Width=460,Height=435}
chartRect {X=55,Y=52,Width=460,Height=434}
chartRect {X=55,Y=52,Width=460,Height=433}
chartRect {X=55,Y=52,Width=460,Height=432}
chartRect {X=55,Y=52,Width=460,Height=431}
chartRect {X=55,Y=52,Width=460,Height=430}
chartRect {X=55,Y=52,Width=460,Height=429}
chartRect {X=55,Y=52,Width=460,Height=428}

do you obtain similar results at your end with this code? If so, could you please give us a more complete code example with which we can reproduce the problem here?
Comment 2 christopher ireland 2014-03-19 11:07:00 EDT
Resolution:

Christian,

Okay, I think I can see what's happening here. The Windows Form Control's Resize event is called before the Windows Form Control's Paint event, meaning the lag in the values of the ChartRect in both versions of TeeChart.dll.

I think there is a much better way of working here, a method which you can apply to both versions of TeeChart.dll and which here gives me expected results in both cases. The code is:

      //fill some sample values
      this.line1.Add(0, 0);
      this.line1.Add(50, 40);
      this.line1.Add(70, 20);
      this.line1.Add(100, 70);
     
      this.horizBar1.Add(100, 2);


      tChart1.GetAxesChartRect += tChart1_GetAxesChartRect;
    }

    void tChart1_GetAxesChartRect(object sender, GetAxesChartRectEventArgs e)
    {
      int offset = (int)tChart1.Panel.MarginTop;
      Rectangle chartRect = e.AxesChartRect;

      tChart1.Axes.Left.StartPosition = 0;
      tChart1.Axes.Left.EndPosition = chartRect.Bottom - HeightCustomSeries - offset;

      tChart1.Axes.Right.StartPosition = tChart1.Axes.Left.StartPosition;
      tChart1.Axes.Right.EndPosition = tChart1.Axes.Left.EndPosition;

      tChart1.Axes.Custom[0].StartPosition = tChart1.Axes.Left.EndPosition;
      tChart1.Axes.Custom[0].EndPosition = chartRect.Bottom - offset;

      tChart1.Axes.Bottom.RelativePosition = HeightCustomSeries;
    }