WEBChart Control

 

 

Step 1              Download The WebChart DLL Control Here.

 

Step 2              Add the WebChart.dll to the Visual Studio IDE Toolbar.

 

Step 3              Add this “imports” Statement: Imports WebChart

 

Step 4              Here’s the Code Behind…

 

  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

    Response.Write("hello world!")

 

    Dim ds As DataSet = GetDataSet()

    Dim view As DataView = ds.Tables(0).DefaultView

 

    '**** CHART ******************************************

    Dim chart As New WebChart.ColumnChart

 

    chart.Fill.Color = System.Drawing.Color.SteelBlue

    chart.Line.Color = Color.Red

    chart.Line.Width = 2

    chart.MaxColumnWidth = 30

 

 

    chart.Legend = "1. Hair Shaping " & vbCrLf & vbCrLf & "2. Thermal Curling"

    chart.DataSource = view

    chart.DataXValueField = "Description"

    chart.DataYValueField = "Value1"

    chart.DataBind()

    ChartControl1.Charts.Add(chart)

    '*********************************************************

 

    '********Second Chart ************************************

    'Dim chart1 As New WebChart.ColumnChart

    'chart1.Fill.Color = System.Drawing.Color.LightGreen

    'chart1.Line.Color = System.Drawing.Color.LightGreen

    'chart1.Line.Width = 2

    'chart1.MaxColumnWidth = 15

 

    'chart1.Legend = "Value 2"

    'chart1.DataSource = view

    'chart1.DataXValueField = "Description"

    'chart1.DataYValueField = "Value2"

    'chart1.DataBind()

    'ChartControl1.Charts.Add(chart1)

    '******************************************************

 

    ConfigureColors()

 

    ChartControl1.RedrawChart()

 

    'Print The Page...

    'Response.Write("<script language='javascript'>window.print()</script>")

 

 

  End Sub

 

  ' Just create a simple dataset

  Private Function GetDataSet() As DataSet

    Dim ds As New DataSet

    Dim table As DataTable = ds.Tables.Add("Data")

    table.Columns.Add("Description")

    table.Columns.Add("Value1", GetType(Integer))

    table.Columns.Add("Value2", GetType(Integer))

    Dim rnd As New Random

    Dim i As Integer

    For i = 1 To 5

      Dim row As DataRow = table.NewRow()

      row("Description") = "Content Area " & i.ToString()

      row("Value1") = i * 20

      row("Value2") = i * 5

      table.Rows.Add(row)

    Next

    Return ds

  End Function

 

 

 

 ' Configure some colors for the Chart, this could be done declaratively also

  Sub ConfigureColors()

 

    ChartControl1.Background.Color = Color.DarkGray

    ChartControl1.Background.Type = InteriorType.Solid

    ChartControl1.Background.HatchStyle = Drawing2D.HatchStyle.Percent25

    ChartControl1.Background.ForeColor = Color.Yellow

    ChartControl1.Background.EndPoint = New Point(500, 350)

 

    ChartControl1.Legend.Position = LegendPosition.Left

 

    ChartControl1.YCustomEnd = 100 'Show the highest y point as 100

 

    ChartControl1.RenderHorizontally = True

    'ChartControl1.HasChartLegend = False

    ChartControl1.YAxisFont.ForeColor = Color.Red

    ChartControl1.XAxisFont.ForeColor = Color.Black

 

    ChartControl1.ChartTitle.Text = "Percent Correct Per Content Area"

    ChartControl1.ChartTitle.ForeColor = Color.DarkBlue

 

    ChartControl1.Border.Color = Color.SteelBlue

    ChartControl1.BorderStyle = BorderStyle.Ridge

  End Sub