Commit 43233f9d authored by Masayuki Tanaka's avatar Masayuki Tanaka

Refactor focus legend

parent 127b6258
...@@ -3044,24 +3044,23 @@ ...@@ -3044,24 +3044,23 @@
/*-- Draw Legend --*/ /*-- Draw Legend --*/
function toggleFocusLegend(id, focus) {
var legendItem, isTarget, notTarget;
if (!__legend_show) { return; }
legendItem = legend.selectAll('.legend-item');
isTarget = function (d) { return !id || d === id; };
notTarget = function (d) { return !isTarget(d); };
legendItem.filter(notTarget).transition().duration(100).style('opacity', focus ? 0.3 : 1);
legendItem.filter(isTarget).transition().duration(100).style('opacity', focus ? 1 : 0.3);
}
function focusLegend(id) { function focusLegend(id) {
if(!__legend_show) { return; } toggleFocusLegend(id, true);
var legendItem = legend.selectAll('.legend-item'),
isTarget = function (d) { return !id || d === id; },
notTarget = function (d) { return !isTarget(d); };
legendItem.filter(notTarget).transition().duration(100).style('opacity', 0.3);
legendItem.filter(isTarget).transition().duration(100).style('opacity', 1);
} }
function defocusLegend(id) { function defocusLegend(id) {
if(!__legend_show) { return; } toggleFocusLegend(id, false);
var legendItem = legend.selectAll('.legend-item'),
isTarget = function (d) { return !id || d === id; },
notTarget = function (d) { return !isTarget(d); };
legendItem.filter(notTarget).transition().duration(100).style('opacity', 1);
legendItem.filter(isTarget).transition().duration(100).style('opacity', 0.3);
} }
function revertLegend() { function revertLegend() {
if(!__legend_show) { return; } if (!__legend_show) { return; }
legend.selectAll('.legend-item') legend.selectAll('.legend-item')
.transition().duration(100) .transition().duration(100)
.style('opacity', 1); .style('opacity', 1);
......
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