Commit 74bd5369 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix legend state when revert called - #782

parent 1333c1e9
...@@ -3732,12 +3732,11 @@ ...@@ -3732,12 +3732,11 @@
var $$ = this; var $$ = this;
targetIds = $$.mapToTargetIds(targetIds); targetIds = $$.mapToTargetIds(targetIds);
$$.legend.selectAll('.' + CLASS.legendItem) $$.legend.selectAll('.' + CLASS.legendItem)
.classed(CLASS.legendItemFocused, function (id) { .filter(function (id) { return targetIds.indexOf(id) >= 0; })
return targetIds.indexOf(id) >= 0 && focus; .classed(CLASS.legendItemFocused, focus)
}) .transition().duration(100)
.transition().duration(100) .style('opacity', function () {
.style('opacity', function (id) { var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
var opacity = targetIds.indexOf(id) >= 0 && focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
return opacity.call($$, $$.d3.select(this)); return opacity.call($$, $$.d3.select(this));
}); });
}; };
...@@ -5592,7 +5591,7 @@ ...@@ -5592,7 +5591,7 @@
}; };
c3_chart_internal_fn.selectorLegends = function (ids) { c3_chart_internal_fn.selectorLegends = function (ids) {
var $$ = this; var $$ = this;
return ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null; return ids && ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null;
}; };
var isValue = c3_chart_internal_fn.isValue = function (v) { var isValue = c3_chart_internal_fn.isValue = function (v) {
...@@ -5691,7 +5690,7 @@ ...@@ -5691,7 +5690,7 @@
if ($$.hasArcType()) { if ($$.hasArcType()) {
$$.unexpandArc(targetIds); $$.unexpandArc(targetIds);
} }
$$.revertLegend(); $$.showLegend(targetIds);
$$.focusedTargetIds = []; $$.focusedTargetIds = [];
$$.defocusedTargetIds = []; $$.defocusedTargetIds = [];
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -47,7 +47,7 @@ c3_chart_fn.revert = function (targetIds) { ...@@ -47,7 +47,7 @@ c3_chart_fn.revert = function (targetIds) {
if ($$.hasArcType()) { if ($$.hasArcType()) {
$$.unexpandArc(targetIds); $$.unexpandArc(targetIds);
} }
$$.revertLegend(); $$.showLegend(targetIds);
$$.focusedTargetIds = []; $$.focusedTargetIds = [];
$$.defocusedTargetIds = []; $$.defocusedTargetIds = [];
......
...@@ -170,5 +170,5 @@ c3_chart_internal_fn.selectorLegend = function (id) { ...@@ -170,5 +170,5 @@ c3_chart_internal_fn.selectorLegend = function (id) {
}; };
c3_chart_internal_fn.selectorLegends = function (ids) { c3_chart_internal_fn.selectorLegends = function (ids) {
var $$ = this; var $$ = this;
return ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null; return ids && ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null;
}; };
...@@ -66,12 +66,11 @@ c3_chart_internal_fn.toggleFocusLegend = function (targetIds, focus) { ...@@ -66,12 +66,11 @@ c3_chart_internal_fn.toggleFocusLegend = function (targetIds, focus) {
var $$ = this; var $$ = this;
targetIds = $$.mapToTargetIds(targetIds); targetIds = $$.mapToTargetIds(targetIds);
$$.legend.selectAll('.' + CLASS.legendItem) $$.legend.selectAll('.' + CLASS.legendItem)
.classed(CLASS.legendItemFocused, function (id) { .filter(function (id) { return targetIds.indexOf(id) >= 0; })
return targetIds.indexOf(id) >= 0 && focus; .classed(CLASS.legendItemFocused, focus)
}) .transition().duration(100)
.transition().duration(100) .style('opacity', function () {
.style('opacity', function (id) { var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
var opacity = targetIds.indexOf(id) >= 0 && focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
return opacity.call($$, $$.d3.select(this)); return opacity.call($$, $$.d3.select(this));
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment