Has anyone got any experience of this WebChart Control?
WebChart Control for ASP.NET
I've tried the example on the site but all I get is a no image Red X. When I check the source, no src file is added to the <img> tag and when I check the WebCharts folder, where the graph image should be stored, it's empty.
I've contacted my host to check on permissions, but I don't think it's a permissions problem.
Can anyone confirm if this control works with 2.0. I believe it should do, but I've no idea why mine isn't working.
Any ideas?
webchart.aspx
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="webchart.aspx.vb" Inherits="webchart_page" %>
<%@ Register TagPrefix="webchart" Namespace="WebChart" Assembly="WebChart" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="XHTML namespace" >
<head runat="server">
<title>Web Chart</title>
</head>
<body>
<form id="form1" runat="server">
<webchart:ChartControl ID="test_chart" Width="500" Height="350" ChartFormat="Jpg" runat="server" />
</form>
</body>
</html>
webchart.aspx.vb
Code:
Imports System.Drawing
Imports System.Data
Imports MySql.Data.MySqlClient
Imports WebChart
Partial Class webchart_page
Inherits System.Web.UI.Page
Sub Page_Load()
Dim ds As DataSet = GetDataSet()
Dim view As DataView = ds.Tables(0).DefaultView
Dim chart As New SmoothLineChart()
chart.Line.Color = Color.SteelBlue
chart.Legend = "Value 1"
chart.DataSource = view
chart.DataXValueField = "Description"
chart.DataYValueField = "Value1"
chart.DataBind()
test_chart.Charts.Add(chart)
Dim chart1 As New SmoothLineChart()
chart1.Line.Color = Color.Red
chart1.Legend = "Value 2"
chart1.DataSource = view
chart1.DataXValueField = "Description"
chart1.DataYValueField = "Value2"
chart1.DataBind()
test_chart.Charts.Add(chart1)
ConfigureColors()
test_chart.RedrawChart()
End Sub
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 = 0 To 20
Dim row As DataRow = table.NewRow()
row("Description") = i.ToString()
row("Value1") = rnd.Next(100)
row("Value2") = rnd.Next(100)
table.Rows.Add(row)
Next
Return ds
End Function
' Configure some colors for the Chart, this could be done declaratively also
Sub ConfigureColors()
test_chart.Background.Color = Color.DarkGray
test_chart.Background.Type = InteriorType.Hatch
test_chart.Background.HatchStyle = System.Drawing.Drawing2D.HatchStyle.DiagonalBrick
test_chart.Background.ForeColor = Color.Yellow
test_chart.Background.EndPoint = New Point(500, 350)
test_chart.Legend.Position = LegendPosition.Left
test_chart.Legend.Width = 80
test_chart.YAxisFont.ForeColor = Color.Red
test_chart.XAxisFont.ForeColor = Color.Green
test_chart.ChartTitle.Text = "WebChart Control Sample"
test_chart.ChartTitle.ForeColor = Color.DarkBlue
test_chart.Border.Color = Color.SteelBlue
test_chart.BorderStyle = BorderStyle.Ridge
End Sub
End Class