Page 1 of 1

Huge margins on plots with long rotated axis labels

Posted: Tue Jun 01, 2010 2:57 am
by 9641603
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 8665 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

Re: Huge margins on plots with long rotated axis labels

Posted: Wed Jun 02, 2010 12:14 pm
by yeray
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).

Re: Huge margins on plots with long rotated axis labels

Posted: Wed Jun 02, 2010 3:19 pm
by 9641603
Hi,

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

Best,
Michal

Re: Huge margins on plots with long rotated axis labels

Posted: Wed Jun 02, 2010 3:30 pm
by yeray
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.

Re: Huge margins on plots with long rotated axis labels

Posted: Thu Jun 03, 2010 10:44 pm
by 9641603
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

Re: Huge margins on plots with long rotated axis labels

Posted: Fri Jun 04, 2010 11:40 am
by narcis
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), "...");
        }
      }
    }