Axis title being overwritten by axis labels

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
JCincotta
Newbie
Newbie
Posts: 8
Joined: Fri Jun 28, 2013 12:00 am

Axis title being overwritten by axis labels

Post by JCincotta » Mon Jul 15, 2013 8:23 pm

The attached image shows the y-axis title being overwritten by the y-axis labels. When this chart was first drawn, the max value on the y-axis was only 3-digits. But the user can interact with the chart changing the range up to 1,00,000. As this happens, the space reserved for the y-axis labels is not increased and the new labels overlap the y-axis title. Is there some setting that will cause the axis layout to dynamically recalculate as the range is changed? If not, is there a method I can call to ask TeeChart to update the layout reflecting the new range?
Attachments
Axis.png
Image showing the problem with axis label placement
Axis.png (173.08 KiB) Viewed 5821 times

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

Re: Axis title being overwritten by axis labels

Post by Sandra » Tue Jul 16, 2013 12:13 pm

Hello JCincotta,

I have made a simple code where you can use to positioning the title of axes correctly and prevent the overlap:

Code: Select all

  private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      tChart1.Header.Visible = false;
      tChart1.Legend.Alignment = LegendAlignments.Bottom;
      Random rnd = new Random(); 
      for (int i = 0; i < 3; i++)
      {
        new Steema.TeeChart.Styles.Line(tChart1.Chart);
       
        for (int j = 0; j < 20; j++)
        {
          tChart1[i].Add(j, rnd.Next(5000000)); 
        }
      }
      tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
      tChart1.Axes.Left.Title.Visible = true;
      tChart1.Axes.Left.Title.Text = "Y values of Line Series";
      tChart1.Axes.Left.Title.Angle = 90; 
      tChart1.Draw();
      PlaceAxes(0, 0, 0, 0, 0);
      tChart1.AfterDraw += new PaintChartEventHandler(tChart1_AfterDraw);
    
      tChart1.Draw();
    }

  
    void tChart1_AfterDraw(object sender, Graphics3D g)
    {
      PlaceAxes(0, 0, 0, 0, 0);
    }

    private void PlaceAxes(int nSeries, int NextXLeft, int NextXRight, int MargLeft, int MargRight)
    {
      const int extraPos = 12;
      const int extraMargin = 50;
      //Variable 
      int MaxLabelsWidth;
      int lenghtTicks;
      int extraSpaceBetweenTitleAndLabels;

      MaxLabelsWidth = tChart1.Axes.Left.MaxLabelsWidth();
      lenghtTicks = tChart1.Axes.Left.Ticks.Length;
      extraSpaceBetweenTitleAndLabels = (tChart1.Axes.Left.Title.Width);//- tChart1.Axes.Custom[nSeries].MaxLabelsWidth());
      if (tChart1.Axes.Left.Title.Visible)
      {
        tChart1.Axes.Left.RelativePosition = NextXLeft;
        NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraSpaceBetweenTitleAndLabels + extraPos);
        MargLeft = MargLeft + extraMargin;
      }
      tChart1.Panel.MarginLeft = MargLeft;
    
    }
Could you tell us if previous code works in your end?

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

JCincotta
Newbie
Newbie
Posts: 8
Joined: Fri Jun 28, 2013 12:00 am

Re: Axis title being overwritten by axis labels

Post by JCincotta » Mon Jul 22, 2013 10:12 pm

No, I'm afraid this doesn't help. In my graph, Panel.MarginLeft is always just 3.0 and setting it to a larger value just gives me wasted space along the left edge.

Fooling around with the many properties on the chart (thanks for those, btw!), I think I found my answer. I believe all that is necessary is:

Code: Select all

    tChart1.Axes.Left.FixedLabelSize = false;

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

Re: Axis title being overwritten by axis labels

Post by Sandra » Tue Jul 23, 2013 11:52 am

Hello JCincotta,

Thanks for your information. I am glad you have found a good solution for you :). On the other hand, if you have any problems please let me know.

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