views:

99

answers:

2

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?

A: 

Looks like the you need an inclusive maximum (i.e. less than or equal to current date). Since you're dealing in whole days why not just do the following?

:max => Date.current+1
RobinGower
Tried that, no change
cbrulak
A: 

Looking at flotila source I bet that :xaxis min, 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.

johno