Huge margins on plots with long rotated axis labels

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Huge margins on plots with long rotated axis labels

Post by Michal Blazejczyk » Tue Jun 01, 2010 2:57 am

Hi,

We are a few versions behind with TeeChart (3.5.3188.18561), but all has been working fine until now... We have a few charts with fairly long bottom axis labels, so we are rotating the text. The problem is that this leaves huge white margins under the chart...
Steema - Huge margin.png
Steema - Huge margin.png (7.45 KiB) Viewed 7937 times
Is there a way to fix this? We would rather not update to a recent version of TeeChart because there are always many backward-compatibility issues, and we simply have no time for that.

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Huge margins on plots with long rotated axis labels

Post by Yeray » Wed Jun 02, 2010 12:14 pm

Hi Michal,

Yes, I've seen that the bottom margin calculated when having long bottom axis labels with an oblique angle seems to be like the angle were 90.
I've added it to the defect list to be revised in future releases (TF02014926).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Re: Huge margins on plots with long rotated axis labels

Post by Michal Blazejczyk » Wed Jun 02, 2010 3:19 pm

Hi,

Does it mean that it doesn't work well in even recent versions, either? That's sad... :(

Best,
Michal

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Huge margins on plots with long rotated axis labels

Post by Yeray » Wed Jun 02, 2010 3:30 pm

Hi Michal,

What I've seen is that we fixed a similar problem some time ago that may be related (TF02013509) but it's not exactly the same.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Re: Huge margins on plots with long rotated axis labels

Post by Michal Blazejczyk » Thu Jun 03, 2010 10:44 pm

Hi Yeray,

In this case I'm even more surprised because issue TF02013509 you mention is a manifestation of the same problem that I described. It was reported in October 2008, and it is still not fixed???

Could you suggest a workaround, i.e. a way of detecting this situation, and manually making the plot area bigger so that there is no white space under the axis labels?

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Huge margins on plots with long rotated axis labels

Post by Narcís » Fri Jun 04, 2010 11:40 am

Hi Michal,
In this case I'm even more surprised because issue TF02013509 you mention is a manifestation of the same problem that I described. It was reported in October 2008, and it is still not fixed???
It seems TF02013509 fixed this for labels at 90 degrees but not for other possible values :(
Could you suggest a workaround, i.e. a way of detecting this situation, and manually making the plot area bigger so that there is no white space under the axis labels?
What about something as the code below? You can tweak the AfterDraw event a little bit to enhance the workaround.

Code: Select all

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

    private void InitializeChart()
    {
      tChart1.Legend.Visible = false;

      Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

      string label = "this is a very long label for testing";

      line1.Add(3, label);
      line1.Add(5, label);
      line1.Add(7, label);
      line1.Add(2, label);

      tChart1.Axes.Bottom.Labels.Angle = 0;

      tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
      tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);

      Timer timer1 = new Timer();
      timer1.Interval = 1000;
      timer1.Tick += new EventHandler(timer1_Tick);
      timer1.Enabled = true;
    }

    void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      int angle = tChart1.Axes.Bottom.Labels.Angle;

      if (angle != 0)
      {
        int labelSize = tChart1.Axes.Bottom.MaxLabelsWidth();
        double factor = Math.Sin(angle);
        double margin = labelSize * Math.Abs(factor);

        tChart1.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels;
        tChart1.Panel.MarginBottom = margin;
      }
    }

    void timer1_Tick(object sender, EventArgs e)
    {
      tChart1.Axes.Bottom.Labels.Angle = (tChart1.Axes.Bottom.Labels.Angle + 10 % 360);
    }

    void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
    {
      if (sender.Equals(tChart1.Axes.Bottom))
      {
        if (e.LabelText.Length > 15)
        {
          e.LabelText = string.Format("{0}{1}", e.LabelText.Substring(0, 15), "...");
        }
      }
    }
Best Regards,
Narcís Calvet / 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