clean up year display in x-axis of flot graph
Previously, if there were more than 20 years in the range of returned data, the years appearing along the x-axis in the flot graph overwrote each other.
I changed the init-flot.js file by replacing this:
xaxis: {
tickSize: 1,
tickFormatter: function(val, axis) {
if (!yearTotals[val]) {
return val;
} else {
return val + '<br />' + yearTotals[val];
}
}
}
with this:
xaxis: {
ticks: 20,
tickDecimals: 0,
tickFormatter: function(val, axis) {
return ' ' + val;
}
}
The ticks limits the number of years explicitly labelled to a maximum of 20, thus taking care of the overlapping year display on the x-axis when there are lots of years in the chart.
The tickDecimals controls whether fractions of years get ticks on the x-axis. For small year ranges, if this is not set to 0, you get values like 1744.5 appearing, which is nonsensical for this dataset.
Since not all years get a tick on the x-axis, it didn't seem to make sense to display the total hits, so I've removed that from the tickFormatter.
I prefer the year label to be left justified to the left side of the column in the graph, rather than centered on the left side of the column, so I added those spaces to push the date to the left.