有没有办法在我的dygraph上显示正值..我的Y和X轴在0处开始?
我可以添加一个选项,或者我需要为y轴选项调整customRange并计算每个图形的每个最大/最小值?
我的选择是:
var options = {
labels: labels,
showRangeSelector: true,
legend: 'always',
ylabel: units,
title: graphTitle,
includeZero: true,
axes: {
y: {
valueFormatter: function (value, opts, seriesName, dygraph, row, col) {
if (seriesName == "Mode") {
return modemMode[value];
} else if (seriesName == "Submode") {
return modemSubmode[value];
} else if (seriesName == "Sysmode") {
return modemSysmode[value];
} else if (seriesName == "Roaming") {
return modemRoaming[value];
}
return value;
}
}
},
underlayCallback: function(canvas, area, g) {
for (var i=0; i<highlightArea.length; i++) {
var left = g.toDomXCoord(highlightArea[i][0]);
var right = g.toDomXCoord(highlightArea[i][1]);
canvas.fillStyle = "rgba(217, 101, 87, 0.2)";
canvas.fillRect(left, area.y, right - left, area.h);
}
}
}
答案 0 :(得分:1)
You can use the valueRange
option to achieve this:
new Dygraph(div, data, {
valueRange: [0, null] // null means "calculate max from the data"
});
Here's a full example.