How To Include Any Chart In Your Rails App
By: Prem Kaithwas Category: Ruby on Rails Technologies: Ruby on Rails
If you want to chart different types of charts in your application using a single library, the Apex charts library is a good one I know.
Follow these steps to use the apex-charts library in your rails application.
1. Open your terminal and run this command to create your brand new rails app.
rails new my-app
2. Install all the necessary gems required by our rails app by running this command.
3. Create a database for our application by this command.
4. Let’s generate a scaffold for Model Student by running this command.
rails g scaffold Student name marks:integer
5. Migrate database by running this command
6. Start the server to check, we are going well till here by running rails s.
7. If everything is going well, create some records.
8. To add the apex-chart library in your rails app, you can add it using cdn or by using npm.
Goto this link for more details.
9. I have used cdn to include the apex-chart library in our rails app, the script for cdn is below:
10. Now visit the apex-chart official website to quickly get the code for your required chart. Once you are on the apex-chart website choose any chart you want in your app by clicking on it. Follow this link to get there directly.
12. You got your chart.
Originally published at https://www.cryptextechnologies.com.