Web page displaying Empty Pie Chart for dynamic values in ASP.Net

Last Reply 5 months ago By narasiman

Posted 6 months ago

i dynamically set the value in pie chart My code as follows

<asp:PieChart ID="PieChart1" runat="server" ChartHeight="300"
ChartWidth="450" ChartTitle="Today's Attendance"
<asp:PieChartValue Category="Present" Data="80" />
<asp:PieChartValue Category="Absent" Data="10" />
<asp:PieChartValue Category="Leave" Data="10" />

when i run the above code shows the empty pie chart. what is the mistake in my above code.

Posted 5 months ago

in page load code as follows

    DataTable _objdt = new DataTable();
    _objdt = GetDataForChart();

    public void BindDataToChartcontrol(DataTable _objdt)
        Chart1.DataSource = _objdt;


    public DataTable GetDataForChart()
        DataTable _objdt = new DataTable();

        _objdt.Columns.Add("Country", typeof(string));
        _objdt.Columns.Add("Growth", typeof(long));

        var _objrow = _objdt.NewRow();
        _objrow["Country"] = "On or Before Time";
        _objrow["Growth"] = 80;

        _objrow = _objdt.NewRow();
        _objrow["Country"] = "Grace Time";
        _objrow["Growth"] = 15;

        _objrow = _objdt.NewRow();
        _objrow["Country"] = "Late Time";
        _objrow["Growth"] = 5;

        return _objdt;

 When i run the above code. pie chart is display