Pie Chart Control.
Below is the sample example to create PIE chart in your asp.Net web Application. Code uses C# as code language.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
//using WebChart.Design;
using blong.WebControls;
/*
* Add this XML tag to the web.config file"
*
*/
namespace Ancilla
{
///
/// Summary description for chartcheck.
///
public class chartcheck : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.Panel Pending;
protected System.Web.UI.WebControls.Panel Resolved;
protected System.Web.UI.WebControls.Label LblPending;
protected System.Web.UI.WebControls.Label LblResolved;
protected System.Web.UI.WebControls.Label LblPper;
protected System.Web.UI.WebControls.Label LblRper;
protected System.Web.UI.WebControls.Label LblHeading;
protected blong.WebControls.WebChart WebChart1;
private void Page_Load(object sender, System.EventArgs e)
{
float total,pper,rper;
int x=(int)Session["pending"];
int y=(int)Session["resolved"];
total = x+y;
if(x==0)
{
pper=0;
}
else
{
pper =(x/total)*100;
pper=(float)Math.Round(pper,2);
}
if(y==0)
{
rper=0;
}
else
{
rper =(y/total)*100;
rper =(float)Math.Round(rper,2);
}
LblPper.Text =string.Concat(pper.ToString(),"","%");
LblRper.Text =string.Concat(rper.ToString(),"","%");
blong.WebControls.WebChart chart =new blong.WebControls.WebChart();
chart.Type = blong.WebControls.WebChart.ChartType.Pie;
chart.ID ="Real";
if(x!=0 || y!=0)
{
chart.WebChartItems.Add(new WebChartItem("Pending",x,false));
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem("Resolved",y,false));
}
if(x==0 && y==0)
{
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
chart.WebChartItems.Add(new WebChartItem());
}
chart.BackColor=Color.Gainsboro;
chart.BorderWidth =2;
chart.BorderColor =Color.PowderBlue;
chart.BorderStyle =BorderStyle.Solid;
chart.ShowLegend = false;
chart.Diameter = blong.WebControls.WebChart.PieDiameter.Small;
chart.ExplodeOffset = 25;
chart.Rotate = 70;
chart.Thickness = blong.WebControls.WebChart.PieThickness.Medium;
string check = Session["check"].ToString();
if(check == "Lc")
{
chart.Title ="";
//chart.Title ="Log Calls Report Chart";
LblHeading.Text ="Log Calls Report Chart";
}
else
{
chart.Title ="";
//chart.Title ="Agent Calls Report Chart";
LblHeading.Text ="Agent Calls Report Chart";
}
chart.Format = blong.WebControls.WebChart.ChartFormat.Png;
this.Controls.Add(chart);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}