ankane / chartkick

Create beautiful JavaScript charts with one line of Ruby
https://chartkick.com
MIT License
6.33k stars 565 forks source link

Sinatra support for Chart.js and Highcharts #549

Closed blakegearin closed 3 years ago

blakegearin commented 3 years ago

Is your feature request related to a problem? Please describe. While using chartkick.js with Sinatra it seems the charting library being used is Google Charts. I would like to be able to switch between Chart.js, Google Charts, and Highcharts

Describe the solution you'd like

  1. Provide different flavors chartkick.js for different charting libraries OR
  2. More documentation around how to use the existing chartkick.js with Chart.js and Highcharts. For instance, do other .js files need to be downloaded and included with a script tag? If so, what should be downloaded?

Additional context For Chart.js I tried the following:

  1. Downloaded Chart.min.js version 2.9.3 from a Chart.js CDN (raw file)
  2. Added line 3 to my layout.haml file (which was previously working, displaying a chart using Google Charts))
    1 %script{ src: '//www.google.com/jsapi' }
    2 %script{ type: 'text/javascript', src: "/javascripts/chartkick.js" }
    3 %script{ type: 'text/javascript', src: "/javascripts/Chart.min.js" }
  3. Got this error in the browser console:
    chartkick.js:1763 Uncaught Error: This method is not implemented: either no adapter can be found or an incomplete integration was provided.
ankane commented 3 years ago

Hey @blakegearin, thanks for the suggestion! You'll need to use Chart.bundle.js instead of Chart.min.js. I've expanded the docs in the readme.