C#图表旋转标签 [英] C# chart rotate labels

查看:367
本文介绍了C#图表旋转标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的图表,我想在x轴上的标签旋转45度。我做错了什么?

I have a simple chart, and I'd like the labels on the x-axis to be rotated 45 degrees. What am I doing wrong?

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

输出为:

我正在使用系统的图表。

I'm using the charting stuff from System.Web.UI.DataVisualization.Charting.

推荐答案

文档说Series.LabelAngle设置数据点标签角度, )是图表上方的标签。

The documentation says that Series.LabelAngle sets data point label angle, which (I think) is a label above the chart's column.

要设置轴标签的角度,请尝试以下操作:

To set an angle of axis labels try this one:

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

这篇关于C#图表旋转标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆