Chart label minimum separation problems when angled.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
biqpaulson
Newbie
Newbie
Posts: 93
Joined: Thu Apr 17, 2008 12:00 am

Chart label minimum separation problems when angled.

Post by biqpaulson » Mon Feb 06, 2017 2:39 pm

There seems to be a problem with label minimum separation when the label is not at an exact 90 or 180 degree increment.

This first example is when the labels on the bottom axis are at 90 degrees with a 1 percent minimum separation:
Min separation 1 percent - 90 degrees.PNG
Min separation 1 percent - 90 degrees.PNG (14.7 KiB) Viewed 18182 times
If the angle is changed by only one degree, on the next picture it is 89 degrees, the label separation is not by one percent separation but much much more:
Min separation 1 percent - 89 degrees.PNG
Min separation 1 percent - 89 degrees.PNG (13.46 KiB) Viewed 18183 times
Now this can be sort of fixed by making the minimum separation a value of zero percent as in this example where the angle is increased to 70 degrees with no problem:
Min separation 0 percent - 70 degrees.PNG
Min separation 0 percent - 70 degrees.PNG (16.06 KiB) Viewed 18175 times
Of course, with zero percent labels sometimes overlap and hence look horrible if the user resizes the form to a smaller size.

Is there a way to know when labels overlap and exclude them when the minimum separation is zero or is there a way to fix the one percent (or any percent value) separation so that it works appropriately when the angles are at a value of anything other than 90 and 180 degrees?

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

Re: Chart label minimum separation problems when angled.

Post by Christopher » Tue Feb 07, 2017 5:18 pm

Hello,

Which version of TeeChart.dll are you using? Using the latest public version and the following code:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = true;
      tChart1.Series.Add(typeof(Tower)).FillSampleValues();
      tChart1[0].Labels.Add("A first long label");
      tChart1[0].Labels.Add("A second long label");
      tChart1[0].Labels.Add("A third long label");
      tChart1[0].Labels.Add("A fourth long label");
      tChart1[0].Labels.Add("A fifth long label");
      tChart1[0].Labels.Add("A sixth long label");
      tChart1[0].Labels.Add("A seventh long label");
      tChart1[0].Labels.Add("An eighth long label");
      tChart1[0].Labels.Add("A ninth long label");
      tChart1[0].Labels.Add("A tenth long label");
      tChart1.Axes.Bottom.Labels.Angle = 70;
      tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Text;
      tChart1.Axes.Bottom.Labels.Separation = 0;

      tChart1.GetAxesChartRect += TChart1_GetAxesChartRect;
    }

    private void TChart1_GetAxesChartRect(object sender, GetAxesChartRectEventArgs e)
    {
      Rectangle rect = e.AxesChartRect;

      if (rect.Width < 50)
      {
        MessageBox.Show("Less than 50");
        rect.Width = 50;
        e.AxesChartRect = rect;
      }
    }
gives me the following:
https://www.screencast.com/t/knallgTg

this seems reasonable behaviour to me - how does it seem to you?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

biqpaulson
Newbie
Newbie
Posts: 93
Joined: Thu Apr 17, 2008 12:00 am

Re: Chart label minimum separation problems when angled.

Post by biqpaulson » Fri Feb 17, 2017 10:31 pm

The library that is being used for this issue is the latest ("Steema TeeChart for .Net 2016 4.1.2016.10260" - .Net 4.0)

I have been testing with and without 0 percent label separation and the application keeps spinning in the method GetAxisSeriesLabel.

The older library (Steema TeeChart for .NET 2016 4.1.2016.05120) did not cause a lock up/spinning although the older library was also causing labels to overlap.

In the latest library, 0 percent label separation will cause the spin more often but even 1 percent label separation causes the application to spin, albeit less often.

You should be able to duplicate the spin by using your code above but removing the minimum chart size line:

Code: Select all

tChart1.GetAxesChartRect += TChart1_GetAxesChartRect;
then resizing the chart to a small value.

The stack trace is in the picture below:
Spinning in GetAxisSeriesLabel.PNG
Spinning in GetAxisSeriesLabel.PNG (21.47 KiB) Viewed 18130 times
By the way, I do not want you to think that this is a "small chart" issue. I have large charts with only one or just two labels which are pretty large and causing the spinning in the library.

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

Re: Chart label minimum separation problems when angled.

Post by Christopher » Mon Feb 20, 2017 11:23 am

Hello,
biqpaulson wrote: By the way, I do not want you to think that this is a "small chart" issue. I have large charts with only one or just two labels which are pretty large and causing the spinning in the library.
I'm sorry, but I'm a little confused as to how I can reproduce the spinning you speak of. Would you please be so kind as to be a little more explicit, possibly with the aid of a Minimal, Complete, and Verifiable example as specified here?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

biqpaulson
Newbie
Newbie
Posts: 93
Joined: Thu Apr 17, 2008 12:00 am

Re: Chart label minimum separation problems when angled.

Post by biqpaulson » Tue Feb 21, 2017 3:20 pm

Like I said, just modify your code a bit. Here is a simple example which took me about 10 minutes to create.
  • Create a generic C# forms application.
  • Save it and then make sure that the .Net version is .Net 4.0.
  • Add a new TChart with no modifications.
  • Make sure that the "Steema TeeChart for .NET 2016 4.1.2016.10260" library is being used.
  • Add the code below.
  • Start the application and the application will spin on startup.
(I made sure it was not just because of the placement of the InitializeChart in the "Form1" constructor by adding the Shown event. If you uncomment the USE_SHOWN_EVENT line then the shown event will be used instead but the application still spins.)

Code: Select all

// #define USE_SHOWN_EVENT

using Steema.TeeChart;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace ResizeSpinningIssue
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
#if (USE_SHOWN_EVENT)
            Shown += new EventHandler(Form1_Shown);
#else
            InitializeChart();
#endif
        }

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

            Steema.TeeChart.Styles.Series TheSeries = new Steema.TeeChart.Styles.Points();
            tChart1.Series.Add(TheSeries);

            TheSeries.Add(1000, "A first long label");
            TheSeries.Add(2000, "A second long label");

            tChart1.Axes.Bottom.Labels.Angle = 70;
            tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Text;
            tChart1.Axes.Bottom.Labels.Separation = 0;
        }

#if (USE_SHOWN_EVENT)
        private void Form1_Shown(Object sender, EventArgs e)
        {
            InitializeChart();
        }
#endif
    }
}
The problem does not happen if you have only one label but two labels it happens every time on startup.

If I change the steema library reference in the project from the "Steema TeeChart for .NET 2016 4.1.2016.10260" library to the "Steema TeeChart for .NET 2016 4.1.2016.05120" library the spinning goes away.

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

Re: Chart label minimum separation problems when angled.

Post by Christopher » Wed Feb 22, 2017 11:30 am

Hello,

Many thanks for the MCVE, I have now been able to reproduce the problem. At the head of the Git project here, this problem does not occur, that is, it has already been 'fixed'. To workaround the issue, please add in the single line of code as indicated below.

Code: Select all

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

      Steema.TeeChart.Styles.Points TheSeries = new Steema.TeeChart.Styles.Points();
      tChart1.Series.Add(TheSeries);

      TheSeries.Add(1000, "A first long label");
      TheSeries.Add(2000, "A second long label");

      tChart1.Axes.Bottom.Increment = 1; //<- additional line
      tChart1.Axes.Bottom.Labels.Angle = 70;
      tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Text;
      tChart1.Axes.Bottom.Labels.Separation = 0;
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

biqpaulson
Newbie
Newbie
Posts: 93
Joined: Thu Apr 17, 2008 12:00 am

Re: Chart label minimum separation problems when angled.

Post by biqpaulson » Wed Feb 22, 2017 2:55 pm

Thanks.

Code: Select all

tChart1.Axes.Bottom.Increment = 1; //<- additional line
works in most cases but not in all of the cases. I have still seen a chart spin. Unfortunately the spin is normally when multiple of charts are being resized/refreshed and I don't know which chart it is that is doing the spinning. If I narrow it down further than I will post another example where the:

Code: Select all

tChart1.Axes.Bottom.Increment = 1; //<- additional line
does not work.

Sorry, I should have added that the stack trace for even the new spinning is still the one displayed above.

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

Re: Chart label minimum separation problems when angled.

Post by Christopher » Wed Feb 22, 2017 3:51 pm

Hello,

Please do not hesitate to send us further concise and accurate issue reports concerned TeeChart behaviour so we can quickly get on with their resolution!

Thank you very much for reporting your issues to us.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

biqpaulson
Newbie
Newbie
Posts: 93
Joined: Thu Apr 17, 2008 12:00 am

Re: Chart label minimum separation problems when angled.

Post by biqpaulson » Thu Apr 06, 2017 1:10 pm

Thank you very much. I am not sure what you have done because I do not see this issue as fixed in the release notes but we are no longer seeing this issue. We have not had any more spinning problems with the latest version of the library. This was a hindrance in doing any sort of testing because it would cause the application to spin at the most inopportune times while resizing the charts.

(I moved this, and edited it, from another thread where it was incorrectly placed. Sorry if it caused any issues.)

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

Re: Chart label minimum separation problems when angled.

Post by Christopher » Thu Apr 06, 2017 2:10 pm

biqpaulson wrote:Thank you very much. I am not sure what you have done because I do not see this issue as fixed in the release notes but we are no longer seeing this issue. We have not had any more spinning problems with the latest version of the library. This was a hindrance in doing any sort of testing because it would cause the application to spin at the most inopportune times while resizing the charts.

(I moved this, and edited it, from another thread where it was incorrectly placed. Sorry if it caused any issues.)
No problem. No, no mention of this issue was made in the release notes as no code changes were made. When I said the issue had been "fixed" (in inverted commas) I meant that a change must have been made to the code in relation to another issue which inadvertently fixed your issue. In these cases, where no changes to the code have been made, we do not add reference to the release notes.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply