Draw BarChart / LineChart using Chart.js in Lightning Component

  1. Download chart.js file from https://cdnjs.com/libraries/Chart.js and add it as a static Resource in your org and name it “Chart”.

2. Create a new lightning Component “ChartComp”.

3) Click on the Controller and paste the following code.

4) Click helper and paste the following code.

5) Create a new Apex class “GraphController” and paste the following code.

These are just the mock data for this tutorial.

6) You can test this component by adding it to the lightning app and the graph looks like this: