2017-05-31 6 views
0

。私は自分のプロジェクトにgoogle calendar chartを追加しようとしていましたが、わからないことが間違っています。Google Chart long JavaScriptの問題

私のグラフは、をクリックしてがトリガーするポップアップパネルにあります。ここに私のコードがあります。

ボタンのクリック機能は:

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

コードは実際に見えますシンプルで正しい。私は何が起こっているのか理解していないので、いくつかの助けは素晴らしいだろう。前もって感謝します。

編集:私はコードを作成してそこにこのコードを試してみました。今私はconfucedよ:(

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>

答えて

0

コードで結構ですので、私は。VSを閉鎖し、問題解決何とかプロジェクトを再起動します。注意のためのみんなありがとう。

関連する問題