Fundamentally that looks fine. I suspect the image isn't being updated because the src
isn't changing when you set it the second, third, etc. times. You could either clear it before setting it:
function refresh() {
var graph = document.getElementById('graph');
graph.src = '';
graph.src = 'graph.php';
}
...or give it an ever-changing URL by appending a query string:
function refresh() {
document.getElementById('graph').src = 'graph.php?' + Date.now();
}