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 1184 - StackOverflowException in Styles.Points series
Summary: StackOverflowException in Styles.Points series
Status: RESOLVED FIXED
Alias: None
Product: .NET TeeChart
Classification: Unclassified
Component: Series (show other bugs)
Version: TeeChart.NET 2014 4.1.2014.12154
Hardware: PC Windows
: --- critical
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-01 05:43 EDT by sdgr
Modified: 2015-05-12 05:57 EDT (History)
1 user (show)

See Also:
Chart Series: PointXY
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 sdgr 2015-04-01 05:43:35 EDT
Hi,

Simply create a new windows project in VS2013 and add a TeeChart component and  one simple button.

Add one series to the Chart:
    private Steema.TeeChart.Styles.Points points1;

Add code behind the button:
    private void button1_Click(object sender, EventArgs e)
    {
      points1.Add(0, 5);
      points1.Add(1, 1.79E+308);
    }

Run the application and press the button, you will get a StackOverflowException.

Is there a workaround? Thanks.

Regards,
Stefan.
Comment 1 christopher ireland 2015-04-01 07:13:03 EDT
Hello Stefan,

This error is being produced in the TeeChart code here:

        if (IAxisSize > 0)
        {

          tmp = inverted ? IEndPos - value : value - IStartPos;
          tmp *= iRange / IAxisSize;

          return horizontal ? iMinimum + tmp : iMaximum - tmp;
        }

tmp is calculated as Double.Infinity. In fact, the same issue can be observed running the following code:

      double large = 1.79E+308;
      large *= 500;

500 is about the normal size of the value of tmp, with iRange having a slightly larger value than 1.79E+308. I will have to think a little about the best way of avoiding this error being thrown. Many thanks for reporting it to us.
Comment 2 christopher ireland 2015-04-02 06:02:47 EDT
Stefan,

The best workaround I've found to date would be this:

    private void InitializeChart()
    {
      Points points1 = new Points(tChart1.Chart);
      points1.Pointer.InflateMargins = false;
      points1.ValueFormat = "0.###E+0";
      tChart1.Axes.Left.Labels.ValueFormat = "0.###E+0";
      tChart1.GetNextAxisLabel +=tChart1_GetNextAxisLabel;
      points1.Add(0, 5);
      points1.Add(1, 1.79E+308);
    }

    void tChart1_GetNextAxisLabel(object sender, GetNextAxisLabelEventArgs e)
    {
      if (((Steema.TeeChart.Axis)sender).Equals(tChart1.Axes.Left))
      {
        e.Stop = false;
        switch (e.LabelIndex)
        {
          case 0:
            e.LabelValue = 5;
            break;
          case 1:
            e.LabelValue = 1.79E+308;
            break;
          default:
            e.Stop = true;
            break;
        }
      }
    }

It is always different working with values whose arithmetic relationship is beyond double precision, such as (5, 1.79E+308) ... e.g.

    private void button4_Click(object sender, EventArgs e)
    {
      double large = 1.79E+308;
      double small = 5;

      double subtract = large - small;

      MessageBox.Show(Utils.MinimalDifference(large, subtract, 1).ToString());
    }