Page 1 of 1

Equally spread axis labels

Posted: Mon Feb 20, 2017 9:05 am
by 15678474
Hi,
We're experimenting with some label styles and like the fact that when using AxisLabelStyle.PointValue, axis labels are all lined up with the chart points.
We also like the fact that when using AxisLabelStyle.Value, axis labels are nicely spread along the axis. When there is not enough space, the interval between labels is increased, so that labels stay spread equally over the axis.

When there is not enough space when using AxisLabelStyle.PointValue however, individual labels are left out, depending on the available space, causing the labels not to be spread equally anymore.
What we're wondering now:
Is there an option to combine the behavior of both label styles, so that axis labels are still lined up with the chart points (AxisLabelStyle.PointValue), but when there is not enough space on the axis, to not hide individual labels, but just show 1 out of every 2, 3, 4,... labels, so that the labels are still spread nicely over the axis (AxisLabelStyle.Value)?

Re: Equally spread axis labels

Posted: Mon Feb 20, 2017 11:28 am
by Christopher
OMP wrote: Is there an option to combine the behavior of both label styles, so that axis labels are still lined up with the chart points (AxisLabelStyle.PointValue), but when there is not enough space on the axis, to not hide individual labels, but just show 1 out of every 2, 3, 4,... labels, so that the labels are still spread nicely over the axis (AxisLabelStyle.Value)?
A quick question - do you know if the gap between points, that is, the size of the TimeSpan between them, will be constant or not? If you cannot guarantee a constant gap value then your request is not going to be trivial to achieve.

Re: Equally spread axis labels

Posted: Mon Feb 20, 2017 2:44 pm
by 15678474
Christopher wrote: A quick question - do you know if the gap between points, that is, the size of the TimeSpan between them, will be constant or not? If you cannot guarantee a constant gap value then your request is not going to be trivial to achieve.
Yes, we assume that the gap between 2 points will always be 1 week, so this is constant.

Re: Equally spread axis labels

Posted: Thu Feb 23, 2017 9:20 am
by Christopher
Hello,

Apologies for the delay in my reply. I can see what you mean - I think the situation can be slightly bettered by setting the bottom axis' label angle to 90º, e.g.

Code: Select all

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

      DateTime now = DateTime.Now;
      Random rnd = new Random();

      for (int i = 0; i < 50; i++)
      {
        series.Add(now, rnd.Next(1000));
        now = now.AddDays(7);
      }


      tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yy hh:mm:ss";
      tChart1.Axes.Bottom.Labels.Angle = 90;
      tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.PointValue;
    }
but the gaps between the labels are still much bigger than when the Style is set to Auto. I have added this issue to our issue tracker with id=1801.

Re: Equally spread axis labels

Posted: Mon Feb 27, 2017 7:46 am
by 15678474
Christopher wrote:Apologies for the delay in my reply. I can see what you mean - I think the situation can be slightly bettered by setting the bottom axis' label angle to 90º
No problem, thank you for the hint and for adding the issue to the issue tracker.