D3 js general update pattern