[Chartjs]-Chart.js: Label each dataset

1👍

Finally I have it working as I want thanks to a hint by a user who separated the data in x and y sections

Code on jsFiddle

Full working example here:
jsFiddle

3👍

Note the comments below:

var powerChart = new Chart(powerCanvas,
    {
        type: 'bar',
        data:
        {
            labels: ['Volts', 'Amperes'],
            datasets:
                [
                    {
                        label: 'Value',       // This is actually the label that shows up when you hover over a bar
                        data: [24.78, 14.51]  // NOTE: Number of labels defined above should equal number of values here
                    },
                ]
        },
        options:
        {
        }
    }
);

Edit:

data:
{
    labels: ['Volts', 'Amperes'],
    datasets:
        [
            {
                data: [24.78, 14.51],  // Volts and amperes, respectively
                borderWidth: 1,
                borderColor: ['#0000e0', '#e00000'],  // Border colors for volts and amperes, respectively
    
            },
        ]
},

Leave a comment