[英]DataVisualization.Chart, how can I make the X-axis interval larger?
guys! 伙计们!
I'm trying to build a graph, using Chart from System.Web.UI.DataVisualization.Charting namespace. 我正在尝试使用System.Web.UI.DataVisualization.Charting命名空间中的Chart来构建图形。
I have int values on Y-axis and TimeSpan (converted to string) on X-axis. 我在Y轴上有int值,在X轴上有TimeSpan(转换为字符串)。 But I have too many TimeSpan values (1440 - every minute of a day), so they cant fit one next to another.
但是我有太多的TimeSpan值(1440 - 一天中的每一分钟),所以他们不能一个接一个。 (sorry for my english).
(对不起我的英语不好)。 So I decided to display not every time value (every minute), but with some interval (ie every 30 minutes or every hour).
所以我决定不是每次显示值(每分钟),而是显示一些间隔(即每30分钟或每小时)。 The question is: how can I make a bigger interval on the X-axis?
问题是:如何在X轴上创建更大的间隔? I don't want the labels to be like this: 00:00, 00:01, 00:02, etc. But I want them to be like: 00:00, 00:30;
我不希望标签是这样的:00:00,00:01,00:02等。但我希望它们像:00:00,00:30; 01:00, 01:30, etc.
01:00,01:30等
PS: I tried this way, but it didn't work: PS:我试过这种方式,但它不起作用:
foreach (var item in data)
{
point = new DataPoint();
if (counter % 60 == 0)
{
point.AxisLabel = item.Key.ToString(@"hh\:mm");
}
else
{
point.AxisLabel = String.Empty;
}
Thank you! 谢谢! :)
:)
Use the Axis.Interval
property in conjunction with the Axis.IntervalType
property. 将
Axis.Interval
属性与Axis.IntervalType
属性结合使用。 For example 例如
Axis xaxis = chart.ChartAreas[0].AxisX;
xaxis.IntervalType = DateTimeIntervalType.Minutes;
xaxis.Interval = 30;
should get you the 30 minute spacing that you desire. 应该给你30分钟的间距你想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.