jqPlot - Horizontal legend

user1032531 picture user1032531 · Sep 10, 2012 · Viewed 9.6k times · Source

jqPlot has the ability to create a legend for a chart. The examples show only vertical legends. I would like to make a horizontal legend. For instance, I want:

X-Label1 X-Label2 X-Label3

And don't want:

X-Label1
X-Label2
X-Label3

Thanks

Answer

GayashanNA picture GayashanNA · Dec 11, 2012

This is very easy to achieve using the EnhancedLegendRenderer plugin. Just include the plugin and use options similar to this.

legend:{
    renderer: $.jqplot.EnhancedLegendRenderer,
    show: true,
    rendererOptions: {
        numberRows: 1
    }
}

You just have to set the numberRows to 1, so the legend will be rendered with only 1 row.