How to display data using asp.net chart control?

How to display data using asp.net chart control?, someone asked me to explain?

In this article we will discuss, how to display data using asp.net chart control. We want to display weekly visitors of the website.

Step 1: Drag and drop chart control from the toolbox.

Step 2: Copy and paste the following code.

    <asp:Chart ID="Chart2" runat="server" Width="350">
            <asp:Title Text="website visitors">
            <asp:Series Name="Series1" ChartArea="ChartArea1">
                   <asp:DataPoint AxisLabel="sun" YValues="800" />
                   <asp:DataPoint AxisLabel="mon" YValues="900" />
                   <asp:DataPoint AxisLabel="tue" YValues="700" />
                   <asp:DataPoint AxisLabel="wed" YValues="900" />
                   <asp:DataPoint AxisLabel="thr" YValues="600" />
                   <asp:DataPoint AxisLabel="fri" YValues="750" />
                   <asp:DataPoint AxisLabel="sat" YValues="950" />
            <asp:ChartArea Name="ChartArea1">
                <AxisX Title="week">
                <AxisY Title="visitors per day">

In chart we need to provide title for the chart using <Titles>.I There are two main components series & chartAreas.

Series: It is a collection of data points

ChartAreas: we have to provide title for x-axis and y-axis. Here AxisX elements denotes the visitors of website and AxisY for week.

Step 3: Please make sure to register the assembly top of the page.

<%@ Register Assembly="System.Web.DataVisualization,Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>


Run the application and view the output displaying data in a barchart as expected.


display weekly visitors of website using chart control in asp.net

Post your comments / questions