Commit 633ed3bf authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix opacity for hidden legend item

parent b9342ab1
...@@ -337,7 +337,7 @@ ...@@ -337,7 +337,7 @@
}; };
var isLegendRight = __legend_position === 'right'; var isLegendRight = __legend_position === 'right';
var legendStep = 0, legendItemWidth = 0, legendItemHeight = 0; var legendStep = 0, legendItemWidth = 0, legendItemHeight = 0, legendOpacityForHidden = 0.15;
/*-- Define Functions --*/ /*-- Define Functions --*/
...@@ -3744,14 +3744,17 @@ ...@@ -3744,14 +3744,17 @@
/*-- Draw Legend --*/ /*-- Draw Legend --*/
function opacityForLegend(id) { function opacityForLegend(id) {
return d3.select(selectorLegend(id)).classed(CLASS.legendItemHidden) ? 0.5 : 1; return d3.select(selectorLegend(id)).classed(CLASS.legendItemHidden) ? legendOpacityForHidden : 1;
}
function opacityForUnfocusedLegend(id) {
return d3.select(selectorLegend(id)).classed(CLASS.legendItemHidden) ? legendOpacityForHidden : 0.3;
} }
function toggleFocusLegend(id, focus) { function toggleFocusLegend(id, focus) {
var legendItem = legend.selectAll('.' + CLASS.legendItem), var legendItem = legend.selectAll('.' + CLASS.legendItem),
isTarget = function (d) { return (!id || d === id); }, isTarget = function (d) { return (!id || d === id); },
notTarget = function (d) { return !isTarget(d); }; notTarget = function (d) { return !isTarget(d); };
legendItem.filter(notTarget).transition().duration(100).style('opacity', focus ? 0.3 : opacityForLegend); legendItem.filter(notTarget).transition().duration(100).style('opacity', focus ? opacityForUnfocusedLegend : opacityForLegend);
legendItem.filter(isTarget).transition().duration(100).style('opacity', focus ? opacityForLegend : 0.3); legendItem.filter(isTarget).transition().duration(100).style('opacity', focus ? opacityForLegend : opacityForUnfocusedLegend);
} }
function focusLegend(id) { function focusLegend(id) {
toggleFocusLegend(id, true); toggleFocusLegend(id, true);
...@@ -4044,7 +4047,7 @@ ...@@ -4044,7 +4047,7 @@
legend.selectAll(selectorLegends(targetIds)) legend.selectAll(selectorLegends(targetIds))
.classed(CLASS.legendItemHidden, true) .classed(CLASS.legendItemHidden, true)
.transition() .transition()
.style('opacity', 0.5); .style('opacity', legendOpacityForHidden);
} }
redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withTransitionForHorizontalAxis: false}); redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withTransitionForHorizontalAxis: false});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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