<a href="#" class="button" onclick="changeId('graphID1')">График 1</a>
<a href="#" class="button" onclick="changeId('graphID2')">График 2</a>
<div id="graphID1" style="width: 100%"></div>
<script>
function changeId(newId) {
document.querySelector('div').id = newId;
}
</script>