Hi,
I need to display customized tooltips on individual sectors of a pie chart. How can I do it in the code behind? Because I also need to customize the background color of the pie chart, I have to dynamically generate pie series in the code behind.
My code snippet is attached.
Thanks,
Rong
Private Sub LoadAppropriationForAllPrograms()
lblChrtHeader.Text = "Appropriation by Program"
Dim budgetFund As New BudgetBookBAL.BudgetBook
Dim fundDT As New DataTable
Dim seriesColor As New BudgetBookBAL.StaticColors
chrtProgram.PlotArea.Series.Clear()
fundDT = budgetFund.GetAppropriationForAllPrograms()
Dim chartData As New Telerik.Web.UI.PieSeries
chartData.StartAngle = "90"
chartData.LabelsAppearance.Position = Telerik.Web.UI.HtmlChart.PieLabelsPosition.Circle
chartData.LabelsAppearance.DataFormatString = "${0}M"
Dim total As Decimal = 0D
For Each row As DataRow In fundDT.Rows
total = CDec(row("TOT_BUDGET")) + total
Next
Dim index As Integer = 0
For Each row As DataRow In fundDT.Rows
Dim chartSeries As New Telerik.Web.UI.SeriesItem
Dim pct As Decimal = 0D
If total > 0 Then
pct = CDec(row("TOT_BUDGET")) / total * 100
End If
chartSeries.BackgroundColor = seriesColor.GetColor(index)
Dim desc As String = row("PROG_NAME").ToString + " - $" + CDec(row("TOT_BUDGET")).ToString() + "M (" + pct.ToString("F1") + "%)"
chartSeries.YValue = CDec(row("TOT_BUDGET"))
chartSeries.Name = desc
'chartSeries.TooltipValue = desc
chartData.Items.Add(chartSeries)
index += 1
Next
chrtProgram.Legend.Appearance.Position = Telerik.Web.UI.HtmlChart.ChartLegendPosition.Right
chrtProgram.PlotArea.Series.Add(chartData)
chrtProgram.DataBind()
End Sub