Displaying every label on X-Axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Jens Ramlow
Newbie
Newbie
Posts: 13
Joined: Fri Sep 22, 2017 12:00 am
Location: Berlin, Germany

Displaying every label on X-Axis

Post by Jens Ramlow » Tue Oct 17, 2017 9:32 am

Hello Steema team, sorry to bother you again,

I'm using Steema's TeeChart.WPF.

The chart I'm implementing contains three Series from TeeChart.WPF.Styles.Line and TeeChart.WPF.Styles.Points.

TeeChart is adjusting the X-Axis labeling to prevent overlapping etc.
I would like to make sure that every label within the visible range gets drawn.

I'm adjusting the X-axis' properties with

Code: Select all

C#
                leftAxis.Labels.Font.Size = leftAxis.Title.Font.Size;
                leftAxis.Labels.Font.Name = leftAxis.Title.Font.Name;
                leftAxis.Labels.Font.Color = leftAxis.Title.Font.Color;
                leftAxis.Grid.Visible = true;
                leftAxis.Grid.Color = Colors.DarkGray;
                //leftAxis.Grid.DrawEvery = 1;
                leftAxis.MinorGrid.Visible = false;
                leftAxis.MinorTicks.Visible = false;
                leftAxis.Ticks.Color = leftAxis.Grid.Color;
                leftAxis.TickOnLabelsOnly = true;
                leftAxis.Increment = 1.0;
                leftAxis.AutomaticMaximum = false;
                leftAxis.AutomaticMinimum = false;
In the example screenshot, label for "Station 4" is missing but occasionally appears if I pan to the left.
station4 missing.PNG
the label for "Station 4" is missing
station4 missing.PNG (11.85 KiB) Viewed 8373 times
How can I make sure all lables are drawn?

Thank you again.
Yours, Jens

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Displaying every label on X-Axis

Post by Christopher » Tue Oct 17, 2017 4:48 pm

Hello Jens,
Jens Ramlow wrote: How can I make sure all lables are drawn?
One way to ensure all labels are always drawn is to use the 'custom labels' Items collection, e.g.

Code: Select all

    Points series;
    Random rnd = new Random();

    private void InitializeChart()
    {
      series = new Points(tChart1.Chart);

      for (int i = 0; i < 20; i++)
      {
        double val = rnd.Next(0, 500);
        series.Add(i, val);
        AxisLabelItem item = tChart1.Axes.Bottom.Labels.Items.Add(i, "Station " + i.ToString());
        item.Font.Color = Colors.Red;
      }

      tChart1.Axes.Bottom.Labels.Angle = 45;
      MarksTip tool = new MarksTip(tChart1.Chart);
      tool.Style = MarksStyles.LabelValue;
      tool.Series = series;
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Jens Ramlow
Newbie
Newbie
Posts: 13
Joined: Fri Sep 22, 2017 12:00 am
Location: Berlin, Germany

Re: Displaying every label on X-Axis

Post by Jens Ramlow » Wed Oct 18, 2017 7:49 am

Hello Christopher,

Thank you! That's working as expected and resolves my problem.

Yours, Jens

Post Reply