simple-chartjs

1.0.3 • Public • Published
Un module simple d'utilisation, rapide et puissant !

Exemples

Exemple de graphique linéaire
const { Chart, Graph } = require('../src/index');
(async () => {
    const chart = new Chart({
        sizes: { width: 400, height: 400 },
        identity: {
            title: {
                text: "Titre du graphique",
                color: 'black',
                font: { size: 16 }
            }, subtitle: {
                text: "Sous-titre du graphique",
                color: 'gray'
            }
        }, options: {
            backgroundColor: 'white',
            labelsColor: 'black'
        }, data: {
            labels: ['Premier', 'Deuxième', 'Troisième'],
            graphs: [
                new Graph({
                    label: 'Titre de la courbe',
                    type: 'line',
                    borderColor: 'rgb(54, 162, 235)',
                    values: [300, 50, 100],
                    backgroundColor: 'rgb(54, 162, 235)'
                })
            ]
        }
    });
    const image = await chart.renderToBuffer();
})();
Voir le résultat
Exemple de graphique donnut
const { Chart, Graph } = require('../src/index');
(async () => {
    const chart = new Chart({
        sizes: { width: 400, height: 400 },
        identity: {
            title: {
                text: "Titre du graphique",
                color: 'black',
                font: { size: 16 }
            }, subtitle: {
                text: "Sous-titre du graphique",
                color: 'gray'
            }, type: 'doughnut'
        }, options: {
            backgroundColor: 'white',
            labelsColor: 'black',
            displayValues: true
        }, data: {
            labels: ['Rouge', 'Bleu', 'Jaune'],
            graphs: [
                new Graph({
                    borderColor: 'white',
                    values: [300, 50, 100],
                    backgroundColor: [
                        'rgb(255, 99, 132)',
                        'rgb(54, 162, 235)',
                        'rgb(255, 205, 86)'
                    ]
                })
            ]
        }
    });
    const image = await chart.renderToBuffer();
})();
Voir le résultat

Package Sidebar

Install

npm i simple-chartjs

Weekly Downloads

4

Version

1.0.3

License

ISC

Unpacked Size

85.4 kB

Total Files

13

Last publish

Collaborators

  • aeziotech