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

Fix legend state when revert called - #782

parent 1333c1e9
......@@ -3732,12 +3732,11 @@
var $$ = this;
targetIds = $$.mapToTargetIds(targetIds);
$$.legend.selectAll('.' + CLASS.legendItem)
.classed(CLASS.legendItemFocused, function (id) {
return targetIds.indexOf(id) >= 0 && focus;
})
.transition().duration(100)
.style('opacity', function (id) {
var opacity = targetIds.indexOf(id) >= 0 && focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
.filter(function (id) { return targetIds.indexOf(id) >= 0; })
.classed(CLASS.legendItemFocused, focus)
.transition().duration(100)
.style('opacity', function () {
var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
return opacity.call($$, $$.d3.select(this));
});
};
......@@ -5592,7 +5591,7 @@
};
c3_chart_internal_fn.selectorLegends = function (ids) {
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) {
......@@ -5691,7 +5690,7 @@
if ($$.hasArcType()) {
$$.unexpandArc(targetIds);
}
$$.revertLegend();
$$.showLegend(targetIds);
$$.focusedTargetIds = [];
$$.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) {
if ($$.hasArcType()) {
$$.unexpandArc(targetIds);
}
$$.revertLegend();
$$.showLegend(targetIds);
$$.focusedTargetIds = [];
$$.defocusedTargetIds = [];
......
......@@ -170,5 +170,5 @@ c3_chart_internal_fn.selectorLegend = function (id) {
};
c3_chart_internal_fn.selectorLegends = function (ids) {
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) {
var $$ = this;
targetIds = $$.mapToTargetIds(targetIds);
$$.legend.selectAll('.' + CLASS.legendItem)
.classed(CLASS.legendItemFocused, function (id) {
return targetIds.indexOf(id) >= 0 && focus;
})
.transition().duration(100)
.style('opacity', function (id) {
var opacity = targetIds.indexOf(id) >= 0 && focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
.filter(function (id) { return targetIds.indexOf(id) >= 0; })
.classed(CLASS.legendItemFocused, focus)
.transition().duration(100)
.style('opacity', function () {
var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
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