
Imports System.Data
Imports Telerik.Web.UI

Partial Class DrilldownChart_VB
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RadAjaxManager.GetCurrent(Me).EnableAJAX = True
        If Not IsPostBack Then
            Call piechart()
        End If

        RadAjaxManager2.AjaxSettings.AddAjaxSetting(RadAjaxManager2, HtmlChartHolder1)

    End Sub

    Private Sub piechart()
        Dim Piechart As New RadHtmlChart()
        Piechart.ID = "Piechart1"
        Piechart.Width = Unit.Percentage(92%)
        Piechart.Height = Unit.Pixel(450)
        Piechart.ChartTitle.Text = "Piechart1"
        Piechart.ChartTitle.Appearance.Align = HtmlChart.ChartTitleAlign.Left
        Piechart.ChartTitle.Appearance.Position = HtmlChart.ChartTitlePosition.Top
        Piechart.ChartTitle.Appearance.TextStyle.Bold = "True"
        Piechart.ChartTitle.Appearance.TextStyle.FontSize = 12
        Piechart.DataSource = GetData()
        Piechart.DataBind()
        Dim kpi As PieSeries = New PieSeries()
        kpi.DataFieldY = "EMPLOYEECOUNT"
        kpi.NameField = "IDENTITYTYPEDESC"
        kpi.ExplodeField = "IDENTITYTYPEDESC"
        kpi.LabelsAppearance.Visible = True

        kpi.StartAngle = 90
        kpi.ExplodeField = True
        kpi.TooltipsAppearance.Color = Drawing.Color.White
        kpi.LabelsAppearance.ClientTemplate = "#=dataItem.IDENTITYTYPEDESC#: #= dataItem.EMPLOYEECOUNT#"
        kpi.LabelsAppearance.Position = HtmlChart.PieAndDonutLabelsPosition.OutsideEnd
        Piechart.ClientEvents.OnSeriesClick = "OnClientSeriesClicked_1"

        Piechart.PlotArea.Series.Add(kpi)
        HtmlChartHolder1.Controls.Add(Piechart)



    End Sub
    Private Sub piechartdrill()
        Dim Piechart2 As New RadHtmlChart()
        Piechart2.ID = "Piechart2"
        Piechart2.ChartTitle.Text = "Piechart2"
        Piechart2.DataSource = GetData2()
        Piechart2.DataBind()
        Dim kpi1 As PieSeries = New PieSeries()
        kpi1.DataFieldY = "EMPLOYEECOUNT"
        kpi1.NameField = "GENDER"
        kpi1.LabelsAppearance.ClientTemplate = "#=dataItem.GENDER#: #= dataItem.EMPLOYEECOUNT#"
        kpi1.LabelsAppearance.Position = HtmlChart.PieAndDonutLabelsPosition.OutsideEnd
        'Piechart.ClientEvents.OnSeriesClick = "onChartSeriesClick2"
        For Each item As RadHtmlChart In HtmlChartHolder1.Controls.OfType(Of RadHtmlChart)()
            HtmlChartHolder1.Controls.Remove(item)
        Next
        Piechart2.PlotArea.Series.Add(kpi1)
        HtmlChartHolder1.Controls.Add(Piechart2)
    End Sub

    Private Function GetData() As Object
        Dim dt As DataTable = New DataTable()
        dt.Columns.Add("EMPLOYEECOUNT")
        dt.Columns.Add("IDENTITYTYPEDESC")
        dt.Rows.Add(51, "type 1")
        dt.Rows.Add(43, "type 2")
        dt.Rows.Add(32, "type 3")
        dt.Rows.Add(24, "type 4")
        Return dt
    End Function

    Private Function GetData2() As Object
        Dim dt As DataTable = New DataTable()
        dt.Columns.Add("EMPLOYEECOUNT")
        dt.Columns.Add("GENDER")
        dt.Rows.Add(15, "male")
        dt.Rows.Add(14, "female")
        dt.Rows.Add(13, "female")
        dt.Rows.Add(12, "male")
        Return dt
    End Function

    Protected Sub RadAjaxManager2_AjaxRequest(sender As Object, e As AjaxRequestEventArgs)
        piechartdrill()
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "repaintCharts();", True)
    End Sub
End Class
