Solved

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

Posted on 2009-07-04
1
1,931 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

632 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