This tutorial will teach you how to Create a Chart Control in ASP.NET 4.0

Creating a basic Chart Control in ASP .NET 4.

The purpose of this tutorial is to explain how to create a simple chart control and have it grab data
from a database. We will create a very simple Table inside our database that will show the productivity
of an imaginary worker. We will then display them on a chart for a better view of how he/she is doing.

For a More Basic Overview of Databases and ASP.NET go
Here

Overview

1. Create the database and table
2. Create the column chart control
3. Tweaking the chart

Create the Database and Table

1. Right click on your project in solution explorer and navigate to à Add à
New Item
2. Select SQL Server Database from the windows that pops up
3. Name the Database Productivity.mdf
4. Open it by double click
5. Add two new columns to your table WeekID(int) and ItemsDone(int)

6. Make the WeekID column is a Primary Key for the table right click on the WeekID column and navigate toà
Set Primary Key
7. Now we can set the identity of the key so that it auto increments itself, so switch (Is Identity) to Yes.

8. Add data to the table so save the table and name it Employee1
9. Right Click on the Employee1 and Navigate to à Show Table Data
10. Now fill out the table to reflect the Data I have filled in below. Once this is complete we are finished Creating the SQL Table and we can then move on to creating a Chart Control.


Create a Column Chart Control

In Order to create a Chart Control we have to have a Page to put it on so let's start with that


1. Right Click on your project and navigate to ->Add->New Item
2. Select Web Form and Name it PayRoll.aspx
3. Open up the page and go to Design View
4. Then we need to go to the Toolbar and Drag a Chart Item from the Data Section of the Toolbox onto our Web Form. This will create a Chart Control, but we need to link it to the database on order for it to get our information.
5. Next we need to click the Smart Tag of our object found here

6. Choose New Data Source from the Data Source Drop Down Box
7. This will bring up a wizard that will let you connect your database to your Chart
                a. On the first Window Choose SQL Database and Name it Employee1
                b. Choose your Connection String or have it create one for you I named mine ConnectionString    
                c. On the window where you select columns you should have the * selected
                 which means all data this is fine
                d. On the final window you can choose to click the Test Query button and you should see
                 these results after a few seconds, if so hit Finish and you are done with linking the Chart
8. After this Click on the Chart's Smart Tag one more time and edit the x Value Member and Y Value Member drop down boxes to appear as below

9. At this point you should be able to run the page and see your chart with all of the data

Tweaking the Chart

Notice that when you view the chart it has no text or labels on it, it could confuse some people so let's put some labels on there for the end user.


1. Right Click on the Chart and navigate to ->Properties
2. Select the Chart Areas Property under Chart and click the ellipses button(...) next to the word (Collection)
3. Then select the ellipses button next to the Axes property on the new popup window
4. This will bring us to where we can add labels for our AxesChange the Label Property Of the X Axis to say Weeks and Change the Label Property of the Y axis to say Items Done.
5. One more step to add a Table Title will Make it look even better so Go back to the Chart Properties and select the ellipses button next to the Titles Property
6. Click the Add button at the bottom Then change the (Text) property to say Productivity of Employee1 Over 7 Weeks
7. Now your table should look much better when you Load the Page

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.


You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.