Closed metbosch closed 9 years ago
Which is the example? Reinstall dependences and try again.
The example on the README file:
var Canvas = require('canvas')
, canvas = new Canvas(800, 800)
, ctx = canvas.getContext('2d')
, Chart = require('nchart')
, fs = require('fs');
Chart(ctx).Pie(
[
{
"value": 50
, "color": "#E2EAE9"
}
, {
"value": 100
, "color": "#D4CCC5"
}
, {
"value": 40
, "color": "#949FB1"
}
]
, {
scaleShowValues: true
, scaleFontSize: 24
}
);
canvas.toBuffer(function (err, buf) {
if (err) throw err;
fs.writeFile(__dirname + '/pie.png', buf);
});
Which dependencies? 'node-canvas'?
Yes, the canvas
module is required.
$ npm install canvas
Looks like to get it working instead of
var Chart = require('nchart');
should be
var Chart = new (require('nchart'))(ctx);
and the following part
Chart(ctx).Pie(
should be
Chart.Pie(
Good catch! That's it. I should update these examples.
Fxed in v1.0.1.
When I try to run the example code on my installation I get the following error:
The code was executed in the interactive console and the error appears on the call 'Chart(ctx)'.