Rewrite in D3
Added legend