I am building a linear graph with Dygraphs. I have "1 2 3 4" on x axis, and "12, 55, 23, 18" on y axis. When I plot the graph, the tick has in-between number.
For example between 1 and 2 I can see 1.5 on the x axis. I want to have the exact intervals as I specified up as 1 increment. Is there a way to fix this problem ? How to do this in Dygraph ? This is an example :
<html>
<head>
<script type="text/javascript"
src="dygraph-combined.js"></script>
</head>
<body>
<div id="graphdiv"></div>
<script type="text/javascript">
g = new Dygraph(
// containing div
document.getElementById("graphdiv"),
// CSV or path to a CSV file.
("Response Time,Loop\n" +
"01,175\n" +
"02,170\n" +
"03,180\n" +
"04,177\n" +
"05,179\n"+
"06,165\n")
);
</script>
</body>
</html>
There's no built-in support for this (you should star issue 368). But you can simulate it by defining an axisValueFormatter which returns the empty string for non-integers:
axes: {
x: {
axisLabelFormatter: function(num, gran, opts, g) {
if (num == Math.floor(num)) {
return Dygraph.numberAxisLabelFormatter(num, gran, opts, g);
} else {
return '';
}
}
}
}
Fully-functioning demo here.