import { LightningElement ,track,wire,api} from 'lwc'; import { loadScript } from 'lightning/platformResourceLoader'; import HIGHCHARTS from "@salesforce/resourceUrl/D3chartjs"; import partnerSpendData from '@salesforce/apex/AccountSnapshot_Partnerdetails.getAccSnapshotPartnerDetailNew';
export default class AccountPieChart extends LightningElement { @track error; @track data; @api recordid; chartResourcesLoaded=false;
@wire(partnerSpendData, import {accountId :LightningElement '$recordid'})
partnerSpend({error,data}){
if(data){
this.data = data.map(record => {
return {
y: record.datatrack,
name: record.Name
}
});
console.log("++++Data++++"wire,data);
this.error=undefined;
api} from this.runHighcharts();'lwc';
import { loadScript }
else if (error)from {'lightning/platformResourceLoader';
import this.errorHIGHCHARTS =from error;"@salesforce/resourceUrl/D3chartjs";
import partnerSpendData from this'@salesforce/apex/AccountSnapshot_Partnerdetails.partnerSpend = undefined;
}
}getAccSnapshotPartnerDetailNew';
renderedCallbackexport default class AccountPieChart extends LightningElement {
@track error;
@track data;
@api recordid;
chartResourcesLoaded=false;
@wire(partnerSpendData, {accountId : '$recordid'})
partnerSpend({error,data}){
if(data){
this.data = data.map(record => {
return {
y: record.data,
name: record.Name
}
});
console.log("++++Data++++",data);
this.error=undefined;
loadScript(this, HIGHCHARTS + "/highcharts this.js"runHighcharts();
.then( }
else if (error) => {
console this.log("SUCCESS:error highcharts= error;
this.js");partnerSpend = undefined;
}
}
loadScript(this, HIGHCHARTS + "/highcharts-3d.js")
.then(renderedCallback() => {
console.log("SUCCESS: highcharts.js");
loadScript(this, HIGHCHARTS + "/exporting.js")
.then(() => {
console.log("SUCCESS: exporting.js");
loadScript(this, HIGHCHARTS + "/export-datahighcharts.js")
.then(() => {
console.log("SUCCESS: export-datahighcharts.js");
//
loadScript(this, HIGHCHARTS + "/highcharts-3d.runHighchartsjs")
.then(() => {
console.log("SUCCESS: highcharts.js");
loadScript(this, HIGHCHARTS + "/accessibilityexporting.js")
.then(() => {
console.log("SUCCESS: exporting.js");
loadScript(this, HIGHCHARTS + "/export-data.js")
.then(() => {
console.log("SUCCESS: export-data.js");
// this.runHighcharts();
loadScript(this, HIGHCHARTS + "/accessibility.js")
.then(() => {
console.log("SUCCESS: accessibility.js");
this.chartResourcesLoaded = true;
this.runHighcharts();
})
.catch(error => console.log("ERROR: accessibility.js"));
})
.catch(error => console.log("ERROR: accessibilityexport-data.js"));
})
.catch(error => console.log("ERROR: export-dataexporting.js"));
})
.catch(error => console.log("ERROR: exporting.js"));
})
.catch(error => console.log("ERROR: highcharts-3d.js"));
})
.catch(error => console.log("ERROR: highcharts.js"));
}
runHighcharts() {
if(this.chartResourcesLoaded && this.data){
const containerId = this.template.querySelector('div').id;
console.log('containerId: ',containerId);
let container = this.template.querySelector('.chartContainer')
console.log('data: ',this.data);
Highcharts.chart(container, {
Highcharts.chart: {
type: 'pie'(container,
options3d: {
enabled: true,
alpha: 45,
beta: 0
}
},
titlechart: {
texttype: 'Browser market shares in January'pie', 2018'
},
creditsoptions3d: {
enabled: false
},
exporting: {
enabled: false
}true,
tooltip: {
pointFormat: '{series.name}: <b>{point.percentagealpha:.1f}%</b>'
}45,
accessibility: {
point: {
valueSuffixbeta: '%'0
}
},
plotOptions title: {
pie text: {'Browser market shares in January, 2018'
},
allowPointSelect credits: true,{
cursorenabled: 'pointer',false
},
depth exporting: 35,{
dataLabelsenabled: {false
},
enabled: true,
tooltip: {
format pointFormat: '<b>'{pointseries.name}</b>: <b>{point.percentage:.1f}%</b>'
%' },
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
depth : 35,
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
type: 'pie',
data: this.data
}],
}
);
}
}
}
}