highcharts / highcharts/node-export-server

annotations not working with node export server

Open
#591 9 comments 0 reactions 0 assignees View on GitHub
bug only json
Dominant language
JavaScript
Stars
369
Forks
266
PR merge metrics
No merged PRs in 30d

Description

"I am using the Highcharts Node Export Server, and my chart contains annotations. However, when I export the chart using the Node module or the Highcharts server arguments , the exported image does not include any annotations.

I need a solution to fix this issue, please."

#### Expected behaviour

Chart image with annotations

#### Actual behaviour

Chart image without annotations

![options_phantom]
(https://github.com/user-attachments/assets/b8f833bf-f115-4ad2-90e1-cfdf6f6ac315)

#### Reproduction steps

**### here is js code used**

```
import { writeFileSync } from 'fs';
import exporter from '../../lib/index.js';
// Export settings with the old options structure (PhantomJS)
// Will be mapped appropriately to the new structure with the mapToNewConfig utility
const exportSettings = {
type: 'png',
constr: 'chart',
outfile: './samples/module/options_phantom.jpeg',
logLevel: 4,
scale: 1,
workers: 1,
options: {
chart: {
type: "column",
backgroundColor: "#FFFFFF",
},
title: {
text: "Monthly Revenue",
},
xAxis: {
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
title: {
text: "Months",
},
},
yAxis: {
min: 0,
title: {
text: "Revenue (USD)",
},
},
series: [
{
name: "Revenue",
data: [3000, 4000, 3200, 5000, 4500, 6000, 7000, 6800, 6200, 7500, 8200, 9000],
},
],
annotations: [
{
labels: [
{
point: {
xAxis: 0,
yAxis: 0,
x: 3, // April
y: 5000,
},
text: "Highest Revenue of the Quarter",
},
{
point: {
xAxis: 0,
yAxis: 0,
x: 11, // December
y: 9000,
},
text: "Year-End Peak",
},
],
},
],
}
};
const start = async () => {
try {
// Map to fit the new options structure
const mappedOptions = exporter.mapToNewConfig(exportSettings);
// Set the new options
const options = exporter.setOptions(mappedOptions);
// Init a pool for one export
await exporter.initExport(options);
// Perform an export
await exporter.startExport(options, async (error, info) => {
// Exit process and display error
if (error) {
throw error;
}
const { outfile, type } = info.options.export;
// Save the base64 from a buffer to a correct image file
writeFileSync(
outfile,
type !== 'svg' ? Buffer.from(info.result, 'base64') : info.result
);
// Kill the pool
await exporter.killPool();
});
} catch (error) {
// Log the error with stack
exporter.logWithStack(1, error);
// Gracefully shut down the process
await exporter.shutdownCleanUp(1);
}
};
start();
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.