我有一个简单的图表,我希望x轴上的标签旋转45度。我做错了什么?
Chart c = new Chart();
c.ChartAreas.Add(new ChartArea());
c.Width = 200;
c.Height = 200;
Series mySeries = new Series();
mySeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 });
mySeries.LabelAngle = 45; // why doesn't this work?
c.Series.Add(mySeries);
输出为:
我正在使用System.Web.UI.DataVisualization.Charting中的图表工具。
发布于 2011-05-19 00:52:54
文档中说Series.LabelAngle设置了数据点标签角度,这(我认为)是图表列上方的标签。
要设置轴标签的角度,请尝试此选项:
var c = Chart1;
c.ChartAreas.Add(new ChartArea());
c.Width = 200;
c.Height = 200;
Series mySeries = new Series();
mySeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 });
//mySeries.LabelAngle = -45; // why doesn't this work?
c.Series.Add(mySeries);
c.ChartAreas[0].AxisX.LabelStyle.Angle = 45; // this works
发布于 2011-05-19 01:09:09
以下是我通常旋转X轴标签的方式。
ChartArea area = new ChartArea();
area.AxisX.IsLabelAutoFit = true;
area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30;
area.AxisX.LabelStyle.Enabled = true;
结果
上面要查看的关键属性/行是"LabelAutoFitStyle“。
发布于 2015-03-11 01:50:48
我需要以下几行代码才能让它工作:
chartarea.AxisX.LabelStyle.Angle = -90;
chartarea.AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
chartarea.AxisX.IsLabelAutoFit = false;
https://stackoverflow.com/questions/6047961
复制相似问题