I am currently working on incorporating lazy high charts into my project using the GitHub repository found at this link. I have followed these steps:
Installed the Rails plugin with the command: rails plugin install git://github.com/michelson/lazy_high_charts.git
Created a new HighChart object in my controller:
@h = LazyHighCharts::HighChart.new('graph') do |f| f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9]) f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] ) end
- <%= Include the necessary JavaScript file 'highcharts' %>
- <%= Render the high chart using '<%= high_chart("my_id", @h) %>' %>
However, I encountered confusion when it came to placing the code within the controller. I attempted different approaches and faced various errors as listed below:
Attempt 1)
class DashboardController < ApplicationController
access_control do
actions :index do
allow :Admin
end
end
def index
@title = "Welcome to Dashboard"
before_filter :authenticate, :only => [:index]
@h = LazyHighCharts::HighChart.new('graph') do |f|
f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
end
end
end
Result =
Routing Error
uninitialized constant DashboardController::LazyHighCharts
Attempt 2)
class DashboardController::LazyHighCharts < ApplicationController
before_filter :authenticate, :only => [:index]
@h = LazyHighCharts::HighChart.new('graph') do |f|
f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
end
access_control do
actions :index do
allow :Admin
end
end
def index
@title = "Welcome to Dashboard"
end
end
View
<%= Include necessary JS files like 'jquery.dataTables.min', 'datatable', 'jquery.dataTables.columnFilter' %>
.....
<%= Render high chart using '<%= high_chart("my_id", @h) %>' %>
Result =
LoadError in DashboardController#index
Expected dashboard_controller.rb to define DashboardController
As a beginner in RoR and Javascript, I find this process challenging. Any suggestions or advice on where I might be going wrong would be greatly appreciated.