Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 轨道4+;根据HighCharts中的日、周、月和年过滤数据_Ruby On Rails 4_Highcharts - Fatal编程技术网

Ruby on rails 4 轨道4+;根据HighCharts中的日、周、月和年过滤数据

Ruby on rails 4 轨道4+;根据HighCharts中的日、周、月和年过滤数据,ruby-on-rails-4,highcharts,Ruby On Rails 4,Highcharts,在我的Sqlite表中,我有超过5年的产品价格和数量记录。现在,我正试图在高图中呈现数据。对于过滤部分,我放置了4个单选按钮,即日、周、月和年 如果用户单击日期选择,则图形应呈现按日期显示的数据。若用户点击Week按钮,那个么Graph应该呈现每周的计算值,依此类推 现在我没有办法实现它。我试图在模型中实现过滤器代码 请提供一些建议,如何继续。此解决方案速度快且不干净,可能存在一些性能问题。我将在下面建议潜在的优化 假设产品模型具有以下模式 # Table name: products # #

在我的Sqlite表中,我有超过5年的产品价格和数量记录。现在,我正试图在高图中呈现数据。对于过滤部分,我放置了4个单选按钮,即日、周、月和年

如果用户单击日期选择,则图形应呈现按日期显示的数据。若用户点击Week按钮,那个么Graph应该呈现每周的计算值,依此类推

现在我没有办法实现它。我试图在模型中实现过滤器代码


请提供一些建议,如何继续。

此解决方案速度快且不干净,可能存在一些性能问题。我将在下面建议潜在的优化

假设产品模型具有以下模式

# Table name: products
#
#  id         :integer          not null, primary key
#  name       :string
#  amount     :float
#  quantity   :integer
#  created_at :datetime         not null
#  updated_at :datetime         not null
models/product.rb
中:

类产品