SasqChart
Home
Home
Chart Gallery
Thumbs
Bar Charts
Stacked Bar
Line Charts
Area Charts
Stacked Area
Pie Charts
Mixed Charts
Chart Styles
Axis Options
Layout Options
ASP.Net Tutorials
Base Example
DataSet Bind
WinForm Tutorials
Base Example
DataSet Bind
  Forums Login
Username:
Password:
 
Create account
Forget password?
 Who is Online

There are currently:
33 anonymous users online.

0 of 204 registered users online.

There have been 10460 Page Hits by 8008 users

 Search Forums

More search options
Base Example

The following examples on this page generate the following chart

For lots more example code, you can click on any chart in the galleries to see the code that generates them.

C# Code

<%@ Page Language="C#" %>
<%@ Register tagPrefix="SasqChart" Namespace="SasqChart" Assembly="SasqChart" %>
<%@ Import Namespace="System.Data" %>
<HTML>
    <HEAD>
        <title>Simple C# SasqChart Example</title>
        <script runat="server">
            private void Page_Load(object sender, System.EventArgs e)
            {
                Random myRandom = new Random();

                // Create a DataSet
                DataSet myDataSet = new DataSet();

                // Get the first DataTable
                DataTable myDataTable = myDataSet.Tables.Add("Example Dataset Chart");

                // Create Columns
                myDataTable.Columns.Add("label", typeof(string));  
                myDataTable.Columns.Add("value1", typeof(int) );
                myDataTable.Columns.Add("value2", typeof(int) );
                myDataTable.Columns.Add("value3", typeof(int) );

                // Fill in data table
                for(int i=1; i<=20; i++)
                {
                    DataRow myDataRow = myDataTable.NewRow();            
                    myDataRow["label"] = i.ToString();
                    myDataRow["value1"] = myRandom.Next(100) - 50;
                    myDataRow["value2"] = myRandom.Next(100);
                    myDataRow["value3"] =  myRandom.Next(100) + 50;
                    myDataTable.Rows.Add(myDataRow);
                } 
            
                chart.Series[0].Type = ChartType.SmoothLine;
                chart.Series[1].Type = ChartType.SmoothLine;
                chart.Series[2].Type = ChartType.SmoothLine;
                chart.LabelColumnName = "label";
                chart.Series[0].DataProviderColumnNames.Value = "value1";
                chart.Series[1].DataProviderColumnNames.Value = "value2";
                chart.Series[2].DataProviderColumnNames.Value = "value3";
                chart.DataSource = myDataSet;
                chart.DataBind();            
            }
        </script>
    </HEAD>
    <body>
        <SasqChart:WebChartControl id="chart" runat="server" width="500" height="350" />
    </body>
</HTML>

VB Code

<%@ Page Language="VB" %>
<%@ Register tagPrefix="SasqChart" Namespace="SasqChart" Assembly="SasqChart" %>
<%@ Import Namespace="System.Data" %>
<HTML>
    <HEAD>
        <title>Simple C# SasqChart Example</title>
        <script runat="server">
            Sub Page_Load(ByVal sender as object, ByVal e As System.EventArgs)
            
                Dim myRandom as New Random()

                Dim myDataSet as New DataSet()

                Dim myDataTable as DataTable= myDataSet.Tables.Add("Example Dataset Chart")

                myDataTable.Columns.Add("label", GetType(String) )
                myDataTable.Columns.Add("value1", GetType(Integer) )
                myDataTable.Columns.Add("value2", GetType(Integer) )
                myDataTable.Columns.Add("value3", GetType(Integer) )

                Dim i As Integer
                For i = 1 To 20
                    Dim myDataRow as DataRow = myDataTable.NewRow()            
                    myDataRow("label") = i.ToString()
                    myDataRow("value1") = myRandom.Next(100) - 50
                    myDataRow("value2") = myRandom.Next(100)
                    myDataRow("value3") =  myRandom.Next(100) + 50
                    myDataTable.Rows.Add(myDataRow)
                Next
            
                chart.Series(0).Type = ChartType.SmoothLine
                chart.Series(1).Type = ChartType.SmoothLine
                chart.Series(2).Type = ChartType.SmoothLine
                chart.LabelColumnName = "label"
                chart.Series(0).DataProviderColumnNames.Value = "value1"
                chart.Series(1).DataProviderColumnNames.Value = "value2"
                chart.Series(2).DataProviderColumnNames.Value = "value3"
                chart.DataSource = myDataSet
                chart.DataBind()            
            End Sub
        </script>
    </HEAD>
    <body>
        <SasqChart:WebChartControl id="chart" runat="server" width="500" height="350" />
    </body>
</HTML>