Search code examples
c#.netteechart

Teechart: bottom axes label angle


I'm using Teechart for .net V3.

When trying to rotate the X-labels to 45° some of the labels are not displayed, but if the angle is set to 90° it is OK.

Please see the following images:

This is 45° rotation: 45° rotation

This is 90° rotation: enter image description here

Is it possible to show all the labels with 45° angle?


Solution

  • I think you can use custom labels to achieve all labels appear when you use an angle of 45º. You can do something as next code:

    private Steema.TeeChart.TChart tChart1; 
    public Form1()
    {
      InitializeComponent();
      tChart1 = new Steema.TeeChart.TChart();
      this.Controls.Add(tChart1);
      tChart1.Left = 100;
      tChart1.Top = 50;
      tChart1.Width = 500;
      tChart1.Height = 350; 
      tChart1.Dock = DockStyle.Fill; 
      InitialzieChart(); 
    }
    private void InitialzieChart()
    {
      Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
      DateTime dt = DateTime.Today;
      Random rnd = new Random();
      bar1.XValues.DateTime = true; 
      //bar1.date
      for (int i = 0; i < 20; i++)
      {
        bar1.Add(dt, rnd.Next(100));
        dt = dt.AddDays(5); 
      }
    
      tChart1.Axes.Bottom.Labels.Angle = 45;
      tChart1.Panel.MarginLeft = 10;
      tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Bottom; 
      AddCustomLabels(); 
    }
    private void AddCustomLabels()
    {
      tChart1.Axes.Bottom.Labels.Items.Clear();
      for (int i = 0; i < tChart1[0].Count; i++)
      {
        tChart1.Axes.Bottom.Labels.Items.Add(tChart1[0].XValues[i], DateTime.FromOADate(tChart1[0].XValues[i]).ToLongDateString()); 
      }
    }
    

    Could you tell us if previous code works in your end?

    Thanks,