I am trying to follow this documentation to create a D3 Simple Bar graph in my web component. At the very bottom you will see the section Other Useful Patterns followed by a piece on how to load a script resource. In enter link description here they say you n need to load this script in order to use the scaleBand method for Bar Graphs:
<script src="https://d3js.org/d3-selection-multi.v1.min.js"></script>
So, what I attempted to do was put this in my JS file:
import { LightningElement } from 'lwc';
import { loadScript, loadStyle } from 'lightning/platformResourceLoader';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import D3 from '@salesforce/resourceUrl/D3JavaScript';
export default class YtpReport extends LightningElement {
svgWidth = 400;
svgHeight = 400;
d3Initialized = false;
loadScript(this, D3 + '/d3-selection-multi.v1.min.js').then(() => {});
...
}
But I get the unexpected token error on the 15th column of the loadScript line...
How are you suppose to load this kind of resource?