The default Dygraphs x-axis range seems to be [first x-value, last x-value] rather than [minimum x-value, maximum x-value]. Is this deliberate? I haven't seen anything that says your input data must be sorted, nor have I found any way of setting the x-axis range like "valueRange" does for y-axes.
Ex. input data:
[[5,1,2,3],
[2,4,5,6],
[3,7,8,9],
[4,1,5,9],
[5,5,5,5]]
The x-values range from [2,5], but my Dygraph always shows up with an x-axis at [5,5]. I tried setting an option as follows but it doesn't work, presumably because "valueRange" is defined for vertical height only:
{
axes: {
x: {
valueRange: [2,5]
}
}
}
For now I can go to the trouble of sorting all my input, but it would be rather more logical to change the default.
dygraphs expects its input to be sorted. I'm surprised that it's not logging a warning about this (see issue 584). If you break the expectations about input format, there are no guarantees. I'd expect many of dygraphs' methods to fail with this input.
So, sort your data! It shouldn't be much "trouble"—every programming language has built-in tools for sorting lists.
To answer your other question, you can use the oddly-named dateWindow
option to specify the x-axis range (i.e. the domain):
g = new Dygraph(div, data, { dateWindow: [2, 5] });