I am sorry i am unable to attach it as zip from my system.
Here is the code.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OWC;
using Microsoft.Office.Interop;
using System.Xml;
using System.Data.SqlClient;
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["displayconnection"]);
cn.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select pid, count(pid) from chart where month(time)=" + DropDownList1.SelectedItem.Value + " group by pid", cn);
da.Fill(ds);
//Testing
//Response.Write("ChartSpaceClass");
OWC.ChartSpaceClass oChartSpace = new OWC.ChartSpaceClass();
System.IO.StringWriter sw = new System.IO.StringWriter();
XmlDocument xDoc = new XmlDocument();
ds.WriteXml(sw);
// clean up
cn.Close();
da.Dispose();
ds.Dispose();
xDoc.LoadXml(sw.ToString());
sw.Close();
System.Xml.XmlNodeList nodes;
nodes = xDoc.ChildNodes.Item(0).ChildNodes;
int nCount = nodes.Count;
string[] aNames = new string[nCount];
string[] aTotals = new string[nCount];
string names = String.Empty;
string totals = String.Empty;
int i = 0;
for (i = 0; i < nCount; i++)
{
aNames[i] = nodes.Item(i).ChildNodes.Item(0).InnerText;
aTotals[i] = nodes.Item(i).ChildNodes.Item(1).InnerText;
}
names = String.Join("\t", aNames);
totals = String.Join("\t", aTotals);
oChartSpace.Charts.Add(0);
oChartSpace.Charts[0].SeriesCollection.Add(0);
oChartSpace.Charts[0].SeriesCollection[0].SetData(OWC.ChartDimensionsEnum.chDimCategories,
Convert.ToInt32(OWC.ChartSpecialDataSourcesEnum.chDataLiteral), names);
oChartSpace.Charts[0].SeriesCollection[0].SetData(OWC.ChartDimensionsEnum.chDimValues,
Convert.ToInt32(OWC.ChartSpecialDataSourcesEnum.chDataLiteral), totals);
string strFullPathAndName = Server.MapPath("~/chart/" + System.DateTime.Now.Ticks.ToString() + ".gif");
oChartSpace.ExportPicture(strFullPathAndName, "gif", 800, 600);
string[] arr = new string[] { };
arr = strFullPathAndName.Split('\\');
Image1.Visible = true;
Panel1.Visible = true;
Image1.ImageUrl = "~/" + arr[arr.Length - 2] + "/" + arr[arr.Length - 1];
}
}
Gayathri, if this helps please login to Mark As Answer. | Alert Moderator