Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

10 Experts available now in Live!

Get 1:1 Help Now