data
最も簡単な方法は、要素自体で使用することだと思います。
<button id="day" class="graph-button" data-state="off">Day</button>
<button id="week" class="graph-button" data-state="off">Week</button>
<!-- graph here -->
<button id="filter1" class="graph-button" data-state="off">Filter 1</button>
<button id="filter2" class="graph-button" data-state="off">Filter 2</button>
次に、次のような jQuery を使用できます。
$(function(){
$('.graph-button').click(function(ev){
ev.preventDefault();
var state = $(this).data('state'),
newState = state == 'off' ? 'on' : 'off',
onButtons = [];
$(this).data('state', newState);
$('.graph-button[data-state="on"]').each(function(i, el){
onButtons.push(this.id);
});
// updateGraphWith(onButtons);
});
});