我使用HighChart显示某些容器的内存使用情况。问题是,有时尺度在K中有时在M中,有时没有任何东西(如下图所示):
这就是我创建HighChart的方式:
var cursor = Template.currentData();
liveChart = Highcharts.chart(cursor.chart_id, {
title: {
text: 'Memory usage of the controlcontainers_mongo_1'
},
xAxis: {
type: 'datetime',
},
yAxis: {
title: {
text: 'usage'
}
},
tooltip: {
formatter: function() {
return '<b>' + this.series.name + '</b><br/>' + Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>';
}
},
series: [{
type: 'line',
name: 'memory usage',
data: []
}]
});
如果有人需要,这是我的格式化程序:
formatter: function() {
var usage = this.value;
if((usage >= 1000000)&&(usage < 1000000000)){
return (usage/1000000).toFixed(2) + "MB";
}else if (usage >= 1000000000) {
return (usage/1000000000).toFixed(2) + "GB";
}else{
return usage + "KB";
}
}
答案 0 :(得分:0)
您可以在y轴格式化功能中舍入值
else if (val=='i'){
myservo.write(0);
delay(4000);
for(pos = 0; pos <= 90; pos += 1){
myservo.write(pos);
delay(15);
}
}
else if (val=='j'){
myservo.write(0);
delay(4000);
for(pos = 90; pos >= 0; pos -= 1){
myservo.write(pos);
delay(15);
}
}
&#13;
了解更多here