Posts

Showing posts from June, 2020

Lightning component to display chart using Chart.Js

Image
In the following example, we are using Chart.Js plugin to implement Chart in our lightning component . I am using Account and it's related Contact for showing how many contact are related to one account graphically. Screenshots: - Apex: -   public class getContact {     @AuraEnabled     public static List<Contact> getContactList(){         List<Contact> con = [SELECT Id, Name, Email, Account.Name FROM Contact];         return con;     } } Component: - <aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="getContact"> <!--attributes-->     <ltng:require scripts="{!$Resource.chartNew}" afterScriptsLoaded="{!c.scriptsLoaded}"/> <!--include chart JS plugin from static resource-->          <aura:handler name="init" value="{!this}" action="{!c.init}" /> <!--init method for getting contacts and acco...