Closed Devarshi87 closed 1 year ago
We've never heard of Salesforce Lightning Locker. Could you explain more about how you're using it?
The Lightning Locker is a security architecture for Lightning components. Its meant to enhance component security inside salesforce, more information can be found on this link .
At present just loading the script causes and undefined error
renderedCallback(){ Promise.all([ loadScript(this, amChart + '/amcharts/index.js'), loadScript(this, amChart + '/amcharts/xy.js'), loadScript(this, amChart + '/amcharts/Animated.js' ), ]) .then(() => { this.isChartJsInitialized = true; this.createChart(); }) .catch(error => { console.log('chartConfig======error===>',error); // this.dispatchEvent( // new ShowToastEvent({ // title: 'Error loading amChart', // message: error.message, // variant: 'error', // }) // ); }); }
Are you sure that the URL is correct? Shouldn't it be /amcharts/themes/Animated.js
?
I am loading it from a local resource, so the script shows up in the console properly.
What is your loadScript
function?
loadScript is a method provided by Lightning web component framework in salesforce to load third party scripts.
Well, I can't reproduce it in the console, I always get SecurityError: The operation is insecure.
and it refuses to run. So I think you'll have to ask Lightning Locker for help, since the problem is with their loading system / sandbox.
The Animated.js
file doesn't do anything weird, it just exports some classes, so I don't see any reason why it should break.
This issue is stale because it has been open 30 days with no activity. It will be closed in 5 days unless a new comment is added.
I am trying to use the amCharts in lightning web components in salesforce and the Animated.js script fails to load with a blank undefined error.
Any workarounds for this?
The locker service documentation can be found here - https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_api_viewer.htm
and the validation console is here
Thanks