Angled label white space and start of label cut off.

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

Angled label white space and start of label cut off.

Post by biqpaulson » Thu Mar 09, 2017 4:39 pm

Hello,

Is there anything we can do about:
  • Angled labels causing a large amount of white space under the chart
  • Beginning of long angled labels being cut off.
If the labels are small (one character here) then it looks like:
ChartWithSmallLabel.PNG
ChartWithSmallLabel.PNG (18.32 KiB) Viewed 11869 times
If the labels are long then the two issues are seen:
ChartWithLongLabel.PNG
ChartWithLongLabel.PNG (19.78 KiB) Viewed 11870 times
The Red rectangle is the white space and grows with label length.
The Blue rectangle shows the cut of of the label on the left of the panel.
  • Make a new form.
  • Add a TChart.
  • Add a trackbar.
  • Add the code below.
    The code I used is:

    Code: Select all

    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;
    using Steema.TeeChart;
    
    namespace NoRefreshOnHorizBar
    {
        public partial class Form1 : Form
        {
            private const string LONG_TEXT_STRING = "aBcDe FgHiJkL MnOpQrS tUvWx Yz";
            //        private Steema.TeeChart.Styles.Bar TheSeries;
            private Steema.TeeChart.Styles.Bar TheSeries;
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                SetupTrackBar();
                SetupChart();
            }
    
            private void SetupTrackBar()
            {
                trackBar1.Minimum = 1;
                trackBar1.Maximum = LONG_TEXT_STRING.Length;
                trackBar1.Value = 1;
            }
    
            private void SetupChart()
            {
                tChart1.Aspect.View3D = false;
                tChart1.Legend.Visible = false;
                tChart1.Axes.Bottom.Labels.Angle = 30;
                tChart1.Axes.Bottom.Labels.Separation = 0;
                tChart1.Axes.Bottom.FixedLabelSize = false;
                TheSeries = new Steema.TeeChart.Styles.Bar();
                for (int ii = 0; ii < 10; ii++)
                {
                    TheSeries.Add(ii, LONG_TEXT_STRING.Substring(0, trackBar1.Value));
                }
                tChart1.Series.Add(TheSeries);
    
                TheSeries.Marks.Visible = false;
    
                ResetLabels();
            }
    
            private void ResetLabels()
            {
                if (TheSeries == null) return;
    
                for (int jj = 0; jj < TheSeries.Labels.Count; jj++)
                {
                    TheSeries.Labels[jj] = LONG_TEXT_STRING.Substring(0,trackBar1.Value);
                }
                tChart1.Refresh();
            }
    
            private void trackBar1_Scroll(object sender, EventArgs e)
            {
                ResetLabels();
            }
        }
    }
    

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

Re: Angled label white space and start of label cut off.

Post by Christopher » Thu Mar 09, 2017 5:14 pm

Hello,

For the red rectangle you can use the GetAxesChartRect to customize the size of the Chart Rectangle, e.g.:

Code: Select all

    Line series;
    private void InitializeChart()
    {
      series = new Line(tChart1.Chart);

      tChart1.Legend.Visible = false;

      for (int i = 0; i < 10; i++)
      {
        series.Add(i, i, "This is a relatively long string for a label");
      }

      tChart1.Axes.Bottom.Labels.Angle = 45;
      tChart1.GetAxesChartRect += TChart1_GetAxesChartRect;
    }

    private void TChart1_GetAxesChartRect(object sender, GetAxesChartRectEventArgs e)
    {
      Rectangle rect = e.AxesChartRect;
      rect.Height += 90;
      e.AxesChartRect = rect;
    }
As for the blue rectangle, I'm not sure exactly what you would like to do about it - could you please give me a clearer indication of what you would expect to see?
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: Angled label white space and start of label cut off.

Post by biqpaulson » Thu Mar 09, 2017 5:25 pm

Hi:

For the "blue" example, it seems to me that when you (steema) scale the chart to fit in the panel, you would want to take into consideration angled labels, since the outside bounds of the label are larger than the chart.left. Therefore, the chart should be scaled so it fits.

Thanks

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

Re: Angled label white space and start of label cut off.

Post by biqpaulson » Thu Mar 09, 2017 8:06 pm

I am a little concerned about the white space (red rectangle) fix. Does this mean that you want me to figure out what percentage is being lost each time the user changes the size of the label and somehow calculate that value, subtract the calculated value from the oversized chart?

For one character the white space looks like it could be correct. For each subsequent character that the user might add we would have to know how much white space is being added per character being added.

1) Won't we then have to remove this need space shrinkage once Steema fixes the growth problem?
2) Can you explain what is making the growth of white space and how much we need to calculate to remove each time a new character is added?

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

Re: Angled label white space and start of label cut off.

Post by Christopher » Thu Mar 09, 2017 9:26 pm

biqpaulson wrote: For the "blue" example, it seems to me that when you (steema) scale the chart to fit in the panel, you would want to take into consideration angled labels, since the outside bounds of the label are larger than the chart.left. Therefore, the chart should be scaled so it fits.
Just to confirm: that if the label cannot be rendered fully on the chart left, it should not be rendered at all? If so, I will add this as a feature request.
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

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

Re: Angled label white space and start of label cut off.

Post by Christopher » Thu Mar 09, 2017 9:34 pm

biqpaulson wrote: 1) Won't we then have to remove this need space shrinkage once Steema fixes the growth problem.
2) Can you explain what is making the growth of white space and how much we need to calculate to remove each time a new character is added?
There is a chance these two questions are related - that is, once a reliable algorithm has been determined to calculated the vertical height of a label at an angle, then the issue may be solved on both your side and ours. We will look into such an algorithm, and have entered the issue in our issue-tracking database with id=1815.
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: Angled label white space and start of label cut off.

Post by biqpaulson » Fri Mar 10, 2017 8:35 pm

Christopher wrote:
biqpaulson wrote: For the "blue" example, it seems to me that when you (steema) scale the chart to fit in the panel, you would want to take into consideration angled labels, since the outside bounds of the label are larger than the chart.left. Therefore, the chart should be scaled so it fits.
Just to confirm: that if the label cannot be rendered fully on the chart left, it should not be rendered at all? If so, I will add this as a feature request.
If the label and chart can be displayed by scaling the chart smaller, the answer is no. If the label still does not fit then the answer is yes.

Post Reply