0

as the title says, I need to disable Interval Labels from AxisY but only mantaining the extremes maximum and minimum axis y labels, is this possible?

I searched at this website and there nothing like my question...

Also, I need to know if the maximum axis y label and minimum axis y label can be rotated +45° and -45° respectively

Thank you!

TaW
  • 53,122
  • 8
  • 69
  • 111

1 Answers1

0

I think you will have to use two CustomLabels.

Note the they all must have the same angle.

Use a suitable delta, i.e. a small number that determines the range of the label, and a suitable format..

ChartArea ca = chart1.ChartAreas[0];
Series series = chart1.Series[0];
double delta = 0.1;

double yMin = series.Points.Min(x => x.YValues[0]);
double yMax = series.Points.Max(x => x.YValues[0]);
CustomLabel clyMax = new CustomLabel();
CustomLabel clyMin = new CustomLabel();

clyMax.FromPosition = yMax - delta;
clyMax.ToPosition = yMax + delta;
clyMin.FromPosition = yMin - delta;
clyMin.ToPosition = yMin + delta;

clyMax.Text = yMax.ToString("0.0");
clyMin.Text = yMin.ToString("0.0");

ca.AxisY.LabelStyle.Angle = 45;

ca.AxisY.CustomLabels.Add(clyMax);
ca.AxisY.CustomLabels.Add(clyMin);
TaW
  • 53,122
  • 8
  • 69
  • 111
  • Hello... sorry for not reply this, i was too busy.... anyway, I can't make it work, it loses all the label... My graph is based on this code from this webpage https://stackoverflow.com/questions/43861842/how-to-add-more-y-axes-to-mschart-with-different-scale-at-left-or-right-side I have the graoh with 6 axis created by method CreateAxisY , my objective is make the axis Y lines stay together (i dont have it with the axis y label ), so that why i need to take the interval labels off and make the extreme max min label on 45°. Hope you understand me, Sorry for my english – Mangostain Jun 14 '18 at 19:54
  • Yes, all label go away once the axis displays customlables. And these only show if you manage to set their To-&FromPosition correctly. But I can't help more with so little to go by.. – TaW Jun 14 '18 at 20:42
  • Ok, don't worry, thanks anyway, this detail is not a major priority to finish my app. Thanks! – Mangostain Jun 14 '18 at 21:17