diff --git a/Gemfile b/Gemfile index c75891b..ccbddb5 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,8 @@ gem "stimulus-rails" # Build JSON APIs with ease [https://github.com/rails/jbuilder] gem "jbuilder" +gem "chartkick" + # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] # gem "bcrypt", "~> 3.1.7" diff --git a/Gemfile.lock b/Gemfile.lock index f78761c..0e807d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,6 +96,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + chartkick (5.1.2) concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) @@ -362,6 +363,7 @@ DEPENDENCIES bootsnap brakeman capybara + chartkick debug importmap-rails jbuilder diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..95f2992 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,4 @@ +class HomeController < ApplicationController + def index + end +end diff --git a/app/javascript/application.js b/app/javascript/application.js index 0d7b494..af15016 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,3 +1,6 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "@hotwired/turbo-rails" import "controllers" + +import "chartkick" +import "Chart.bundle" diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000..b1bd2cb --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1 @@ +<%= pie_chart [["A", 1], ["B", 2]] %> diff --git a/config/importmap.rb b/config/importmap.rb index 909dfc5..0a55179 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -5,3 +5,6 @@ pin "@hotwired/stimulus", to: "stimulus.min.js" pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" pin_all_from "app/javascript/controllers", under: "controllers" + +pin "chartkick", to: "chartkick.js" +pin "Chart.bundle", to: "Chart.bundle.js" diff --git a/config/routes.rb b/config/routes.rb index 48254e8..371769b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,5 +10,5 @@ # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker # Defines the root path route ("/") - # root "posts#index" + root "home#index" end