How to use chartjs-node-canvas - 3 common examples

To help you get started, we’ve selected a few chartjs-node-canvas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blake-regalia / graphy.js / perf / compare.js View on Github external
boxWidth: 12,
				},
			},
			scales: {
				yAxes: [{
					ticks: {
						beginAtZero: true,
					},
				}],
			},
		},
	};

	let pr_img = `chart/${si_chart}.png`;

	const y_service = new CanvasRenderService(x_width, x_height, (ChartJS) => {
		ChartJS.plugins.register({
			beforeDraw(y_chart) {
				let y_ctx = y_chart.ctx;
				y_ctx.fillStyle = '#ffffff';
				y_ctx.fillRect(0, 0, x_width, x_height);
			},
		});
	});

	let ds_test = y_service.renderToStream(gc_chart)
		.pipe(fs.createWriteStream(`./${pr_img}`));

	await once(ds_test, 'finish');

	return pr_img;
}
github funo-bot / Funo / src / ImageHandler / methods / graphMembers.js View on Github external
(async () => {
    const canvasRenderService = new CanvasRenderService(width, height, chartCallback);
    const image = await canvasRenderService.renderToBuffer(configuration);
    const dataUrl = await canvasRenderService.renderToDataURL(configuration);
    const stream = canvasRenderService.renderToStream(configuration);
    cb({ "Status": true, "Message": "Graph Generated", "Buffer": await image })
  })();
}
github funo-bot / Funo / src / ImageHandler / methods / graphMemberCount.js View on Github external
(async () => {
    const canvasRenderService = new CanvasRenderService(width, height, chartCallback);
    const image = await canvasRenderService.renderToBuffer(configuration);
    const dataUrl = await canvasRenderService.renderToDataURL(configuration);
    const stream = canvasRenderService.renderToStream(configuration);
    var Jimp = require("jimp")

    Jimp.read(image).then(async imageone => {
      Jimp.read("https://i.imgur.com/Ow3ZyN5.png").then(async imagetwo => {
        await imagetwo.composite(imageone, 7, 43)
        cb({ "Status": true, "Message": "Graph Generated", "Buffer": await imagetwo.getBufferAsync(Jimp.AUTO) })
      })
    })
  })();
}

chartjs-node-canvas

A node renderer for Chart.js using canvas.

MIT
Latest version published 3 years ago

Package Health Score

44 / 100
Full package analysis

Popular chartjs-node-canvas functions