flotilla:日期范围的特定最小/最大值

时间:2022-09-26 21:17:33

I have a basic PageView model that tracks when a particular page is opened.

我有一个基本的PageView模型,可以跟踪特定页面的打开时间。

I want to display a graph of hits over time. I'm using flotilla for generating the graphs.

我希望显示随时间推移的命中图表。我正在使用flotilla来生成图表。

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).

现在,如果我有一系列的时间段的PageViews,但我想显示一个时间段,即使没有PageViews flotilla似乎渲染图形只包含第一个和最后一个PageView的时间(不是min /我想要的最大值)。

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.

但是,如果在Date.current的同一天创建商店,则不会呈现该日期范围。

I've also tried :mode=>"date" and :mode=>"datetime" but no luck.

我也尝试过:mode =>“date”和:mode =>“datetime”但没有运气。

Any ideas?

2 个解决方案

#1


0  

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.

看看flotila来源我敢打赌:xaxis min,max options没有正确转换。 Flot似乎期望以毫秒为单位的时间戳,你传递的是简单的Date对象,它刚刚被转换为json。

Try this :xaxis => {:mode=>"time", :min => @store_one.created_at.to_time.to_i * 1000,:max => Date.current.to_time.to_i * 1000}

试试这个: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.

免责声明:从未使用过flotila或flot。

#2


-1  

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

#1


0  

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.

看看flotila来源我敢打赌:xaxis min,max options没有正确转换。 Flot似乎期望以毫秒为单位的时间戳,你传递的是简单的Date对象,它刚刚被转换为json。

Try this :xaxis => {:mode=>"time", :min => @store_one.created_at.to_time.to_i * 1000,:max => Date.current.to_time.to_i * 1000}

试试这个: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.

免责声明:从未使用过flotila或flot。

#2


-1  

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