ASPX
-------------------------
<asp:Chart ID="Chart5" runat="server" Width="500px" Height="250px">
<Legends>
<asp:Legend Name="Legend1" Title="" Alignment="Center">
</asp:Legend>
</Legends>
<Series>
<asp:Series Name="Series1" Legend="Legend1" LegendText="#VALX (#VAL)" ChartType="Pie">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
CS
------------------------------
public void getChart()
{
DataTable ds = GetRegionByTotal();
if (ds.Rows.Count != 0)
{
DataTable dt = new DataTable();
DataColumn X = new DataColumn("X");
DataColumn Total = new DataColumn("Total");
dt.Columns.Add(X);
dt.Columns.Add(Total);
for (int i = 0; i < ds.Rows.Count; i++)
{
DataRow dr = dt.NewRow();
dr[0] = ds.Rows[i]["RegionName"].ToString();
dr[1] = ds.Rows[i]["Amount"].ToString();
dt.Rows.Add(dr);
}
Chart5.Visible = true;
Chart5.Titles.Add("Actual Expense");
Chart5.Series["Series1"].ChartType = SeriesChartType.Pie;
Chart5.DataSource = dt;
Chart5.Series["Series1"].XValueMember = "X";
Chart5.Series["Series1"].YValueMembers = "Total";
Chart5.Series["Series1"].ToolTip = "#VALX: #VAL";
Chart5.Series["Series1"].MapAreaAttributes = "onclick=\"javascript:alert('Mouse " + "ondblclick event captured in the series! Series Name: #SER');\"";
Chart5.Series["Series1"].LegendToolTip = "#PERCENT";
Chart5.Series["Series1"].PostBackValue = "#INDEX";
Chart5.Series["Series1"].LegendPostBackValue = "#INDEX";
Chart5.Series["Series1"].CustomProperties = "PieLabelStyle=Disabled";
Chart5.DataBind();
}
}
IMAGE
-------------------
-------------------------
<asp:Chart ID="Chart5" runat="server" Width="500px" Height="250px">
<Legends>
<asp:Legend Name="Legend1" Title="" Alignment="Center">
</asp:Legend>
</Legends>
<Series>
<asp:Series Name="Series1" Legend="Legend1" LegendText="#VALX (#VAL)" ChartType="Pie">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
CS
------------------------------
public void getChart()
{
DataTable ds = GetRegionByTotal();
if (ds.Rows.Count != 0)
{
DataTable dt = new DataTable();
DataColumn X = new DataColumn("X");
DataColumn Total = new DataColumn("Total");
dt.Columns.Add(X);
dt.Columns.Add(Total);
for (int i = 0; i < ds.Rows.Count; i++)
{
DataRow dr = dt.NewRow();
dr[0] = ds.Rows[i]["RegionName"].ToString();
dr[1] = ds.Rows[i]["Amount"].ToString();
dt.Rows.Add(dr);
}
Chart5.Visible = true;
Chart5.Titles.Add("Actual Expense");
Chart5.Series["Series1"].ChartType = SeriesChartType.Pie;
Chart5.DataSource = dt;
Chart5.Series["Series1"].XValueMember = "X";
Chart5.Series["Series1"].YValueMembers = "Total";
Chart5.Series["Series1"].ToolTip = "#VALX: #VAL";
Chart5.Series["Series1"].MapAreaAttributes = "onclick=\"javascript:alert('Mouse " + "ondblclick event captured in the series! Series Name: #SER');\"";
Chart5.Series["Series1"].LegendToolTip = "#PERCENT";
Chart5.Series["Series1"].PostBackValue = "#INDEX";
Chart5.Series["Series1"].LegendPostBackValue = "#INDEX";
Chart5.Series["Series1"].CustomProperties = "PieLabelStyle=Disabled";
Chart5.DataBind();
}
}
IMAGE
-------------------
No comments:
Post a Comment