-1
並提前致謝。 我有這個問題,在插件時,當我帶一個ajax信息與「Morris.js」建立一個條形圖,軸的每個第二個酒吧沒有顯示的信息,但如果我直接寫「json」它工作的代碼很好,我的錯誤是什麼?這裏是代碼:Morris.js缺少標籤寫入每個
$(document).ready(function(){
var numberOfSeconds=30*1000; //the interval of refreshing the information of the calls per server
var x=getTheInfoAboutTheServers();
//The m_graph contains an information
//and build the graph itself later we update the data with the m_graph.setData() function
var m_graph= Morris.Bar({
element: 'my_chart',
data: x,
xkey: 'y',
ykeys: ['a'],
labels: ['Number of calls']
});
/**
* This Function get the number of calls per each server
* return a JSON object to the morris.js pluggin
*/
function getTheInfoAboutTheServers(){
var inf=null;
$.ajax({
async: false,
type: "POST",
url : $('#site_url').val()+"index.php/Login_controller/mw_iaa_rawGraphInfoClient",
dataType: "JSON",
success: function(data){
var dataArr=[];
for (key in data) {
if (!isNaN(key)) {
var obj = data[key];
var mySplitResult = obj['callserver'].split(".");
var calls=parseInt(obj['numOfCalls']);
dataArr.push({ y: String(mySplitResult[0]), a : calls});
}
}
inf=dataArr;
}
});
return inf;
}
謝謝你的答案Ajax的成功方法中調用另一個函數,但它也有一個返回JSON和我看到圖 – user1823410
我也看到一切正確的工具提示,但在軸每隔一列錯過了它的名字 – user1823410