Charts DEC“},{v:null},{v:541438.55},{v:442690.4},{v:394919.81},{v:497903.68},{v:198755.42},{c:[{v:NOV},{v:null},{v:442690.4},{v:4449491
Charts DEC“},{v:null},{v:541438.55},{v:442690.4},{v:394919.81},{v:497903.68},{v:198755.42},{c:[{v:NOV},{v:null},{v:442690.4},{v:4449491,charts,google-visualization,Charts,Google Visualization,DEC“},{v:null},{v:541438.55},{v:442690.4},{v:394919.81},{v:497903.68},{v:198755.42},{c:[{v:NOV},{v:null},{v:442690.4},{v:44494919.81},{v:497903.68},{v:198755},{`当我有这个,它是给你的时间,它没有显示任何东西,我改变行,但它没有显示任何东西你必须确保你传递的json数据看起来就像上面的例子。你能分享你是如何在服务器上创建json的吗?我不
DEC“},{v:null},{v:541438.55},{v:442690.4},{v:394919.81},{v:497903.68},{v:198755.42},{c:[{v:NOV},{v:null},{v:442690.4},{v:44494919.81},{v:497903.68},{v:198755},{`当我有这个,它是给你的时间,它没有显示任何东西,我改变行,但它没有显示任何东西你必须确保你传递的json数据看起来就像上面的例子。你能分享你是如何在服务器上创建json的吗?我不知道webmethod,或者如何创建你需要的结构服务器。相反,请参见上面的编辑…天哪,谢谢你,所以穆奇兄弟,它成功了,谢谢,真的谢谢
All series on a given axis must be of the same data type
google.charts.load('current', {packages: ['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var options = {
title: 'Reparation par RSP',
width: '100%',
height: 500,
bar: { groupWidth: "75%" },
seriesType: 'bars',
series: { 5: { type: 'line' } },
colors: ['#dacfcf','#fee812','#ff7900','#ff0000','#ff0000'],
legend: 'right',
curveType: 'function',
isStacked: true,
hAxis: { format: '###' },
titleTextStyle: {
fontSize: 32,
},
};
$.ajax({
type: "POST",
url: "ReparationParRSP.aspx/GetChartData",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var data = google.visualization.arrayToDataTable(r.d);
var view = new google.visualization.DataView(data);
view.setColumns([0,
1, {calc: function (dataTable, rowIndex) {return getAnnotation(dataTable, rowIndex, 1);}, type: "string", role: "annotation" ,sourceColumn: 1},
2, {calc: function (dataTable, rowIndex) {return getAnnotation(dataTable, rowIndex, 2);}, type: "string", role: "annotation" ,sourceColumn: 2},
3, {calc: function (dataTable, rowIndex) {return getAnnotation(dataTable, rowIndex, 3);}, type: "string", role: "annotation" ,sourceColumn: 3},
4, {calc: function (dataTable, rowIndex) {return getAnnotation(dataTable, rowIndex, 4);}, type: "string", role: "annotation" ,sourceColumn: 4},
5, {calc: function (dataTable, rowIndex) {return getAnnotation(dataTable, rowIndex, 5);}, type: "string", role: "annotation" ,sourceColumn: 5}
]);
function getAnnotation(dataTable, rowIndex, columnIndex) {
return dataTable.getFormattedValue(rowIndex, columnIndex) || null;
}
var chart = new google.visualization.BarChart($("#chart_div")[0]);
chart.draw(view, options);
// updateChart();
},
});
[WebMethod]
public static List<object> GetChartData()
{
string query = "select * from tblrespo";
List<object> chartData = new List<object>();
chartData.Add(new object[]
{
"Nome","0_2","2_4","4_8","8_24","+24"
});
using (SqlConnection con = new SqlConnection("Data Source=DESKTOP-BCMH2U1\\SQLEXPRESS;Initial Catalog=DB_B2B;Integrated Security=True"))
{
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
var rsp = sdr[0];
if (rsp.ToString()=="")
{
rsp = "aucune info";
}
chartData.Add(new object[]
{
rsp, sdr[1],sdr[2],sdr[3],sdr[4],sdr[5]
});
}
}
con.Close();
return chartData;
}
}
}
All series on a given axis must be of the same data type
var data = new google.visualization.DataTable({
"cols": [
{"label": "Month", "type": "string"},
{"label": "Y0", "type": "number"},
{"label": "Y1", "type": "number"},
{"label": "Y2", "type": "number"},
{"label": "Y3", "type": "number"},
{"label": "Y4", "type": "number"},
{"label": "Y5", "type": "number"}
],
"rows": [
{"c":[{"v":"FEB"},{"v":null},{"v":541438.55},{"v":442690.4},{"v":394919.81},{"v":497903.68},{"v":198755.42}]},
{"c":[{"v":"JAN"},{"v":null},{"v":541438.55},{"v":442690.4},{"v":394919.81},{"v":497903.68},{"v":198755.42}]},
{"c":[{"v":"DEC"},{"v":null},{"v":541438.55},{"v":442690.4},{"v":394919.81},{"v":497903.68},{"v":198755.42}]},
{"c":[{"v":"NOV"},{"v":null},{"v":541438.55},{"v":442690.4},{"v":394919.81},{"v":497903.68},{"v":198755.42}]}
]
});