jqPlot and naming series

Pelle picture Pelle · Jun 5, 2012 · Viewed 13.2k times · Source

I'm trying out jqPlot, but I can't figure out how to set the name of the different series.

Currently, my code looks like this:

$(document).ready(function () {
    $.jqplot('chartdiv', [
        [[201201, 10], [201202, 20], [201203, 30], [201204, 60], [201205, 40]], 
        [[201201, 5], [201202, 10], [201203, 7], [201204, 8], [201205, 11]]
    ], {
        axes: {
            xaxis: {
                label: "Year/month",
                pad: 0
            },
            yaxis: {
                label: "Amount (Kr)"
            }
        },
        legend: {
            show: true
        }
    });
});

It renders the diagram, but the series are named series 1 and series 2. Is there any way that I can control the naming of the series?

Answer

Boro picture Boro · Jun 5, 2012

To have names for series you must set 'label' which is under 'series'. Please see here for documentation.

Example code presenting its use is available here.