1
<script src="../BootStrapFiles/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('visualization', '1', { packages: ['corechart'] });
// google.load('visualization', '1.1', { 'packages': ['bar'] });
</script>
<script type="text/javascript">
$(function() {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default.aspx/GetChartData',
data: '{}',
success:
function (response) {
drawchart(response.d);
},
error: function() {
alert("Error loading data!");
}
});
})
function drawchart(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Total amount');
// data.addColumn('string', 'Total amount2');
for (var i = 0; i < dataValues.length; i++) {
// data.addRows([dataValues[i].Year, dataValues[i].Total], dataValues[i].Year);
data.addRow([dataValues[i].Year, dataValues[i].Total]);
}
// new google.visualization.PieChart
// new google.visualization.BarChart( //LineChart //ColumnChart //ComboChart
new google.visualization.PieChart(document.getElementById('myChartDivPie')).
draw(data, { title: "Sales Pie chart last 8 days " });
new google.visualization.ColumnChart(document.getElementById('myChartDiv')).
draw(data, { title: "Sales Column chart last 8 days " });
}
</script>
這是我的代碼,當我在visual studio 2010上運行它運行完美。但是當試圖在Visual Studio 2015圖表上運行時,並沒有出現。請你幫我解決一下我在做什麼錯誤。是版本問題還是別的什麼?我的代碼是在visual studio 2010中開發的。每件事情都很完美,但圖表不可見。jsapi不在視覺工作室2015
謝謝你太多@whiteHat。這對我很有用,再次感謝你。 – user3402966
#whitehat我希望我可以:D但我很不幸 – user3402966