amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
Other
349 stars 92 forks source link

Animated.js File fails to work with salesforce lightning locker service #886

Closed Devarshi87 closed 1 year ago

Devarshi87 commented 1 year ago

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

Pauan commented 1 year ago

We've never heard of Salesforce Lightning Locker. Could you explain more about how you're using it?

Devarshi87 commented 1 year ago

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', // }) // ); }); }

Pauan commented 1 year ago

Are you sure that the URL is correct? Shouldn't it be /amcharts/themes/Animated.js?

Devarshi87 commented 1 year ago

I am loading it from a local resource, so the script shows up in the console properly.

Pauan commented 1 year ago

What is your loadScript function?

Devarshi87 commented 1 year ago

loadScript is a method provided by Lightning web component framework in salesforce to load third party scripts.

Pauan commented 1 year ago

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.

github-actions[bot] commented 1 year ago

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.