mahdi-shojaee commented on issue #19233:
URL: https://github.com/apache/echarts/issues/19233#issuecomment-1774132094
I encountered the same issue. The problem appears to be that the user agent
is not defined in Node.js. I used JSDOM to create a workaround that solved the
issue for me:
Important: You must call require("echarts") after defining the JSDOM props.
I only need server-rendered SVG images, not canvas images. An empty
`createCanvas` is sufficient for my needs. However, if you are using canvas,
you may need to use `node-canvas`.
```javascript
const { JSDOM } = require("jsdom");
const { window } = new JSDOM();
global.window = window;
global.document = window.document;
global.navigator = window.navigator;
global.navigator.userAgent = window.navigator.userAgent;
global.navigator.language = window.navigator.language;
const echarts = require("echarts");
echarts.setPlatformAPI({
createCanvas() {},
});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]