Calculating gems for D3