Browse Source

Refactor focus legend

pull/104/head
Masayuki Tanaka 11 years ago
parent
commit
43233f9d4e
  1. 25
      c3.js
  2. 4
      c3.min.js

25
c3.js

@ -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);

4
c3.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save