0
當我創建具有以下選項海軍報的圖形繪製圖形正確:flot打標功能,軸沒有定義?
var options = {
colors: trendcolors,
series: {
points: {
show: true
},
lines: {
show: true
}
},
xaxis: {
mode: "time",
axisLabel: "Date/Time",
tickLength: 0
},
yaxis: {
axisLabel: "Duration (Sec)"
},
selection: {
mode: "x"
},
grid: {
hoverable: true,
clickable: true,
markings: function (axes) {
var markings = [];
var date = new Date(axes.xaxis.min);
date.setUTCSeconds(0);
date.setUTCMinutes(0);
date.setUTCHours(0);
var i = date.getTime();
do {
markings.push({xaxis:{from: i, to: i + (24 * 60 * 60 * 1000) }, color: colormarking });
i += ((24 * 60 * 60 * 1000) * 2);
} while (i < axes.xaxis.max);
return markings;
}
},
legend: {
labelFormatter: function(label, series) {
return label + " (" + series.data.length + ")";
}
}
};
但是,當我改變標記匿名函數的標準功能出現錯誤和海軍報未能繪製圖形,因爲「軸'未在fMarkings行中定義。爲什麼是這樣?有什麼不同?
var options = {
colors: trendcolors,
series: {
points: {
show: true
},
lines: {
show: true
}
},
xaxis: {
mode: "time",
axisLabel: "Date/Time",
tickLength: 0
},
yaxis: {
axisLabel: "Duration (Sec)"
},
selection: {
mode: "x"
},
grid: {
hoverable: true,
clickable: true,
markings: fMarkings(axes)
},
legend: {
labelFormatter: function(label, series) {
return label + " (" + series.data.length + ")";
}
}
};
順便說一下,fMarkings是在另一個js塊中全局定義的。