[英]Google Chart long Javascript Issue
。嗨,我一直在嘗試將Google日歷圖表添加到我的項目中,但是有一些我不理解的錯誤。
我的圖表位於一個彈出面板上,該彈出面板由單擊按鈕觸發 。
按鈕點擊功能:
function Detail(id)
{
google.charts.load("current", { packages: ["calendar"] });
google.charts.setOnLoadCallback(drawChart); //callback for chart
$.ajax({
//Some stuff here
});
$.ajax({
//Some other stuff here
});
}
因此,您可以在單擊按鈕后看到,必須運行drawChart。
function drawChart(){
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'date', id: 'Date' });
dataTable.addColumn({ type: 'number', id: 'done/miss' });
dataTable.addColumn({ type: 'string', role: 'tooltip', p: { html: true } });
dataTable.addRows([
[new Date(2017, 3, 9), 10, '<div style="width:40px; height:40px;">TESTtest</div>']
]);
var chart = new google.visualization.Calendar(document.getElementById('calendar'));
var options = {
title: "test",
height: '100%',
};
chart.draw(dataTable, options);
$('#PopUpDiv').show();
}
當我單擊按鈕頁面鎖定幾秒鍾時,Firefox會說:“ 腳本停止工作或不再響應,腳本: https ://www.gstatic.com/charts…sapi_compiled_format_module.js:179 ”
該代碼看起來非常簡單和正確。 我不知道發生了什么,所以一些幫助會很棒。 提前致謝。
編輯:我已經創建了代碼片段,並在那里嘗試該代碼,並且可以正常工作。 現在我被征服了:(
function Detail() { google.charts.load("current", { packages: ["calendar"] }); google.charts.setOnLoadCallback(drawChart); } function drawChart(){ var dataTable = new google.visualization.DataTable(); dataTable.addColumn({ type: 'date', id: 'Date' }); dataTable.addColumn({ type: 'number', id: 'done/miss' }); dataTable.addColumn({ type: 'string', role: 'tooltip', p: { html: true } }); dataTable.addRows([ [new Date(2017, 3, 9), 10, '<div style="width:40px; height:40px;">TESTtest</div>'] ]); var chart = new google.visualization.Calendar(document.getElementById('calendar')); var options = { title: "test", height: '100%', }; chart.draw(dataTable, options); }
<script src="https://www.gstatic.com/charts/loader.js"></script> <button type="button" onclick="Detail()">click it</button> <div id="calendar"></div>
我關閉了VS,然后重新啟動了項目,並以某種方式解決了問題。 所以代碼很好。 感謝大家的關注。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.