Imports System.Web.UI.DataVisualization
Imports System.Web.UI.DataVisualization.Charting
Dim srs As Series = chtTotal.Series.Add("srsTotal")
Dim lgn As Legend = chtTotal.Legends.Add("legTotal")
Dim ds As DataSet = Bugs.GetCallListForReviewChartPie(Session("user_id"), lblClients.Text, txtFromDate.Text, txtToDate.Text)
If ds.Tables(0).Rows.Count > 0 Then
chtTotal.DataSource = ds.Tables(0)
lgn.LegendStyle = LegendStyle.Table
lgn.Alignment = StringAlignment.Center
lgn.Docking = Docking.Bottom
srs.ChartType = SeriesChartType.Pie
srs.ShadowOffset = 2
srs.Font = New Font("Times New Format", 7.0F)
srs.IsValueShownAsLabel = True
Dim yValues(1) As Integer
Dim xValues(1) As String
For j As Integer = 0 To ds.Tables(0).Rows.Count - 1
xValues(j) = ds.Tables(0).Rows(j).Item("Category")
If ds.Tables(0).Rows.Count = 1 Then
xValues(j + 1) = IIf(ds.Tables(0).Rows(j).Item("Category") = "CR", "PR", "CR")
End If
Next
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
yValues(i) = ds.Tables(0).Rows(i).Item("Total")
Next
srs.Points.DataBindY(yValues)
For pointIndex As Integer = 0 To srs.Points.Count - 1
srs.Points(pointIndex).LegendText = xValues(pointIndex)
srs.Points(pointIndex).ToolTip = xValues(pointIndex) & " (" & yValues(pointIndex) & ")"
srs.Points(pointIndex).LegendToolTip = xValues(pointIndex) & " (" & yValues(pointIndex) & ")"
Next
srs.PostBackValue = "#INDEX"
srs.LegendPostBackValue = "#INDEX"
srs.Points(0).Font = New Font("Times New Format", 7.0F)
chtTotal.Series("srsTotal").SetCustomProperty("PieLabelStyle", "Disabled")
For pointIndex As Integer = 0 To srs.Points.Count - 1
If yValues(pointIndex) = "0" Then
srs.Points(pointIndex).PostBackValue = ""
srs.Points(pointIndex).LegendPostBackValue = ""
End If
Next
If Not txtID.Text = "" Then
srs.Points(IIf(txtID.Text = "PR", 1, 0)).Font = New Font("Times New Format", 9.0F, FontStyle.Bold)
srs.Points(IIf(txtID.Text = "PR", 1, 0)).BorderColor = Color.Black
srs.Points(IIf(txtID.Text = "PR", 1, 0)).BorderWidth = 4
End If
chtTotal.Width = 500
If File.Exists(tmpChartName) Then File.Delete(tmpChartName)
chtTotal.SaveImage(tmpChartName, ChartImageFormat.Png)
chtTotal.Legends.RemoveAt(0)
chtTotal.Width = 200
Else
chtTotal.Visible = False
Session("Message") = "No Records."
Master.ShowMessage()
End If
i create dynamically, this with the help of mschart.