I’ve been working on creating custom data-driven charts for use in a new product. We looked at several options including Microsoft’s free Chart Controls but ultimately decided to go with Dundas Chart because of their excellent customer service and support. Their product makes it relatively easy to create nice looking charts for ASP.NET pages such as this pie chart.

'Chart - Total Annual Compensation
Sub Bind_Chart_TotalAnnualComp()
Dim strCEOBaseSalary As Double
Dim strCEOBonus As Double
Dim strCEONonEqIncentComp As Double
Dim strCEOPensionNQDC As Double
Dim strCEOAllOtherCompensation As Double
'Create a connection
Dim myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("TearSheet_ConnString").ConnectionString)
'Create the command object, passing in the SQL string
Const strSQL As String = "p_Chart_TotalAnnualComp"
Dim myCommand As New SqlCommand(strSQL)
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.AddWithValue("@id_company", lblid_company.Text)
'Set the datagrid's datasource to the datareader and databind
myConnection.Open()
myCommand.Connection = myConnection
Dim myReader As SqlDataReader = myCommand.ExecuteReader()
Dim xValues As String() = {"Salary", "Bonus", "Non-Equity Incentive Comp", "Pension/NQDC Earnings", "All Other Compensation"}
Dim yValues As New List(Of Double)
With myReader
If .HasRows Then
While .Read
yValues.Add(Double.Parse(.GetValue(0)))
strCEOBaseSalary = Double.Parse(.GetValue(0))
yValues.Add(Double.Parse(.GetValue(1)))
strCEOBonus = Double.Parse(.GetValue(1))
yValues.Add(Double.Parse(.GetValue(2)))
strCEONonEqIncentComp = Double.Parse(.GetValue(2))
yValues.Add(Double.Parse(.GetValue(3)))
strCEOPensionNQDC = Double.Parse(.GetValue(3))
yValues.Add(Double.Parse(.GetValue(4)))
strCEOAllOtherCompensation = Double.Parse(.GetValue(4))
End While
End If
End With
Chart_TotalAnnualComp.Series("Default").Points.DataBindXY(xValues, yValues.ToArray())
myConnection.Close()
myConnection.Dispose()
'Make the chart 3D
Chart_TotalAnnualComp.ChartAreas("Default").Area3DStyle.Enable3D = True
'Don't let the text in the legend wrap
Chart_TotalAnnualComp.Legends("Default").TextWrapThreshold = 0
'Chart Title
Chart_TotalAnnualComp.Legends("Default").Title = "Total Annual Compensation"
'Add the series and values for each
Chart_TotalAnnualComp.Series(0).Points(0).LegendText = "Salary " & FormatCurrency(strCEOBaseSalary.ToString(), 0)
Chart_TotalAnnualComp.Series(0).Points(1).LegendText = "Bonus " & FormatCurrency(strCEOBonus.ToString(), 0)
Chart_TotalAnnualComp.Series(0).Points(2).LegendText = "Non-Equity Incentive Comp " & FormatCurrency(strCEONonEqIncentComp.ToString(), 0)
Chart_TotalAnnualComp.Series(0).Points(3).LegendText = "Pension/NQDC Earnings " & FormatCurrency(strCEOPensionNQDC.ToString(), 0)
Chart_TotalAnnualComp.Series(0).Points(4).LegendText = "All Other Compensation " & FormatCurrency(strCEOAllOtherCompensation.ToString(), 0)
'Add custom tooltips showing each series value
Chart_TotalAnnualComp.Series(0).Points(0).ToolTip = "Salary " & FormatCurrency(strCEOBaseSalary.ToString(), 0)
Chart_TotalAnnualComp.Series(0).Points(1).ToolTip = "Bonus " & FormatCurrency(strCEOBonus.ToString(), 0)
Chart_TotalAnnualComp.Series(0).Points(2).ToolTip = "Non-Equity Incentive Comp " & FormatCurrency(strCEONonEqIncentComp.ToString(), 0)
Chart_TotalAnnualComp.Series(0).Points(3).ToolTip = "Pension/NQDC Earnings " & FormatCurrency(strCEOPensionNQDC.ToString(), 0)
Chart_TotalAnnualComp.Series(0).Points(4).ToolTip = "All Other Compensation " & FormatCurrency(strCEOAllOtherCompensation.ToString(), 0)
'This prevents the values from showing up inside the pie chart
Chart_TotalAnnualComp.Series(0)("PieLabelStyle") = "Disabled"
End Sub