simple-chartjs
Version:
Un module ChartJS simple d'utilisation, rapide et puissant !
33 lines (31 loc) • 1.13 kB
JavaScript
const { Chart, Graph } = require('./src/index');
const fs = require('fs');
(async () => {
const chart = new Chart({
sizes: { width: 512, height: 512 },
identity: {
title: { text: "Vente de jouets en fonction des mois (€)", color: "black", font: { size: 16 } },
subtitle: { text: "Données enregistrées par Ae Zio-Tech", color: "gray" },
type: 'doughnut'
},
options: {
backgroundColor: 'white',
labelsColor: 'black',
displayValues: true
}, data: {
labels: ['Red', 'Blue', 'Yellow'],
graphs: [
new Graph({
label: "Colors",
backgroundColor: [
'rgb(255, 99, 132)', 'rgb(54, 162, 235)', 'rgb(255, 205, 86)'
],
borderColor: 'white',
values: [300, 50, 100]
})
]
}
});
const image = await chart.renderToBuffer();
fs.writeFileSync(`${process.cwd()}/chart.png`, image);
})();