TChart has severe problems with constant series/lines

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Oliver@Siemens
Newbie
Newbie
Posts: 7
Joined: Thu Feb 03, 2011 12:00 am
Location: Erlangen
Contact:

TChart has severe problems with constant series/lines

Post by Oliver@Siemens » Thu Oct 18, 2012 8:16 am

Introduction:
We have a product that is at least one of the most well known engineering tools for industrial purpose.
So that we are using your control might be a very good reputation for Steema.
Before switching over to another chart control here is another chance for you to fix your bugs or to provide us applicable workarounds ( not by changing our setup into line.Add(xArray, penetrationValues); ).

Setup:
In our industrial world the most common case is to have constant series/lines in the range of double.MinValue and double.MaxValue. They might change to non constant series/lines, but that is not predictable. For several reasons we use distinct lines/series per custom axis. I guess that is a common setup for people that want to hide ( visible=false ) certain series/lines and have the need to show the axis labels only for one series. We also focus and color the complete axis according to the corresponding series/line.

Hint:
We are currently using an older Version ( 4.1.2010.11302 ), but the same problems also occur with the latest version ( TeeChart for .NET v2012 [28 SEP 2012] RELEASE 4.1.2012.09280 ).

List of known problems where we haven't found a workaround yet:
1.
  1. Why is the same label value shown several times ( sometimes and sometimes not )? Expected is just one '0' or .. -2 -1 0 1 2 .. and so on:
    Image
2. 3.
  • Utils.cs::SignificantDifference() crashes with constant lines with values bigger than 1.0e+015.
    Just uncomment the penetrationValues 1.0e+015, -1.0e+015, 1.0e+016, -1.0e+016, ... :
    Image
The first problem is annyoing, the second one is critical in the sense of signal value interpretation and the third is classified as showstopper in our bugtracker.

Code-Snippet:

Code: Select all

        #region / Fields                    /

        System.Windows.Forms.Timer timer;
        int currentVertAxisIdx = -1;

        #endregion / Fields                    /
        #region / C'tor                     /

        /// <summary>
        /// Initializes a new instance of the <see cref="Form1"/> class.
        /// </summary>
        public Form1()
        {
            InitializeComponent();

            InitializeChart();

            timer = new System.Windows.Forms.Timer();
            timer.Interval = 2000; // every 2 seconds
            timer.Tick += new EventHandler(timer_Tick); // switches the current visible custom axis
            timer.Enabled = true;

            ForceDraw();
        }

        #endregion / C'tor                     /
        #region / Init                      /

        double[] penetrationValues = { 
                                       -1.0,       0.0,       1.0,
                                        1.0e+014, -1.0e+014,
                                        /* this values lead to chart crashes
                                        1.0e+015, -1.0e+015, 
                                        1.0e+016, -1.0e+016,
                                        */
                                     };        

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            int samples = 10;

            foreach (var val in penetrationValues)
            {
                var constantLine = new Steema.TeeChart.Styles.Line();
                var constantLineAxis = new Steema.TeeChart.Axis();

                constantLine.Chart = tChart1.Chart;
                SetAxisColor(constantLineAxis, constantLine.Color);
                constantLine.CustomVertAxis = constantLineAxis;

                constantLineAxis.Labels.Style = AxisLabelStyle.Value;

                tChart1.Series.Add(constantLine);
                tChart1.Axes.Custom.Add(constantLineAxis);

                for (int i = 0; i < samples; i++)
                    constantLine.Add(i, (double)val); // adds a constant signal
            }

            AddRefLine(samples);
        }

        private void AddRefLine(int samples)
        { 
            var referenceLine = new Steema.TeeChart.Styles.Line();
            var referenceAxis = new Steema.TeeChart.Axis();

            referenceLine.Chart = tChart1.Chart;
            SetAxisColor(referenceAxis, referenceLine.Color);
            referenceLine.CustomVertAxis = referenceAxis;

            referenceAxis.Labels.Style = AxisLabelStyle.Value;

            tChart1.Series.Add(referenceLine);
            tChart1.Axes.Custom.Add(referenceAxis);

            referenceLine.Add(0, -1.0e+014);
            referenceLine.Add(samples - 1, 1.0e+014);
        }

        . . .

        #endregion / Init                      /

        . . .

        #region / Timer Handling            /

        void timer_Tick(object sender, EventArgs e)
        { // shuffles through the available axis
            foreach (var ax in tChart1.Axes.Custom.Cast<Axis>())
                ax.Visible = false;

            if (currentVertAxisIdx + 1 < tChart1.Axes.Custom.Count)
                currentVertAxisIdx++;
            else
                currentVertAxisIdx = 0;

            Axis currentAxis = tChart1.Axes.Custom[currentVertAxisIdx];
            currentAxis.Visible = true;
            ActiveVertAxis = currentAxis;

            ForceDraw();
        }

        #endregion / Timer Handling        /
A demo project is attached as well ( TeeChart.dll is not included ).
Attachments
tcharttest.constant.signals.forumversion.zip
demo project ( TeeChart.dll is not included )
(11.48 KiB) Downloaded 1069 times
With best regards,
Oliver Trenkelbach

Siemens AG
Industry Sector
Drive Technologies Division
Motion Control Systems
Research and Development

http://www.siemens.com/motion-control

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: TChart has severe problems with constant series/lines

Post by Sandra » Thu Oct 18, 2012 4:19 pm

Hello Oliver,
1.Why is the same label value shown several times ( sometimes and sometimes not )? Expected is just one '0' or .. -2 -1 0 1 2 .. and so on:
I have checked your code and I can see that all axes are painted in the first time. You need hide the axes aren't selected as an active axis before active timer. For this reason, I have made an AxisVisible method where I use the lines of code you are using in the timer. Please see the modification in your code:

Code: Select all

namespace tcharttest
{
    public partial class Form1 : Form
    {
        #region / Fields                    /

        System.Windows.Forms.Timer timer;
        int currentVertAxisIdx = -1;

        #endregion / Fields                    /
        #region / C'tor                     /

        /// <summary>
        /// Initializes a new instance of the <see cref="Form1"/> class.
        /// </summary>
        public Form1()
        {
            InitializeComponent();

            InitializeChart();
            // You need select the axis is active in first time. 
            AxisVisible();
            timer = new System.Windows.Forms.Timer();
            timer.Interval = 2000; // every 2 seconds
            timer.Tick += new EventHandler(timer_Tick); // switches the current visible custom axis
            timer.Enabled = true;
          
        }

        #endregion / C'tor                     /
        #region / Init                      /

        double[] penetrationValues = { -1.0,       0.0,       1.0,
                                        1.0e+014, -1.0e+014,
                                        /* this values lead to chart crashes
                                        1.0e+015, -1.0e+015, 
                                        1.0e+016, -1.0e+016,
                                        */
                                     };        

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            int samples = 10;

            foreach (var val in penetrationValues)
            {
                var constantLine = new Steema.TeeChart.Styles.Line();
                var constantLineAxis = new Steema.TeeChart.Axis();

                constantLine.Chart = tChart1.Chart;
                SetAxisColor(constantLineAxis, constantLine.Color);

                constantLine.CustomVertAxis = constantLineAxis;

                constantLineAxis.Labels.Style = AxisLabelStyle.Value;

                tChart1.Series.Add(constantLine);
                tChart1.Axes.Custom.Add(constantLineAxis);

                for (int i = 0; i < samples; i++)
                    constantLine.Add(i, (double)val); // adds a constant signal
            }

            AddRefLine(samples);
      
        }

        private void AddRefLine(int samples)
        { 
            var referenceLine = new Steema.TeeChart.Styles.Line();
            var referenceAxis = new Steema.TeeChart.Axis();

            referenceLine.Chart = tChart1.Chart;
            SetAxisColor(referenceAxis, referenceLine.Color);

            referenceLine.CustomVertAxis = referenceAxis;

            referenceAxis.Labels.Style = AxisLabelStyle.Value;

            tChart1.Series.Add(referenceLine);
            tChart1.Axes.Custom.Add(referenceAxis);

            referenceLine.Add(0, -1.0e+014);
            referenceLine.Add(samples - 1, 1.0e+014);
            
        }

        private void SetAxisColor( Axis axis, Color color )
        {
            axis.AxisPen.Color      = color;
            axis.Ticks.Color        = color;
            axis.Labels.Font.Color  = color;
            axis.Title.Color        = color;
            axis.Title.Font.Color   = color;
        }

        private void AxisVisible()
        {
            // shuffles through the available axis
            foreach (var ax in tChart1.Axes.Custom.Cast<Axis>())
                ax.Visible = false;

            if (currentVertAxisIdx + 1 < tChart1.Axes.Custom.Count)
                currentVertAxisIdx++;
            else
                currentVertAxisIdx = 0;

            Axis currentAxis = tChart1.Axes.Custom[currentVertAxisIdx];
            currentAxis.Visible = true;
            ActiveVertAxis = currentAxis;
            ForceDraw();
        }
        #endregion / Init                      /
        #region / Properties                /

        Axis currentVertAxis = null;
        Axis ActiveVertAxis
        { 
            get
            {
                if ( currentVertAxis!= null)
                    return currentVertAxis;

                return this.tChart1.Axes.Left;
            }
            set{ currentVertAxis = value; }
        }

        #endregion / Properties                 /
        #region / Timer Handling            /

        void timer_Tick(object sender, EventArgs e)
        { // shuffles through the available axis

            AxisVisible();
        }

        #endregion / Timer Handling        /
        #region / Layout Adjustments        /

        internal void ForceDraw()
        {
            //TeeChart got a bug regarding internalDraw when window is not visible (e.g. the window is to small).
            // in this case a redraw is not needed as nothing is been seen anyhow and as soon as the window gets resised
            //the draw accours anyways
            try
            {
                if (chartHorizontalScrollPanel.Visible && (tChart1.Height > 1 && tChart1.Width > 1))
                {
                    tChart1.Invalidate(true);
                    CalcLeftAxisWidth();
                    tChart1.Draw();
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        const int tchartsPanelMarginLeftOffset = 12; // in pixel
        private void CalcLeftAxisWidth()
        {
            tChart1.Panel.MarginLeft = ActiveVertAxis.MaxLabelsWidth() + tchartsPanelMarginLeftOffset;
            tChart1.Text = tChart1.Panel.MarginLeft.ToString();
            
        }

        #endregion / Layout Adjustments        /
        #region / Button Handling           /

        private void tChart1ShwoEditorButton_Click( object sender, EventArgs e )
        {
            tChart1.ShowEditor();
        }

        #endregion / Button Handling        /
    }
} 
2.
(Constant) lines/series are mutually shifted to each other when panning as seen in the video:
http://img402.imageshack.us/flvplayer.s ... joceysudhl
Can you tell us how you expect that the chart and series behave when do you do scroll?
3.Utils.cs::SignificantDifference() crashes with constant lines with values bigger than 1.0e+015.
Just uncomment the penetrationValues 1.0e+015, -1.0e+015, 1.0e+016, -1.0e+016, ... :
I recommend you take a look in this thread where explain because the problem is produced.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Oliver@Siemens
Newbie
Newbie
Posts: 7
Joined: Thu Feb 03, 2011 12:00 am
Location: Erlangen
Contact:

Re: TChart has severe problems with constant series/lines

Post by Oliver@Siemens » Fri Oct 19, 2012 9:58 am

Hello Sandra,

nice to hear from you!

First of all, like I already mentioned in my last eMail to Christopher: if you need any help just ask!
To fix theses bugs is very important to us. If you still want us to use your control in the future please give these problems high priority.

1.
I have checked your code and I can see that all axes are painted in the first time. You need hide the axes aren't selected as an active axis before active timer. For this reason, I have made an AxisVisible method where I use the lines of code you are using in the timer.
Obviously ( I already knew ) the visible result is fine if the tick-code/AxisVisible-method is called before activating the timer.
But the question is, why we need to hide all other custom axis in order that the labeling is correct?
Our code around your control is much more complex compared to the demo project that is attached. To give you an indication that there must be something wrong here are 2 screenshots of our productive code ( where there is only one custom axis visible at a time ):
  1. Image The label is at the wrong position.
  • Image The same label is shown several times.
2.
Can you tell us how you expect that the chart and series behave when do you do scroll?
Sure: The constant series/lines have to behave in the same way as the "normal" lines. If a user pans/scrolls the chart, the constant series/lines should move like the reference line. Otherwise the visible cut-points are moving also and that is simply not correct.

3.
3.Utils.cs::SignificantDifference() crashes with constant lines with values bigger than 1.0e+015.
Just uncomment the penetrationValues 1.0e+015, -1.0e+015, 1.0e+016, -1.0e+016, ... :
I recommend you take a look in this thread where explain because the problem is produced:

I inform you that the bug number [TF02016018] is not a bug of TeeChart.Net, so this is a problem with the range of System.Double. Have a look at this code, using two double values without TeeChart:

Code: Select all

    double d1 = 4.08426213706027E+304;
    double d2 = 1.7189571678554E+253;
    double d3 = d1 - d2;
    MessageBox.Show((d1.CompareTo(d3) == 0) ? "Equal" : "Unequal");
How you can see, the result is Equal, therefore the range of Double of .Net Framework can not represents numbers with range of values as 4.08426213706027E+304;.
Seriously, this is not a .Net framework problem. That is simply the nature of double arithmetic!
I really don't like to defend them, but Microsoft's double implementation just follows the IEEE-specifications and is correct.
Try to open a bug report at Microsoft and they will tell you the same.
You need to consider if there is a significant change between the doubles in your code when you do the calculations ( mainly in the axis labeling code ). A good resource for the numeric background is this link:
http://docs.oracle.com/cd/E19957-01/806 ... dberg.html
If you want better precision, you need to use decimal instead of double, as it has more significant digits.

Code: Select all

System.Single // float - 7 significant digits
System.Double // double - 15-16 significant digits
System.Decimal // decimal - 28-29 significant digits
Or use calculation tricks like all other chart vendors do. But it is not a good idea to use Math.Round ( like you use in your code ) as it is limited to 1.0e+15. So I am not able to understand the need of your implementation in Utils.cs::SignificantDifference().
To test if there is a significant difference you can simply use the following code:

Code: Select all

Math.Abs(d1 - d2) < double.Epsilon
I can only guess that this is due to the fact, that you have magic double constants in your code other than double.Epsilon and the calculations are wrong. If you use this test instead of yours, the Control will not crash, but will run into endless loops when the constant-line-value is big enough. Just try it out ( it is another bug ).

And here is another example to calculate the next significant difference for any double value:

Code: Select all

    internal static class DoubleExtensions
    {
        /// <summary>
        /// Next possible double that is bigger than <paramref name="val"/>
        /// </summary>
        /// <param name="val">The val.</param>
        /// <returns>the next possible double that is bigger than <paramref name="val"/>,
        /// if the <paramref name="val"/> equals infinity or <value>System.Double.MaxValue</value> 
        /// or is not a number (NAN) the <paramref name="val"/> is returned</returns>
        public static double NextUp(this double val)
        {
            if (val < double.MaxValue) // avoid infinity results
                return val.ChangeByUlp(1);
            else
                return val;
        }

        /// <summary>
        /// Next possible double that is smaller than <paramref name="val"/>
        /// </summary>
        /// <param name="val">The val.</param>
        /// <returns>the next possible double that is smaller than <paramref name="val"/>,
        /// if the <paramref name="val"/> equals infinity or <value>System.Double.MinValue</value> 
        /// or is not a number (NAN) the <paramref name="val"/> is returned</returns>
        public static double NextDown(this double val)
        {
            if (val > double.MinValue) // avoid infinity results
                return val.ChangeByUlp(-1);
            else
                return val;
        }

        /// <summary>
        /// Changes a double value by the specified amount of ulp's.
        /// ( ulp : Unit in the Last Place )
        /// </summary>
        /// <param name="val">The original value</param>
        /// <param name="ulp">The amount of ulp's.</param>
        /// <returns>a value that differs by the amount of ulp's specified,
        /// if the <paramref name="val"/> equals infinity or is not a number (NAN) the <paramref name="val"/> is returned
        /// if the result is out of the bounds of <value>System.Double.MinValue</value> or <value>System.Double.MaxValue</value> infinity is returned</returns>
        public static double ChangeByUlp(this double val, int ulp)
        {
            if (!double.IsInfinity(val) && !double.IsNaN(val))
            {
                long bits = BitConverter.DoubleToInt64Bits(val);

                if (bits == 0 && ulp < 0) // zero is a special double
                    return -BitConverter.Int64BitsToDouble(bits - ulp);
                else
                {
                    if (val < 0)
                        ulp = -ulp; // negative logic

                    return BitConverter.Int64BitsToDouble(bits + ulp);
                }
            }

            return val;
        }

        /// <summary>
        /// Gets the Unit in the Last Place.
        /// </summary>
        /// <remarks>
        /// The Ulp depends on the exponent, because floating arithmetic is very imprecisely
        /// call value:         result:
        /// GetUlp( 0.00001 )   0.000000000000000000001694065894508600678136645001359283924102783203125
        /// GetUlp(-1 )        -0.0000000000000002220446049250313080847263336181640625
        /// GetUlp( 1 )         0.0000000000000002220446049250313080847263336181640625
        /// GetUlp( 2 )         0.000000000000000444089209850062616169452667236328125
        /// GetUlp( 10E30 )     1125899906842624
        /// </remarks>
        /// <param name="val">The val.</param>
        /// <returns></returns>
        public static double GetUlp(this double val)
        {
            if (!double.IsInfinity(val) && !double.IsNaN(val))
            {
                long bits = BitConverter.DoubleToInt64Bits(val);
                double nextValue = BitConverter.Int64BitsToDouble(bits + 1);

                return nextValue - val;
            }

            return val;
        }
    }
Due to the license we are not permitted to deliver changes in your source code ourselves.
If we would provide bugfixes of your source code to you, would you review them and deliver hotfixes?
With best regards,
Oliver Trenkelbach

Siemens AG
Industry Sector
Drive Technologies Division
Motion Control Systems
Research and Development

http://www.siemens.com/motion-control

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: TChart has severe problems with constant series/lines

Post by Christopher » Fri Oct 19, 2012 11:44 am

Hello Oliver,

Nice to hear from you too! How are you?

Okay, changing the Utils.SignificantDifference() to:

Code: Select all

		static public bool SignificantDifference(double d1, double d2)
		{
			return Math.Abs(d1 - d2) > double.Epsilon;
		}
Now stops the code crashing. However, when you say
If you use this test instead of yours, the Control will not crash, but will run into endless loops when the constant-line-value is big enough. Just try it out ( it is another bug ).
You give me the impression that this change is not going to be enough to rectify the problem. Is this right? Would you be happy with this change as a solution to the crashing issue?

The first of the other two problems, the annoying one, I can see here and will look into. The second of them, the critical one, I'm not sure I fully understand. I've seen the video: are you talking about the way the left axis labels snap from actual series values to -1 and then to 0? If so, do you have some code I can use to reproduce the issue?

Many thanks,

Christopher Ireland
http://www.steema.com

Oliver@Siemens
Newbie
Newbie
Posts: 7
Joined: Thu Feb 03, 2011 12:00 am
Location: Erlangen
Contact:

Re: TChart has severe problems with constant series/lines

Post by Oliver@Siemens » Mon Oct 22, 2012 12:27 pm

Hello Christopher,

I am fine and hope you are too!
Okay, changing the Utils.SignificantDifference() to:

Code: Select all

          static public bool SignificantDifference(double d1, double d2)
          {
             return Math.Abs(d1 - d2) > double.Epsilon;
          }
Now stops the code crashing.
It stops crashing, but your implementation is slightly wrong. It has to be like this:

Code: Select all

          static public bool SignificantDifference(double d1, double d2)
          {
             return !(Math.Abs(d1 - d2) < double.Epsilon);
          }
Let me shortly explain why: If the value of d1 is identical to d2 clearly the subtraction result is zero and thus smaller than double.Epsilon. So the conclusion is that there is no significant difference. The other cases are more interesting. If d1 or d2 has less significant bits there will be no significant difference in the subtraction and the result is also zero. So the bigger the double values become, the bigger the significant difference has to be ( just look into my double extension above: GetUlp() ). Think of it in a logarithmic way. That is why you cannot use the same magic constants ( like iIncrement, IncrementOffset, and so on ) with all double values and expect that adding or subtracting changes anything to the subtrahend/summand. That is why the endless loops occur in AxisDraw::DoDefaultLabels() and without much doubt in other places as well.
You can test it with my crashfix and a penetrationValue of 1.0e+015 or bigger.

You give me the impression that this change is not going to be enough to rectify the problem. Is this right? Would you be happy with this change as a solution to the crashing issue?
For the end consumer there is no difference if the application crashes or runs into endless loops. The result is he/she cannot use it at all.
I would be happy if you fix the crash and the endless-loop or provide me an workaround.

The second of them, the critical one, I'm not sure I fully understand. I've seen the video: are you talking about the way the left axis labels snap from actual series values to -1 and then to 0? If so, do you have some code I can use to reproduce the issue?
No, the series swapping from -1, to 0 etc. was due to the timer ( to show different problems ).
I have slightly modified the demo project ( see attachment ) for better reproduction and provided a new video showing this issue:
http://img267.imageshack.us/flvplayer.s ... mswftinpad
You can see that all 3 lines initially have a single cutpoint around x=4.5 and y=1.
The first question is, why there is no label of zero next to the constant line as it should be?
And second why is the constant line not moving like the other two lines when panning? That is clearly a mistake. For our customers that is not comprehensible.

You are welcome.
Attachments
tcharttest.constant.signals.forumversion-V2.zip
reproduction demo project ( slightly modified )
(11.6 KiB) Downloaded 1094 times
With best regards,
Oliver Trenkelbach

Siemens AG
Industry Sector
Drive Technologies Division
Motion Control Systems
Research and Development

http://www.siemens.com/motion-control

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: TChart has severe problems with constant series/lines

Post by Christopher » Wed Oct 24, 2012 8:32 am

Hello Oliver,

Sorry, I've been away for the last couple of days but am back on the case now :-)
Let me shortly explain why: If the value of d1 is identical to d2 clearly the subtraction result is zero and thus smaller than double.Epsilon. So the conclusion is that there is no significant difference. The other cases are more interesting. If d1 or d2 has less significant bits there will be no significant difference in the subtraction and the result is also zero. So the bigger the double values become, the bigger the significant difference has to be
Okay, this is what SignificantDifference() looks like:

Code: Select all

static public bool SignificantDifference(double d1, double d2)
          {
             return Math.Abs(d1 - d2) < double.Epsilon;
          }
and these are some test values:

Code: Select all

Utils.SignificantDifference(1.0e020, 1.00000000000000001e020).ToString();
Utils.SignificantDifference(1.0e020, 1.0000000000000001e020).ToString();
Utils.SignificantDifference(1.0e-020, 1.00000000000000001e-020).ToString();
Utils.SignificantDifference(1.0e-020, 1.0000000000000001e-020).ToString();
Utils.SignificantDifference() returns, for these four cases, false true false true. This is what I would expect. Using your code for Utils.SignificantDifference(), i.e.

Code: Select all

static public bool SignificantDifference(double d1, double d2)
          {
             return !(Math.Abs(d1 - d2) < double.Epsilon);
          }
these four test cases return: true false true false. This is also what I would expect. So, the only difference between the two implementations of Utils.SignificantDifference() is the boolean sign they return. Or can you give me a set of figures which returns different results to the four test cases above?
That is why you cannot use the same magic constants ( like iIncrement, IncrementOffset, and so on ) with all double values and expect that adding or subtracting changes anything to the subtrahend/summand. That is why the endless loops occur in AxisDraw::DoDefaultLabels() and without much doubt in other places as well.
Is there some code that you've given me that produces these endless loops you mention? I would be very interested to see these endless loops in action. Apologies if you've already sent the code and I've missed it.
The first question is, why there is no label of zero next to the constant line as it should be?
And second why is the constant line not moving like the other two lines when panning? That is clearly a mistake. For our customers that is not comprehensible.
These issues seems to be related to custom axes. If you comment out all references to constantLineAxis and referenceAxis in your code (and modify the code associated with currentVertAxisIdx) you will get something like the image here:
Screenshot (4).png
Screenshot (4).png (133.58 KiB) Viewed 29372 times
I think you may already know that Custom axes do not zoom and scroll automatically and that code has to be added to make them behave this way. There is an example of how to scroll custom axes in the Feature Demo of TeeChart in the "All Features" tab under "Welcome !\Axes\Scrolling multiple axes".

Or do you see the issues with Custom axes as being related to something other than zooming and scrolling? If so, could you please let me know?

Thank you,

Christopher Ireland
http://www.steema.com

Oliver@Siemens
Newbie
Newbie
Posts: 7
Joined: Thu Feb 03, 2011 12:00 am
Location: Erlangen
Contact:

Re: TChart has severe problems with constant series/lines

Post by Oliver@Siemens » Mon Oct 29, 2012 10:50 am

Hello Christopher,

I am also back on the case now. :wink:
Utils.SignificantDifference() returns, for these four cases, false true false true. This is what I would expect. Using your code for Utils.SignificantDifference(), i.e.

Code: Select all

    static public bool SignificantDifference(double d1, double d2)
    {
        return !(Math.Abs(d1 - d2) < double.Epsilon);
    }
these four test cases return: true false true false. This is also what I would expect. So, the only difference between the two implementations of Utils.SignificantDifference() is the boolean sign they return. Or can you give me a set of figures which returns different results to the four test cases above?
Please find attached the third version of my demo project including a unit test showing that my calculation should be correct. So I get false, true, false, true with your numbers ( the tests are using nunit, but can easily migrated to mstest, if you prefer that ):
Image

Code: Select all

        [Test]
        public void SignificantDifferenceTest()
        {
            const double d1 = 1.0e020;  const double d3 = 1.00000000000000001e020;
                                        const double d4 = 1.0000000000000001e020;
            const double d2 = 1.0e-020; const double d5 = 1.00000000000000001e-020;
                                        const double d6 = 1.0000000000000001e-020;

            Trace.WriteLine( d1.SignificantDifference( d3 ) + " : " + d1.ToExactString() + " - " + d3.ToExactString() ); // false: ( 1.0e020  - 1.00000000000000001e020  )
            Assert.IsFalse ( d1.SignificantDifference( d3 ), "d1 shouldn't have a significant difference compared to d3" );
            Trace.WriteLine( d1.SignificantDifference( d4 ) + "  : " + d1.ToExactString() + " - " + d4.ToExactString() );// true:  ( 1.0e020  - 1.0000000000000001e020   )
            Assert.IsTrue  ( d1.SignificantDifference( d4 ), "d1 should have a significant difference compared to d4" );
            Trace.WriteLine( d2.SignificantDifference( d5 ) + " : " + d2.ToExactString() + " - " + d5.ToExactString() ); // false: ( 1.0e-020 - 1.00000000000000001e-020 )
            Assert.IsFalse ( d2.SignificantDifference( d5 ), "d2 shouldn't have a significant difference compared to d5" );
            Trace.WriteLine( d2.SignificantDifference( d6 ) + "  : " + d2.ToExactString() + " - " + d6.ToExactString() );// true:  ( 1.0e-020 - 1.0000000000000001e-020  )
            Assert.IsTrue  ( d2.SignificantDifference( d6 ), "d2 should have a significant difference compared to d6" );
        }
As you can see in the project there are some more double extensions now that should be useful to determine the things.
Is there some code that you've given me that produces these endless loops you mention? I would be very interested to see these endless loops in action. Apologies if you've already sent the code and I've missed it.
The second version of the demo project should have been prepared for the endless-loop already:
You can test it with my crashfix and a penetrationValue of 1.0e+015.
:wink:
Anyway, the third version is prepared specially for this case ( just use it in conjunction with my crashfix ) and to answer your next question.
These issues seems to be related to custom axes. If you comment out all references to constantLineAxis and referenceAxis in your code (and modify the code associated with currentVertAxisIdx) you will get something like the image here.
I think you may already know that Custom axes do not zoom and scroll automatically and that code has to be added to make them behave this way. There is an example of how to scroll custom axes in the Feature Demo of TeeChart in the "All Features" tab under "Welcome !\Axes\Scrolling multiple axes".

Or do you see the issues with Custom axes as being related to something other than zooming and scrolling? If so, could you please let me know?
I don't think that it is related to the custom axes only. If you look into the third version, I have just added the constant line to the default axes and the problem remains the same ( just use "0" instead of "1.0e+015" for the val ). It seems the root cause is that Ymin==Ymax and this case is not handled correctly.
I have also implemented parts of our zooming code into the project. If you think there is explicitly code missing for scrolling/panning, please be so kind and post the code here.

:idea: The next two weeks I will be in vacation. So you have some time to check and fix the code.

Thanks for your further investigation.
Attachments
tcharttest.constant.signals.forumversion-V3.zip
third version of the demo project
(188.04 KiB) Downloaded 1061 times
With best regards,
Oliver Trenkelbach

Siemens AG
Industry Sector
Drive Technologies Division
Motion Control Systems
Research and Development

http://www.siemens.com/motion-control

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: TChart has severe problems with constant series/lines

Post by Christopher » Tue Oct 30, 2012 4:08 pm

Hello Oliver,

Right. The following code now works without endlessly looping:

Code: Select all

private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      double val = 1000000000000000;
      double nextVal = 1000000000000000.1;
      var constantLine = new Steema.TeeChart.Styles.Line();
      constantLine.Chart = tChart1.Chart;
      tChart1.Series.Add(constantLine);
      constantLine.Add(0, val);
      constantLine.Add(9, nextVal);
    }
I downloaded the first test project you posted here ( tcharttest.constant.signals.forumversion.zip ) and adding the following line:

Code: Select all

private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            tChart1.Panel.MarginLeft = 200; //NEW LINE

            int samples = 10;
this resolved the first issue you mentioned in your first post. I then included the extra values in the penetrationValues array and ran the project; a video of this project running can be seen here:

http://screencast.com/t/QXNH2B632t

The second example project you posted (tcharttest.constant.signals.forumversion-V2.zip) I think would work okay if the relevant code was added to it to make the custom axis scroll. I think I mentioned some example code you could look at in the Feature Demo in one of my last posts to this thread.

When you are back at work, do please let me know and I can pass you a modified TeeChart.dll on to you for you to test. With any luck we won't be too far away from solutions which are going to be fine for your TeeChart needs.

Thank you,

Christopher Ireland
http://www.steema.com

Oliver@Siemens
Newbie
Newbie
Posts: 7
Joined: Thu Feb 03, 2011 12:00 am
Location: Erlangen
Contact:

Re: TChart has severe problems with constant series/lines

Post by Oliver@Siemens » Tue Nov 13, 2012 10:02 am

Hello Christopher,

I am back from my vacation.
When you are back at work, do please let me know and I can pass you a modified TeeChart.dll on to you for you to test.
Can you please provide us a modified TeeChart.dll that is based on our current version 4.1.2010.11302 ? If the modified dll works as expected will it be the official hotfix version or do you will make a hotfix release, that we are allowed to use officially? And last but not least can you confirm that the license and eula will not change with this hotfix?
I think you may already know that Custom axes do not zoom and scroll automatically and that code has to be added to make them behave this way. There is an example of how to scroll custom axes in the Feature Demo of TeeChart in the "All Features" tab under "Welcome !\Axes\Scrolling multiple axes".

Or do you see the issues with Custom axes as being related to something other than zooming and scrolling? If so, could you please let me know?
Like I mentioned in my last post I don't think that it is related to custom axis. To proof it I have applied the scrolling/panning code from the Feature Demo "Welcome !\Axes\Scrolling multiple axes" and provided another video as well as the modified sources:
http://img201.imageshack.us/flvplayer.s ... tphlicqosd
If I understand the demo code correctly, the checkboxes are only intended to limit the scrolling/panning.
But our problem is ( as shown in the video ) that the constant line is not scrolling/panning/moving vertically at all. No matter if it is attached to a custom axis or a default axis.
Attachments
tcharttest.constant.signals.forumversion-V4.zip
applied the scrolling/panning code from the Feature Demo "Welcome !\Axes\Scrolling multiple axes"
(188.46 KiB) Downloaded 1041 times
With best regards,
Oliver Trenkelbach

Siemens AG
Industry Sector
Drive Technologies Division
Motion Control Systems
Research and Development

http://www.siemens.com/motion-control

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: TChart has severe problems with constant series/lines

Post by Christopher » Tue Nov 13, 2012 3:17 pm

Hello Oliver,

Which framework do you want the test version of TeeChart.dll built for?

This test version will not have the same version number as the one you are using. This test TeeChart.dll assembly's legal usage will be exactly the same as for all other TeeChart.dll assemblies as per the license agreement.

Please let me know an email address and I'll send a TeeChart.dll onto you. Have a go with it and let's see where we've got to.

Thank you,

Christopher Ireland
www.steema.com

Oliver@Siemens
Newbie
Newbie
Posts: 7
Joined: Thu Feb 03, 2011 12:00 am
Location: Erlangen
Contact:

Re: TChart has severe problems with constant series/lines

Post by Oliver@Siemens » Wed Nov 14, 2012 9:05 am

Hello Christopher,
Which framework do you want the test version of TeeChart.dll built for?
I would prefer .Net Fx 3.5, but 2.0 would be fine also.
This test version will not have the same version number as the one you are using.
Changing the assembly or file version is not a problem for us. But if the hotfix is based on the latest release only, we will have some trouble.
Please let me know an email address and I'll send a TeeChart.dll onto you.
My email address is: Oliver_DOT_Trenkelbach_AT_siemens_DOT_com ( replace all _DOT_ with . and _AT_ with @ ). Its the same as the one used in the forum here, so maybe its easier for you to copy it from there.

You are welcome.
With best regards,
Oliver Trenkelbach

Siemens AG
Industry Sector
Drive Technologies Division
Motion Control Systems
Research and Development

http://www.siemens.com/motion-control

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: TChart has severe problems with constant series/lines

Post by Christopher » Wed Nov 14, 2012 9:33 am

Hello Oliver,

Okay, I've just sent you an email with the latest TeeChart.dll as an attachment.

Thank you,

Christopher Ireland
www.steema.com

Oliver@Siemens
Newbie
Newbie
Posts: 7
Joined: Thu Feb 03, 2011 12:00 am
Location: Erlangen
Contact:

Re: TChart has severe problems with constant series/lines

Post by Oliver@Siemens » Mon Nov 19, 2012 2:11 pm

Hello Christopher,

now that the crash is finally fixed, let's start with the other problem.

Have you already checked my post from above?
Like I mentioned in my last post I don't think that it is related to custom axis. To proof it I have applied the scrolling/panning code from the Feature Demo "Welcome !\Axes\Scrolling multiple axes" and provided another video as well as the modified sources:
http://img201.imageshack.us/flvplayer.s ... tphlicqosd
If I understand the demo code correctly, the checkboxes are only intended to limit the scrolling/panning.
But our problem is ( as shown in the video ) that the constant line is not scrolling/panning/moving vertically at all. No matter if it is attached to a custom axis or a default axis.
Do you have any clue what the problem might be?
With best regards,
Oliver Trenkelbach

Siemens AG
Industry Sector
Drive Technologies Division
Motion Control Systems
Research and Development

http://www.siemens.com/motion-control

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: TChart has severe problems with constant series/lines

Post by Sandra » Tue Nov 20, 2012 1:22 pm

Hello Oliver,
Like I mentioned in my last post I don't think that it is related to custom axis. To proof it I have applied the scrolling/panning code from the Feature Demo "Welcome !\Axes\Scrolling multiple axes" and provided another video as well as the modified sources:
http://img201.imageshack.us/flvplayer.s ... tphlicqosd
If I understand the demo code correctly, the checkboxes are only intended to limit the scrolling/panning.
But our problem is ( as shown in the video ) that the constant line is not scrolling/panning/moving vertically at all. No matter if it is attached to a custom axis or a default axis.
You have understood the sample code well, but If you check the values you are using when you do SetMinMax in checkbox1(red), you can see that the Min and Max values are same and for this reason the constant line is not scrolling/panning/moving vertically at all. I think is a correct behavior, so if you have the same vertical minimum and maximum, the line never scroll vertically. If you think the behavior must be different, please explain why, so, we can try to consider your arguments and find a good solution for you.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply