Skip to content

Commit 2098f83

Browse files
authored
Issue-177 - fix legend hidden class allocation
Issue-177 - added chart-series class reference to legend elements, removed index based location of series legend elements
1 parent 6aef5db commit 2098f83

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/plugins/jqplot.enhancedLegendRenderer.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@
167167
td2 = $(document.createElement('td'));
168168
td2.addClass('jqplot-table-legend jqplot-table-legend-label');
169169
td2.css('paddingTop', rs);
170-
170+
//Issue-177 | added jqplot series class reference jqplot-table-legend-series-[sidx] - used to locate legend td element for series.
171+
td2.addClass("jqplot-table-legend-series-" + idx);
172+
171173
// td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
172174
// '<div><div class="jqplot-table-legend-swatch" style="background-color:'+color+';border-color:'+color+';"></div>'+
173175
// '</div></td>');
@@ -274,23 +276,12 @@
274276
}
275277
var s = plot.series[sidx];
276278

279+
//Issue-177 | removed element index based location of series legend element and replaced with explicit class reference jqplot-table-legend-series-[sidx]
277280
if (s.canvas._elem.is(':hidden') || !s.show) {
278-
// Not sure if there is a better way to check for showSwatches and showLabels === true.
279-
// Test for "undefined" since default values for both showSwatches and showLables is true.
280-
if (typeof plot.options.legend.showSwatches === 'undefined' || plot.options.legend.showSwatches === true) {
281-
plot.legend._elem.find('td').eq(sidx1 * 2).addClass('jqplot-series-hidden');
282-
}
283-
if (typeof plot.options.legend.showLabels === 'undefined' || plot.options.legend.showLabels === true) {
284-
plot.legend._elem.find('td').eq((sidx1 * 2) + 1).addClass('jqplot-series-hidden');
285-
}
281+
plot.legend._elem.find('td.jqplot-table-legend-series-' + sidx).addClass('jqplot-series-hidden');
286282
}
287283
else {
288-
if (typeof plot.options.legend.showSwatches === 'undefined' || plot.options.legend.showSwatches === true) {
289-
plot.legend._elem.find('td').eq(sidx1 * 2).removeClass('jqplot-series-hidden');
290-
}
291-
if (typeof plot.options.legend.showLabels === 'undefined' || plot.options.legend.showLabels === true) {
292-
plot.legend._elem.find('td').eq((sidx1 * 2) + 1).removeClass('jqplot-series-hidden');
293-
}
284+
plot.legend._elem.find('td.jqplot-table-legend-series-' + sidx).removeClass('jqplot-series-hidden');
294285
}
295286

296287
}

0 commit comments

Comments
 (0)