Page 1 of 1

Axis title being overwritten by axis labels

Posted: Mon Jul 15, 2013 8:23 pm
by 15666433
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?

Re: Axis title being overwritten by axis labels

Posted: Tue Jul 16, 2013 12:13 pm
by 10050769
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,

Re: Axis title being overwritten by axis labels

Posted: Mon Jul 22, 2013 10:12 pm
by 15666433
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;

Re: Axis title being overwritten by axis labels

Posted: Tue Jul 23, 2013 11:52 am
by 10050769
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,