highcharts / highcharts/node-export-server
Inject css variables using nodejs module
- Dominant language
- JavaScript
- Stars
- 369
- Forks
- 266
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
My team and I are attempting to implement the export module to enable the downloading of our charts. However, we’re encountering an issue due to our extensive use of CSS variables, which your server doesn’t seem to accept as it doesn’t allow external resources.
I’ve begun setting up the export server Node.js module on our Express app. The image generation appears to be functioning well, but we’re still facing the same issue. We’re unable to inject the CSS variables. Here’s how we’ve implemented it:
```javascript
module.exports = {
downloadChart: async (req, res) => {
const exportSettings = {
export: {
type: req.body.type,
// this line is just for test purposes
outfile: "./samples/module/" + req.body.filename + "." + "png",
scale: req.body.scale
},
pool: {
minWorkers: 1,
maxWorkers: 1
},
payload: {
svg: req.body.svg
},
customLogic: {
allowCodeExecution: true,
resources: {
css: "here I'd like to inject our variables"
}
}
};
const options = exporter.setOptions(exportSettings);
// Initialize a pool of workers
await exporter.initPool(options);
// Perform an export
exporter.startExport(exportSettings, function(res, err) {
console.log(res);
// The export result is now in res.
// It will be base64 encoded (res.data).
// use fs to write the file
fs.writeFile(exportSettings.export.outfile, res.data, "base64", function(err) {
if (err) {
console.error(err);
}
});
// Kill the pool when we're done with it.
exporter.killPool();
});
// send file
res.status(200);
}
};
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.