用OWC
SqlConnection cn = 
new SqlConnection("Server=(local);DataBase=Northwind;user id=sa;password=232323;"); cn.Open();
DataSet ds = new DataSet("Chart");
SqlDataAdapter da = new SqlDataAdapter("CustorderHist 'ALFKI'", cn);
da.Fill(ds);
OWC11.ChartSpaceClass oChartSpace = new OWC11.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=1;i<nCount;i++)
{
aNames[i]= nodes.Item(i-1).ChildNodes.Item(0).InnerText;        
aTotals[i]= nodes.Item(i-1).ChildNodes.Item(1).InnerText;
}
        
names= String.Join("\t", aNames);  //Chart control accepts tab-delimited string of values
totals= String.Join("\t", aTotals);
oChartSpace.Charts.Add(0); oChartSpace.Charts[0].SeriesCollection.Add(0);
oChartSpace.Charts[0].Type=OWC11.ChartChartTypeEnum.chChartTypeSmoothLine;//类型
oChartSpace.Charts[0].HasLegend = true; //系列
oChartSpace.Charts[0].HasTitle = true;
oChartSpace.Charts[0].Title.Caption="你好啊";
oChartSpace.Charts[0].SeriesCollection[0].Caption="ttttt"; oChartSpace.Charts[0].SeriesCollection[0].Line.Color="Olive"; oChartSpace.Charts[0].SeriesCollection[0].SetData(OWC11.ChartDimensionsEnum.chDimCategories,
Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral),names );
oChartSpace.Charts[0].SeriesCollection[0].SetData(OWC11.ChartDimensionsEnum.chDimValues,
Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral),totals ); oChartSpace.Charts[0].SeriesCollection.Add(0); oChartSpace.Charts[0].SeriesCollection[1].SetData(OWC11.ChartDimensionsEnum.chDimCategories,
Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral),names );
oChartSpace.Charts[0].SeriesCollection[1].SetData(OWC11.ChartDimensionsEnum.chDimValues,
Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral),totals ); oChartSpace.Charts[0].SeriesCollection[1].Caption="sss";
oChartSpace.Charts[0].SeriesCollection[1].Line.Color="red"; string strFullPathAndName=Server.MapPath(System.DateTime.Now.Ticks.ToString() +".gif");
oChartSpace.ExportPicture( strFullPathAndName, "gif", 800, 600);
Image1.ImageUrl=strFullPathAndName;
Image1.Visible =true;
RemoveFiles(Server.MapPath("."));
}
private void RemoveFiles(string strPath)
{  
System.IO.DirectoryInfo di = new DirectoryInfo(strPath);
FileInfo[] fiArr = di.GetFiles();
foreach (FileInfo fi in fiArr)
{               
if(fi.Extension.ToString() ==".gif" )
{
// if file is older than 2 minutes, we'll clean it up
TimeSpan min = new TimeSpan(0,0,0,2,0);
if(fi.CreationTime < DateTime.Now.Subtract(min))
{
fi.Delete();
}
}
}
}