Solved

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

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
parse string in c# 5 41
How we can add Dten600.dll in GAC in c#. 18 55
C# How to display the first five answers that have smallest value? 16 43
msiexec won't run 4 33
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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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