Solved

Using DateTime with the ASP.net/C# Chart Control

Posted on 2009-07-04
1
1,911 Views
Last Modified: 2013-11-08
Hi,

I am having trouble with DateTimes in ASP.net Charting control. I want a graph with time across the bottom and then values as the Y values.

I have stubbed a program below for you to see where I am so far, the problem being the graph only uses the Date and not the Time also. This is obviously not very useful to me, as I end up with the same Date written along the XAxis and no way to see the time.

I have looked around for the answer to this and can't find it anywhere, so any help appreciated.
Series series1 = new Series("Input");
            
            series1.ChartType = SeriesChartType.Line;
            
            Random r = new Random();
            Double prev = 10;
            Double change = 10;
            for (int x = 0; x < 10; x++)
            {
                change = prev - 0.5 + r.NextDouble();
                
                series1.Points.AddXY(DateTime.Now.AddMinutes(x), change);
                prev = change;
            }
            series1.ToolTip = "#VALX";
            Chart1.Series.Add(series1);

Open in new window

0
Comment
Question by:kingy0489
1 Comment
 
LVL 9

Accepted Solution

by:
tetorvik earned 250 total points
ID: 24781266
you can alter the appeareance of the DateTime object by applying AxisX label style formating like below:

hope this helps!
Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "dd/MM hh:mm";

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question