From 84a469e2e231438cb831fe9fec2d832e2713a9b6 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Mon, 15 Sep 2014 12:42:38 +0900 Subject: [PATCH] Fix class for focused legend --- src/legend.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/legend.js b/src/legend.js index 31f82de..0bdce01 100644 --- a/src/legend.js +++ b/src/legend.js @@ -63,14 +63,11 @@ c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) { c3_chart_internal_fn.toggleFocusLegend = function (id, focus) { var $$ = this; $$.legend.selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemFocused, function (_id) { return id === _id && focus; }) .transition().duration(100) .style('opacity', function (_id) { - var This = $$.d3.select(this); - if (id && _id !== id) { - return focus ? $$.opacityForUnfocusedLegend(This) : $$.opacityForLegend(This); - } else { - return focus ? $$.opacityForLegend(This) : $$.opacityForUnfocusedLegend(This); - } + var opacity = id === _id && focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend; + return opacity($$.d3.select(this)); }); }; c3_chart_internal_fn.revertLegend = function () {