告訴我如何從數據庫中獲取價值到highchart,來自asp.net數據庫的highcharts值c#
高圖的代碼。 。
$( '#account_details_chart')highcharts({ 圖表:{ 類型: 'areaspline' },
legend: {
layout: 'inline-block',
align: 'right',
verticalAlign: 'top',
x: 0,
y: 10,
floating: true,
borderWidth: 1,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
xAxis: {
categories: company,
plotBands: [{ // visualize the weekend
from: 6.5,
to: 6.5,
color: 'rgba(68, 170, 213, .2)'
}]
},
yAxis: {
title: {
text: 'Amount In Rupees'
}
},
tooltip: {
shared: true,
valuePrefix: 'Rs. ',
valueSuffix: ' /-'
},
credits: {
enabled: true
},
plotOptions: {
areaspline: {
fillOpacity: 0.5
}
},
series: [{
name: 'Debit Amount',
data: debit_amount
}, {
name: 'Credit Amount',
data: credit_amount
}]
});
});
代碼後面
保護無效的Page_Load(對象發件人,EventArgs e) {
List<string> tempString = new List<string>();
tempString.Add("Hello");
tempString.Add("World");
tempString.Add("Hello");
tempString.Add("World");
tempString.Add("Hello");
tempString.Add("World");
//string builder for binding data in script
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("var company = new Array;");
foreach (string str in tempString)
{
sb.AppendFormat("company.push('{0}');", str);
}
sb.Append("</script>");
//sending data through client script register
ClientScript.RegisterStartupScript(this.GetType(), "TestArrayScript", sb.ToString());
List<int> DebitAmount = new List<int>();
DebitAmount.Add(2);
DebitAmount.Add(3);
DebitAmount.Add(2);
DebitAmount.Add(4);
StringBuilder sb2 = new StringBuilder();
sb2.Append("<script type='text/javascript'>");
sb2.Append("var debit_amount = new Array;");
foreach (int str2 in DebitAmount)
{
sb2.AppendFormat("debit_amount.push('{0}');", str2);
}
sb2.Append("</script>");
//sending data through client script register
ClientScript.RegisterStartupScript(GetType(), "ArrayScript", sb2.ToString());
}
公司數組工作正常x軸但debit_amount陣列不起作用