highcharts / highcharts/node-export-server

Inject css variables using nodejs module

Aperta
#522 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
JavaScript
Stelle
369
Fork
266
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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);
}
};
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia dal punto di ingresso del modulo Express mostrato e dall’opzione exportSettings.customLogic.resources.css. Leggi la documentazione o l’implementazione della gestione delle risorse del server di esportazione per determinare se è possibile iniettare testo CSS nelle esportazioni SVG. Il lavoro è completato quando le variabili CSS vengono applicate durante la generazione dell’immagine senza dipendere da risorse esterne.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
css, express, javascript, node.js
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.