AnyChart/AnyChart-NodeJS

Blank Chart

adityathebe opened this issue · 7 comments

var fs = require('fs');
var JSDOM = require('jsdom').JSDOM;
var jsdom = new JSDOM('<body><div id="container"></div></body>', { runScripts: 'dangerously' });
var window = jsdom.window;

var anychart = require('anychart')(window);
var anychartExport = require('anychart-nodejs')(anychart);

const chart = anychart.line([100, 300, 200, 300, 100])
chart.padding('10px')
chart.bounds(0, 0, 800, 600);
chart.container('container');
chart.draw();

anychartExport.exportTo(chart, "png").then((image) => {
    fs.writeFile('anychart.png', image, (fsWriteError) => {
        if (fsWriteError) {
            console.log(fsWriteError);
        } else {
            console.log('Complete');
        }
    });
}, (generationError) => {
    console.log(generationError);
});

This is my code. it renders the axes but no lines are plotted. Anything wrong with the code ?

Apparently it works for pdf but not for jpg and png

@adityathebe
This issue comes from imagemagick version. Please, can you specify which OS you are using?
Please, try to update the imagemagick version up to 7.0.8-11_1, this will solve the problem.

Thanks it worked !

I have 7.0.8-12 and it's still coming up blank

@JacobCooley
Please, try exactly 7.0.8-11_1 version. If it doesn't help, please, share with us your js code.

I don't think there is a way to go back to -11_1 so I think -12 is the only option now

@Shestac92 So I reinstalled imagemagick and now I'm getting some other error. My code used to work, but I reformated my computer and now it's wonky.

(node:29179) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of null
at HTMLUnknownElement.getBBox (/mnt/c/Projects/cryptoBot/node_modules/anychart-nodejs/lib/anychart-node.js:155:29)

It seems in the getBBox function it's looking for a fontfamily and returning null. Any idea why this would be happening?

It is happening on char.draw()
It is happening with many different example charts I've found for anycharts including the one on this repo
It is still happening if I downgrade to 1.3.6

I have reformatted Ubuntu and it's happening on 16.04 and 18.04.

Should I open a new issue?

Here's my code just for sanity check. I'm just trying the example chart just to get it running

var JSDOM = require('jsdom').JSDOM;
var jsdom = new JSDOM('<body><div id="container"></div></body>', {runScripts: 'dangerously'});
var window = jsdom.window;
const anychart = require('anychart')(window)
var chart = anychart.pie([
    ["Chocolate", 5],
    ["Rhubarb compote", 2],
    ["Crêpe Suzette", 2],
    ["American blueberry", 2],
    ["Buttermilk", 1]
]);
chart.title("Top 5 pancake fillings");
// set the container where chart will be drawn
chart.container("container");
//  draw the chart on the page
chart.draw();

EDIT:

I have started using the 1.3.0-dev-preview-4 build for anycharts-nodejs and this error is gone. Only I am getting

Error: Stream yields empty buffer
    at Socket.<anonymous> (/mnt/c/Projects/cryptoBot/node_modules/gm/lib/command.js:57:17)

when saving my image. It works with svg and pdf, but I need either jpg, or png

@JacobCooley
The problem of TypeError: Cannot read property 'split' of null comes with the update of AnyChart 8.4.0
As a temporary solution, you can downgrade your AnyChart npm module down to 8.3.0 version.
Soon we will provide the fix for the AnyChart-NodeJS according to changes in AnyChart 8.4.0 library.
I will notify you when the fix for all reported problems becomes available.