I have a basic PageView model that tracks when a particular page is opened.
I want to display a graph of hits over time. I’m using flotilla for generating the graphs.
Now, I if I have a series of PageViews of a time period but I want to display a time period even if there are no PageViews flotilla seems to render a graphic that only encapsulates the time of the first and last PageView (not the min/max I want).
Here is my code:
chart("graph", { "Store 1" => { :collection => @store_one, :x => :date, :y => :sales }},:xaxis => {:mode=>"time", :min => @store_one.created_at,:max => Date.current})
But that date range is not rendered if the store is created on the same day as Date.current.
I’ve also tried :mode=>"date" and :mode=>"datetime" but no luck.
Any ideas?
Looking at flotila source I bet that
:xaxismin, max options are not converted correctly. Flot seems to expect timestamps in milliseconds, you are passing in plain Date object which is just converted to json.Try this
:xaxis => {:mode=>"time", :min => @store_one.created_at.to_time.to_i * 1000,:max => Date.current.to_time.to_i * 1000}Disclaimer: Never used flotila nor flot.