Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI sir,

Can u give one complete example on chart control and series properties.
Posted

1 solution

use following demo for chart control.....
on .aspx page:
C#
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Chart ID="chartForMarks" runat="server" Width="500px">
            <Series>
                <asp:Series Name="NumberInMath" XValueMember="Name" YValueMembers="NumberInMath"
                    IsVisibleInLegend="true" ChartType="Pie">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="true">
                    <AxisX LineColor="DarkGreen">
                        <MajorGrid LineColor="LightGreen" />
                    </AxisX>
                    <AxisY LineColor="DarkGreen">
                        <MajorGrid LineColor="LightGreen" />
                    </AxisY>
                    <Area3DStyle Enable3D="True"></Area3DStyle>
                </asp:ChartArea>
            </ChartAreas>
            <Legends>
                <asp:Legend>
                </asp:Legend>
            </Legends>
        </asp:Chart>
    </div>
    </form>
</body>
</html>

on .cs page:
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CreatePIChartForMarks();
        }
    }

    private void CreatePIChartForMarks()
    {
        var table = new DataTable();
        table.Columns.Add("Name", typeof(string));
        table.Columns.Add("NumberInMath", typeof(long));
        table.Columns.Add("Lbl");
        var row = table.NewRow();
        row["Name"] = "Girijesh";
        row["NumberInMath"] = 33;
        table.Rows.Add(row);
        row = table.NewRow();
        row["Name"] = "Rajesh";
        row["NumberInMath"] = 09;
        table.Rows.Add(row);
        row = table.NewRow();
        row["Name"] = "Pallav";
        row["NumberInMath"] = 98;
        table.Rows.Add(row);
        row = table.NewRow();
        row["Name"] = "Sharath";
        row["NumberInMath"] = 37;
        table.Rows.Add(row);
        row = table.NewRow();
        row["Name"] = "Mahesh";
        row["NumberInMath"] = 59;
        table.Rows.Add(row);
        row = table.NewRow();
        row["Name"] = "Lokesh";
        row["NumberInMath"] = 78;
        table.Rows.Add(row);
        chartForMarks.DataSource = table;
        chartForMarks.DataBind();
    }

JMD:-)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900