You need to sign in to do that
Don't have an account?
Akhil Katkam 5
issue with my lwc code
Hi Developer Community ,
i have a task , where i need to display 3 field values in chart based on the current record id values, i have tried using lwc , i will post the code here
as u can see i have taken apex class where there are 3 values domain 1 , 2 , 3 (these 3 fields are present in competition object ) , based on the these particular record , values need to displayed on chart ,
can anyone plz check the code and help me with the solution
Thanks in advance
i have a task , where i need to display 3 field values in chart based on the current record id values, i have tried using lwc , i will post the code here
.JS: import { LightningElement, track,wire ,api } from 'lwc'; import getcompetition from '@salesforce/apex/GEN_ChartController.getcompetition'; export default class Gen_opportunitychart extends LightningElement { chartConfiguration; @track recId; @api recordId; @track clist; @wire(getcompetition,{rec:'$recordId'}) getcompetition({ error, data }) { if (error) { this.error = error; this.chartConfiguration = undefined; } else if (data) { let chartDomain1 = []; let chartDomain2 = []; let chartDomain3 = []; var clist = data; this.clist=data; clist.Domain1= data.forEach(opp => { chartDomain1.push(opp.Domain1); chartDomain2.push(opp.Domain2); chartDomain3.push(opp.Domain3); }); this.chartConfiguration = { type: 'bar', data: { datasets: [{ label: 'Domain1', backgroundColor: "green", data: chartDomain1, }, { label: 'Domain2', backgroundColor: "red", data: chartDomain2, }, { label: 'Domain3', backgroundColor: "blue", data: chartDomain3, }, ],labels:chartDomain1,chartDomain2,chartDomain3, }, options: {}, }; console.log('data => ', data); this.error = undefined; } } }
APEX CLASS: public class GEN_ChartController { @AuraEnabled(cacheable=true) public static Competition__c getcompetition(string rec){ return [SELECT Domain1__c , Domain2__c, Domain3__c FROM Competition__c WHERE id=:rec]; } }
as u can see i have taken apex class where there are 3 values domain 1 , 2 , 3 (these 3 fields are present in competition object ) , based on the these particular record , values need to displayed on chart ,
can anyone plz check the code and help me with the solution
Thanks in advance