Commits

tomasc committed 1f9ae1e

Fixes issue #524

Comments (0)

Files changed (1)

src/plugins/jqplot.enhancedLegendRenderer.js

             else {
 
                 if (s.canvas._elem.is(':hidden') || !s.show) {
-                    plot.legend._elem.find('tr').eq(sidx).children().addClass('jqplot-series-hidden');
-
+                    // Not sure if there is a better way to check for showSwatches and showLabels === true.
+                    // Test for "undefined" since default values for both showSwatches and showLables is true.
+                    if (typeof plot.options.legend.showSwatches === 'undefined' || plot.options.legend.showSwatches === true) {
+                        plot.legend._elem.find('td').eq(sidx * 2).addClass('jqplot-series-hidden');
+                    }
+                    if (typeof plot.options.legend.showLabels === 'undefined' || plot.options.legend.showLabels === true) {
+                        plot.legend._elem.find('td').eq((sidx * 2) + 1).addClass('jqplot-series-hidden');
+                    }
                 }
                 else {
-                    plot.legend._elem.find('tr').eq(sidx).children().removeClass('jqplot-series-hidden');
+                    if (typeof plot.options.legend.showSwatches === 'undefined' || plot.options.legend.showSwatches === true) {
+                        plot.legend._elem.find('td').eq(sidx * 2).removeClass('jqplot-series-hidden');
+                    }
+                    if (typeof plot.options.legend.showLabels === 'undefined' || plot.options.legend.showLabels === true) {
+                        plot.legend._elem.find('td').eq((sidx * 2) + 1).removeClass('jqplot-series-hidden');
+                    }
                 }
-                
+
             }
-            
+
         };
 
         s.toggleDisplay(ev, doLegendToggle);