Solved

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

Posted on 2009-07-04
1
1,902 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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now