Setting up LightningChart resources
LightningChart JS is distributed along with some static resource assets, which are required for select features only. Some examples include MapChart, OnScreenMenu, Themes that use background pictures and Zoom band chart.
When any of these features are used, the user has to ensure that the necessary resources are hosted on a file server where LightningChart JS can fetch them. In official LightningChart JS example frameworks, templates and projects, this setup is usually done beforehand using Webpack configurations or equivalent.
The resources are distributed along with the NPM bundle under @arction/lcjs/dist/resources folder.
Example: Local file server
cd node_modules/@arction/lcjs/dist/resources
npx http-server --cors
const lcjs = lightningChart({
resourcesBaseUrl: 'http://127.0.0.1:8081', // <--- or whichever port http-server assigned.
})
Example: Webpack config
If you copy the resources folder to the Webpack build, then LightningChart JS finds it without having to change the default resourcesBaseUrl value.
// webpack.config.js
plugins: [
new CopyPlugin({
patterns: [
{ from: "node_modules/@arction/lcjs/dist/resources", to: "resources" },
],
}),
]