For content creators, "clicks per day" is a very important metric. They love to see the interaction and engagement happening on a day-to-day basis. We can plot the click data for the authors of the articles using the morris.js
charts where morris.js
is a library for plotting the data as line charts, bar charts, and donut charts. This is the reporting part of our analytics dashboard.
We will now plot the data that we have collected and analyzed in our previous tasks:
The
morris.js
library comes packaged as a gem. It also depends on an SVG that renders a canvas library calledraphael js
.Gemfile gem 'morrisjs-rails' gem 'raphael-rails'
We will add this to the
Gemfile
and runbundle
.We will then define the JavaScript in our
application.js
file. We have to ensure that these lines are placed beforerequire turbolinks
andrequire_tree
:app/assets/javascripts/application.js //= require raphael //= require morris //= require turbolinks...