Integrating with Node js Application on windows
vibhuti12 opened this issue · 10 comments
I have installed rsvg and imagemgick but still when I run the application it says
Warning! Please install imagemagick utility. (https://www.imagemagick.org/script/binary-releases.php)
Warning! Please install rsvglib utility. (https://github.com/AnyChart/AnyChart-NodeJS)
Error: Stream yields empty buffer
Is there anything else that needs to be done ?
@vibhuti12
The quick guide doesn't provide the full information about the installation process on Windows. I will prepare a detailed guide for you soon.
@vibhuti12
Here is a installation guide for required libraries:
-
Go to imagemagick
-
In section "Windows Binary Release" choose a suitable version of ImageMagick
-
Install it
-
Go to GTK+ bundle
-
Download the bundle (if the zip is unavailable, please, tell us and we will share it with you)
-
To use it, create some empty folder like "c:\gtk", Using either
Windows Explorer's built-in zip file management, or the command-line
unzip.exe, available for instance at
ftp://tug.ctan.org/tex-archive/tools/zip/info-zip/WIN32/unz552xN.exe
unzip this bundle. Avoid Winzip! It is known to behave oddly.
(But you presumably already did extract the files, as you are reading
this file.)
Then add the bin folder to your PATH. Make sure you have no other
versions of GTK+ in PATH. Run:
pkg-config --cflags gtk+-3.0
and verify that it prints out something reasonable. Prepare Pango :
pango-querymodules > c:\gtk\etc\pango\pango.modules
Prepare GDK-Pixbuf :
gdk-pixbuf-query-loaders > c:\gtk\lib\gdk-pixbuf-2.0\2.10.0\loaders.cache
Prepare GTK+-IMModules :
gtk-query-immodules-3.0 > c:\gtk\lib\gtk-3.0\3.0.0\immodules.cache
Run:
gtk3-demo
and verify that it works.
- Go to RSVG lib
- Download the rsvg-convert.exe
- Add path to the exe file in Environment Variables, for example 'C:\export\rsvg-convert'
- After that you can try to launch generationg charts
I hope this will help you!
Did you try running this on windows ? I just want to be sure it works on
windows because the official documentation for rsvg lib says it is not
downloadable for windows. They only accept pull request.
Also, the example provided on the github repository of any charts, did you
try running it on windows ?
The GTK+ bundle link is not available.
@vibhuti12
Yes, it works on Windows. Probably you will need additional fonts. But this depends on existing fonts in your system.
You can download GTK bundle from our CDN.
@Shestac92 I have completed the steps till gtk3-demo and that seems to be working fine. But the error for rsvglib still persists. I have added path to the rsvglib.exe in the Path as well. I am assuming we need to do something to add it to node modules. Did you do something to add it to npm ?
Error:
Warning! Please install rsvglib utility. (https://github.com/AnyChart/AnyChart-NodeJS)
Error: Stream yields empty buffer
at Socket. (C:\Users\vt062640\Desktop\POCGraph\node_modules\gm\lib\command.js:57:17)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
This is the error my program says when I'm running it.
@vibhuti12
It doesn't require any actions with NPM. If the PATH is ok, you should be able to run rsvg-convert in the terminal.
Just execute the following line in the promt command:
rsvg-convert
If it doesn't work, please, make sure that the PATH is ok.
Hi @Shestac92.
When I run my app with the cmd everthing works well.
When windows runs my app from the task scheduler I got the error
Error: Stream yields empty buffer
.
Any ideas why?
@Jucesr
Please, make sure that librsvg, imageMagick and GTK library are installed correctly and all paths are ok.
If everything is ok, please, share with us your JS exporting script. We will use it to reproduce the issue.
@Shestac92
Everthing is installed correctly. I am able to run my app with node myapp.js
.
When I create the windows task I got the error message. It is the same source code. I believe it has something with scheduler not being able to find the path to some library use by GM.
const fs = require('fs')
const path = require('path')
// Require JSDOM Class.
const JSDOM = require('jsdom').JSDOM
// Create instance of JSDOM.
const jsdom = new JSDOM('<body><div id="container"></div></body>', {runScripts: 'dangerously'})
// Get window
const window = jsdom.window
// require anychart and anychart export modules
const anychart = require('anychart')(window)
const anychartExport = require('anychart-nodejs')(anychart)
var chart = anychart.column();
chart.bounds(0, 0, 800, 600);
chart.title('Example')
chart.container('container');
let char_data_set = anychart.data.set([
["Red", 1],
["Blue", 2]
])
let chart_serie = char_data_set.mapAs({x: 0, value: 1})
chart.column(chart_serie)
chart.draw();
anychartExport.exportTo(chart, 'jpeg').then(function(image) {
fs.writeFile(path.join(__dirname, 'example.jpeg'), image, function(fsWriteError) {
if (fsWriteError) {
console.log(fsWriteError);
} else {
console.log('Complete');
}
});
}, function(generationError) {
console.log(generationError);
});