从 AxisY 禁用间隔标签

Disable Interval Label from AxisY

正如标题所说,我需要禁用 AxisY 的间隔标签,但只保留极端最大和最小轴 y 标签,这可能吗?

我在该网站上进行了搜索,没有找到与我的问题相符的内容...

另外,我想知道最大y轴标签和最小y轴标签是否可以分别旋转+45°和-45°

谢谢!

我认为您将不得不使用两个 CustomLabels

注意它们必须有相同的角度。

使用合适的增量,即确定标签范围的小数字,以及合适的格式..

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);