Hi
Im following the instructions provided in Install from here :
https://github.com/highcharts/node-export-server
Specifically , doing :
git clone
https://github.com/highcharts/node-export-server
npm install
npm link
(
I also edited the environment variables , like so :
export ACCEPT_HIGHCHARTS_LICENSE=yes
export HIGHCHARTS_USE_STYLED=true
export HIGHCHARTS_USE_MAPS=true
export HIGHCHARTS_USE_GANTT=true
export HIGHCHARTS_MOMENT=true
export HIGHCHARTS_VERSION=latest
export HIGHCHARTS_CDN=
https://code.highcharts.com/
)
My server is running and Im getting charts by using CURL in the terminal console , no problem there .
But, when Im trying to use node.js , as in the next example .
// /index.js
// 1. Import filesystem and Highcharts Export Server module
const fs = require("fs");
const chartExporter = require("highcharts-export-server");
// Initialize the exporter
chartExporter.initPool();
// Chart details object specifies chart type and data to plot
// Usually the same object that you use to configure your charts
// in the frontend. This will be used to specify the chart type
// and data to plot. I will use a bar chart, the same data
// specified in one of the official demonstrations in the HC website
let chartOptions = {
chart: {
type: 'bar'
},
title: {
text: 'Historic World Population by Region'
},
subtitle: {
text: 'Source: Our Code World'
},
xAxis: {
categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Population (millions)',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
tooltip: {
valueSuffix: ' millions'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 80,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{
name: 'Year 1800',
data: [107, 31, 635, 203, 2]
}, {
name: 'Year 1900',
data: [133, 156, 947, 408, 6]
}, {
name: 'Year 2000',
data: [814, 841, 3714, 727, 31]
}, {
name: 'Year 2016',
data: [1216, 1001, 4436, 738, 40]
}]
};
// Export chart using these options
chartExporter.export({
type: "png",
options: chartOptions,
// By default the width of the chart images is of 600
// In this case, we want a big image
width: 1200
}, (err, res) => {
// Get the image data (base64)
let imageb64 = res.data;
// Filename of the output. In this case, we will write the image
// to the same directory of the initialization script.
let outputFile = "./output-chart.png";
// Save the image data to a file
fs.writeFileSync(outputFile, imageb64, "base64", function (err) {
if (err) console.log(err);
});
console.log("The chart has been succesfully generated!");
chartExporter.killPool();
});
Im getting the :
Export server not configured error
Im pretty lost . Please, could you help me to make that index.js example work ?
Im using this environment .
- node 16.17.0
- nvm
1.1.10
( I also tried with node 15.14.0 )
Thanks in advance !!.