Nov 14, 2012, 10:02 AM
Unable to Get the PieChart Dynamically
Hi,
Here is Sample Code of BasicPie Chart, Here am unable to get the Label Field of inside Pie Series from CodeBehind, Help me
Here is Sample Code of BasicPie Chart, Here am unable to get the Label Field of inside Pie Series from CodeBehind, Help me
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function saveChart(btn) {
Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function (choice) {
if (choice == 'yes') {
btn.up('panel').down('chart').save({
type: 'image/png'
});
}
});
}
</script>
<script runat="server">
SqlConnection cn = new SqlConnection(WebConfigurationManager.ConnectionStrings["con"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
cn.Open();
PieSeries objPieSeries = new PieSeries();
objPieSeries.ShowInLegend = true;
objPieSeries.Donut = 0;
objPieSeries.Highlight = true;
objPieSeries.HighlightSegmentMargin = 20;
TransactionChart.Series.Add(objPieSeries);
SqlCommand cmd2 = new SqlCommand("select * from Chart", cn);
SqlDataReader dr2 = cmd2.ExecuteReader();
dr2.Read();
string input = dr2["Data1"].ToString();
string input1 = dr2["Name"].ToString();
dr2.Close();
objPieSeries.AngleField = "Data1";
objPieSeries.Label.Field = "Name"; // Am getting Error Here
// Getting Data into Model Fields
SqlCommand cmd = new SqlCommand("select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'Chart'", cn);
SqlDataReader dr = cmd.ExecuteReader();
var reader = new JsonReader();
while (dr.Read())
{
reader.Record = dr["COLUMN_NAME"].ToString();
Model2.Fields.Add(dr["COLUMN_NAME"].ToString());
}
dr.Close();
cn.Close();
DataSet ds = PDataset("select * from Chart");
Store1.DataSource = ds;
Store1.DataBind();
TransactionChart.Render();
}
protected DataSet PDataset(string Select_Statement)
{
cn.Open();
SqlDataAdapter ad = new SqlDataAdapter(Select_Statement, cn);
DataSet ds1 = new DataSet();
ad.Fill(ds1, "Chart");
cn.Close();
return ds1;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Panel ID="Panel2" runat="server" Height="600" Layout="FitLayout" MarginSpec="0 0 3 0">
<Items>
<ext:Chart ID="TransactionChart" runat="server" Animate="true" Shadow="true" InsetPadding="60"
Theme="Base:gradients">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model2" runat="server">
</ext:Model>
</Model>
</ext:Store>
</Store>
<LegendConfig Position="Right" />
</ext:Chart>
</Items>
</ext:Panel>
</div>
</form>
</body>
</html>
ThanK You...
Last edited by nagesh; Nov 16, 2012 at 5:05 AM.