ASPX
---------------------------
<asp:Chart ID="Chart1" runat="server" BackImageTransparentColor="Transparent" Width="500px">
<Legends>
<asp:Legend Name="Legend1" Alignment="Far" Title="" LegendStyle="Column">
</asp:Legend>
</Legends>
<Series>
<asp:Series Name="Income" Legend="Legend1" ChartType="Spline" IsValueShownAsLabel="True">
</asp:Series>
<asp:Series Name="Target" Legend="Legend1" ChartType="Spline" IsValueShownAsLabel="True">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
CS
---------------------
public void getChart4Publ()
{
DataTable ds = gc.GetDataTable("select id,Product from tbl_NewProduct");
if (ds.Rows.Count != 0)
{
DataTable dt = new DataTable();
DataColumn X = new DataColumn("X");
DataColumn Total = new DataColumn("Total");
DataColumn Total1 = new DataColumn("Total1");
dt.Columns.Add(X);
dt.Columns.Add(Total);
dt.Columns.Add(Total1);
for (int i = 0; i < ds.Rows.Count; i++)
{
DataRow dr = dt.NewRow();
DataSet regionDT = GetDataSet("exec prc_Business_Plan_Print_Targetby_Type @Type='" + ds.Rows[i]["Product"].ToString() + "',@FYear='"+ViewState["FYear"].ToString()+"'");
dr[0] = ds.Rows[i]["Product"].ToString();
dr[1] = String.Format("{0:00.00}", regionDT.Tables[0].Rows[0]["Price"]).ToString();
dr[2] = String.Format("{0:00.00}", regionDT.Tables[1].Rows[0]["tot"]).ToString();
dt.Rows.Add(dr);
}
Chart1.ChartAreas[0].AxisX.Title = "Product";
Chart1.ChartAreas[0].AxisY.Title = "Amount in ($)";
Chart1.Visible = true;
Chart1.Titles.Add("Target Sale for Publication");
Chart1.Series["Target"].ChartType = SeriesChartType.Spline;
Chart1.DataSource = dt;
Chart1.Series["Target"].XValueMember = "X";
Chart1.Series["Target"].YValueMembers = "Total";
Chart1.Series["Target"].ToolTip = "#VALX: #VAL";
Chart1.Series["Target"].MapAreaAttributes = "onclick=\"javascript:alert('Mouse " + "ondblclick event captured in the series! Series Name: #SER');\"";
Chart1.Series["Target"].LegendToolTip = "#PERCENT";
Chart1.Series["Target"].PostBackValue = "#INDEX";
Chart1.Series["Target"].LegendPostBackValue = "#INDEX";
Chart1.Series["Target"].LabelAngle = 90;
Chart1.Series["Target"].CustomProperties = "PieLabelStyle=Disabled";
Chart1.Series["Income"].ChartType = SeriesChartType.Spline;
//Chart1.Series["Target"].XValueMember = "X";
Chart1.Series["Income"].YValueMembers = "Total1";
Chart1.Series["Income"].ToolTip = "#VALX: #VAL";
Chart1.Series["Income"].MapAreaAttributes = "onclick=\"javascript:alert('Mouse " + "ondblclick event captured in the series! Series Name: #SER');\"";
Chart1.Series["Income"].LegendToolTip = "#PERCENT";
Chart1.Series["Income"].PostBackValue = "#INDEX";
Chart1.Series["Income"].LegendPostBackValue = "#INDEX";
Chart1.Series["Income"].LabelAngle = 90;
Chart1.Series["Income"].CustomProperties = "PieLabelStyle=Disabled";
Chart1.Legends[0].LegendStyle = LegendStyle.Table;
Chart1.Legends[0].TableStyle = LegendTableStyle.Wide;
Chart1.Legends[0].Docking = Docking.Bottom;
Chart1.DataBind();
Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
}
}
IMAGE
-------------------
No comments:
Post a Comment