<asp:Chart ID="Chart1" runat="server" Width="600px">
<series>
<asp:Series BorderWidth="5" ChartArea="ChartArea1" ChartType="Line" Name="Present">
</asp:Series>
<asp:Series BorderWidth="5" ChartArea="ChartArea1" ChartType="Line" Color="Tomato" Name="Absent">
</asp:Series>
<asp:Series BorderWidth="5" ChartArea="ChartArea1" ChartType="Line" Color="#33cc00" Name="Leave">
</asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1">
<axisx islabelautofit="false">
<LabelStyle Interval="1" />
</axisx>
</asp:ChartArea>
</chartareas>
</asp:Chart>
public void bindChart(DataTable dtChartForBinding)
{
Chart1.Series["Present"].XValueMember = "";
Chart1.Series["Present"].YValueMembers = "";
//Chart1.Series["Series1"].IsValueShownAsLabel = true ;
Chart1.ChartAreas["ChartArea1"].AxisY.Minimum = 0;
Chart1.ChartAreas["ChartArea1"].AxisY.Maximum = 100;
Chart1.ChartAreas["ChartArea1"].AxisY.Interval = 10;
Chart1.DataSource = dtChartForBinding;
Chart1.Legends.Add("Present Percentage").Title = "Percentage";
// here i am giving the title of the x-axis
Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Month";
Chart1.ChartAreas["ChartArea1"].AxisX.TitleForeColor = System.Drawing.Color.Red;
Chart1.ChartAreas["ChartArea1"].AxisX.TitleFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Bold);
// here i am giving the title of the y-axis
Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Attendance Percentage";
Chart1.ChartAreas["ChartArea1"].AxisY.TitleForeColor = System.Drawing.Color.Red;
Chart1.ChartAreas["ChartArea1"].AxisY.TitleFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Bold);
// here i am binding the x-axisvalue with the chart control
Chart1.Series["Present"].XValueMember = "Month";
Chart1.Series["Absent"].XValueMember = "Month";
Chart1.Series["Leave"].XValueMember = "Month";
// here i am binding the y-axisvalue with the chart control
Chart1.Series["Present"].YValueMembers = "Present Percentage";
Chart1.Series["Absent"].YValueMembers = "Absent Percentage";
Chart1.Series["Leave"].YValueMembers = "Leave Percentage";
Chart1.DataBind();
}
<series>
<asp:Series BorderWidth="5" ChartArea="ChartArea1" ChartType="Line" Name="Present">
</asp:Series>
<asp:Series BorderWidth="5" ChartArea="ChartArea1" ChartType="Line" Color="Tomato" Name="Absent">
</asp:Series>
<asp:Series BorderWidth="5" ChartArea="ChartArea1" ChartType="Line" Color="#33cc00" Name="Leave">
</asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1">
<axisx islabelautofit="false">
<LabelStyle Interval="1" />
</axisx>
</asp:ChartArea>
</chartareas>
</asp:Chart>
public void bindChart(DataTable dtChartForBinding)
{
Chart1.Series["Present"].XValueMember = "";
Chart1.Series["Present"].YValueMembers = "";
//Chart1.Series["Series1"].IsValueShownAsLabel = true ;
Chart1.ChartAreas["ChartArea1"].AxisY.Minimum = 0;
Chart1.ChartAreas["ChartArea1"].AxisY.Maximum = 100;
Chart1.ChartAreas["ChartArea1"].AxisY.Interval = 10;
Chart1.DataSource = dtChartForBinding;
Chart1.Legends.Add("Present Percentage").Title = "Percentage";
// here i am giving the title of the x-axis
Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Month";
Chart1.ChartAreas["ChartArea1"].AxisX.TitleForeColor = System.Drawing.Color.Red;
Chart1.ChartAreas["ChartArea1"].AxisX.TitleFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Bold);
// here i am giving the title of the y-axis
Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Attendance Percentage";
Chart1.ChartAreas["ChartArea1"].AxisY.TitleForeColor = System.Drawing.Color.Red;
Chart1.ChartAreas["ChartArea1"].AxisY.TitleFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Bold);
// here i am binding the x-axisvalue with the chart control
Chart1.Series["Present"].XValueMember = "Month";
Chart1.Series["Absent"].XValueMember = "Month";
Chart1.Series["Leave"].XValueMember = "Month";
// here i am binding the y-axisvalue with the chart control
Chart1.Series["Present"].YValueMembers = "Present Percentage";
Chart1.Series["Absent"].YValueMembers = "Absent Percentage";
Chart1.Series["Leave"].YValueMembers = "Leave Percentage";
Chart1.DataBind();
}
No comments:
Post a Comment