Add Checkbox to legend of a jqplot line graph

I have been using jqplot to plot the line graph in a site I am working on currently. I love how it give me an option to toggle a line series by clicking on the series name in its legend. However, my problem is, the users don't know that they can click on the series name to toggle the series and keep asking how to do it.

How can I add a checkbox beside the series name together with the clickable series name so that the users know that it can be clicked to show/hide a line from the graph? I have been searching for a while but have not been able to find a solution.

Thanks for any help provided.


I've made a function that adds checkboxes to the legend. It then gives the checkboxes the functionality of showing/hiding trendlines for each series. Then it adds instructions to the bottom of the legend. If anybody else is looking for how to do this, here it is:

function addTrendLineButtons() {
    $legend = $("table.jqplot-table-legend", $chartCanvas);
    $legendRows = $("tbody tr.jqplot-table-legend", $legend);

    $legendRows.each(function(idx) {
        $checkbox = $('<input />', {
            type: 'checkbox',
            checked: $jqPlot.options.series[idx]
        $checkbox.change(function() {
            $jqPlot.options.series[idx] = $(this).is(":checked");

    $instructions = $('<tfoot><tr><td colspan=3>Check box to<br />show trendline</td></tr></tfoot>');
    $instructions.css('text-align', 'right');

Note: you must have already explicitly created the trendline object for each series, not just in the seriesDefaults object.

Need Your Help

Doctrine2.3 and OneToOne cascade persist doesn't seem to work

php mysql orm doctrine2

I have two entites (User and UserPreferences) that I want to map OneToOne unidirectional.

Doctrine/ZF z2d2 tutorial issue

php zend-framework doctrine

I'm sure that I'm missing something, but I've spent all day and I still can't get this skeleton doctrine integration project by Jason Gilmour to work:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.