I have created a node JS app with the following code:
Code: Select all
// Initialize the exporter
chartExporter.initPool();
// Chart details object specifies chart type and data to plot
const chartDetails = {
type: "png",
options: {
chart: {
type: "pie"
},
title: {
text: "Heading of Chart"
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
format: "<b>{point.name}</b>: {point.y}"
}
}
},
series: [
{
data: [
{
name: "a",
y: 100
},
{
name: "b",
y: 20
},
{
name: "c",
y: 50
}
]
}
]
}
};
chartExporter.export(chartDetails, (err, res) => {
// Get the image data (base64)
let imageb64 = res.data;
// Filename of the output
let outputFile = "pie2.png";
var fileName = '';
var resolvedBase = path.resolve(staticIMAGEBasePath);
//fileName = path.join(resolvedBase, guid + '.svg');
fileName = path.join(resolvedBase, outputFile);
// Save the image to file
fs.writeFileSync(fileName, imageb64, "base64", function (err) {
if (err) console.log(err);
});
chartExporter.killPool();
});
However, it creates an image with "Export server not configured".
I have installed the export server using
Code: Select all
npm install highcharts-export-server
Code: Select all
node node_modules\highcharts-export-server\build.js