js图表控件:highcharts的应用(三)
线形图
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Line.aspx.cs" Inherits="hhh.Line" %>
后台代码:
public string str = "";//文本
public string strdata = "";//数据
public double allcount = 0;
protected void Page_Load(object sender, EventArgs e)
{
LoadData();
}
protected void LoadData()
{
XmlDocument myDoc = new XmlDocument();
myDoc.Load(Server.MapPath("DB_51aspx.xml"));
XmlNode xn = myDoc.SelectSingleNode("//VoteInfo[ID='2']");//读取数据源
XmlNodeList xnl = xn.SelectNodes("Item");
double AllCount = 0;//总数
for (int i = 0; i < xnl.Count; i++)
{
AllCount += Convert.ToSingle(xnl.Item(i).SelectSingleNode("Count").InnerText);
}
allcount = AllCount;
for (int i = 0; i < xnl.Count; i++)
{
XmlNode xn0 = xnl.Item(i);
strdata += xn0.SelectSingleNode("Count").InnerText+ ",";
str += "\'" + xn0.SelectSingleNode("Title").InnerText + "\'" + ",";
}
strdata = strdata.Remove(strdata.Length-1,1);
str = str.Remove(str.Length-1,1);
}
效果图展示: