guys!
I'm trying to build a graph, using Chart from System.Web.UI.DataVisualization.Charting namespace.
I have int values on Y-axis and TimeSpan (converted to string) on X-axis. But I have too many TimeSpan values (1440 - every minute of a day), so they cant fit one next to another. (sorry for my english). So I decided to display not every time value (every minute), but with some interval (i.e. every 30 minutes or every hour). The question is: how can I make a bigger interval on the X-axis? 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; 01:00, 01:30, etc.
PS: I tried this way, but it didn't work:
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. 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.