A good getting started article: Using Microsoft's Chart Controls In An ASP.NET Application: Getting Started - 4GuysFromRolla.com
Or for a JavaScript solution use gRaphaël—Charting JavaScript Library
Domanda
I am trying to draw a line graph in ASP.NET. I want to import some data from an excel file and display them in a line chart on the browse.
So far I figured out how to import the data and display them in a grid. Now I want to take it to the next step and draw a line graph using that data.
Please point me in the right direction to some guides on how to draw a line graph in ASP.NET (C# only).
Soluzione
A good getting started article: Using Microsoft's Chart Controls In An ASP.NET Application: Getting Started - 4GuysFromRolla.com
Or for a JavaScript solution use gRaphaël—Charting JavaScript Library
Altri suggerimenti
If all you're after is a simple line graph, then rather than jumping at some third party libraries you can simply manipulate the length of an image, based on the data.
Something I have done a few times is take the data and turn it into a percentage, then make an images height (or width) that percent.
for example,
Say you have your data. Number of orders per day. your data may look like:
monday = 20 tuesday = 15 wednesday = 50 thursday = 30 friday = 10 saturday = 80 sunday = 3
Calculating the percentage for each day is simple. you would do something like:
Total sales = 203. And the formula [DaySales]/[TotalSales] * 100 will give you the percent for that day.
monday = 9.85% tuesday = 7.21% wednesday = 24.03% thursday = 14.42% friday = 4.80% saturday = 38.46% sunday = 1.44%
Simply set the image height/width to the appropriate day percentage and then you have yourself a nice little bar graph with accurate (within a pixel) lines
Read about the Graphics Class. It allows you to generate images. Getting these to show in a <img>
element is another exercise.