I am attempting to display this months (chart 1) and last months (chart 2) visitor count on one chart with Flot. I currently have chart 1 working, but I’m not sure how to overlay with with chart 2 due to the x-axis (date).
Current working code:
$.getJSON('jsondata.txt',function(json){
var visits = [json.visits];
var options = {
xaxis: {
mode: "time",
},
grid: { hoverable: true, clickable: true },
lines: { show: true },
points: { show: true }
}
var plot = $.plot($('.chart'),visits,options);
});
What you need is to explore the xaxes array/option in flot. From the API.txt:
So in your case, instead of defining
xaxis, you specify something like this:And then you’ll need series objects instead of just arrays, and assign each one to a different axis:
Finally, instead of plotting just
visits, you would plot[visits,prevVisits]See it in action here: http://jsfiddle.net/ryleyb/SBrkW/