Skip to content

Commit

Permalink
Merge pull request #1634 from wxd00d/master
Browse files Browse the repository at this point in the history
fix legend label issue
  • Loading branch information
atmgrifter00 committed Apr 18, 2019
2 parents c3322f5 + 7ff6e94 commit 006ec68
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions source/jquery.flot.legend.js
Expand Up @@ -278,17 +278,22 @@
// Generate a list of legend entries in their final order
function getLegendEntries(series, labelFormatter, sorted) {
var lf = labelFormatter,
legendEntries = series.map(function(s, i) {
return {
label: (lf ? lf(s.label, s) : s.label) || 'Plot ' + (i + 1),
color: s.color,
options: {
lines: s.lines,
points: s.points,
bars: s.bars
legendEntries = series.reduce(function(validEntries, s, i) {
var labelEval = (lf ? lf(s.label, s) : s.label)
if (s.hasOwnProperty("label") ? labelEval : true) {
var entry = {
label: labelEval || 'Plot ' + (i + 1),
color: s.color,
options: {
lines: s.lines,
points: s.points,
bars: s.bars
}
}
};
});
validEntries.push(entry)
}
return validEntries;
}, []);

// Sort the legend using either the default or a custom comparator
if (sorted) {
Expand Down

0 comments on commit 006ec68

Please sign in to comment.