I currently have graphs on my Rails app that I implement using Chartkick. The following code is what I have in my view to render the actual graph. The path
graphs_site_hot_water_status_path(@site) connects to a controller where I have all the logic for how my data is being queried from the database, which ideally would stay the same as it is quite complex.
<%= line_chart graphs_site_hot_water_status_path(@site), colors: ['#AE42CE', '#DD6539','#093FF7', '#B2461F', '#A8BCFD', '#E68F6F'], refresh: @refresh_rate, ytitle: t(".fahrenheit"), xtitle: t(".timestamp") %>
Source: JavaSript – Stack Overflow