GreenInfo-Network / nyc-crash-mapper-chart-view

Chart view for NYC Crash Mapper that allows for viewing Trends, Comparing, and Ranking of various NYC geographies
http://vis.crashmapper.org
MIT License
2 stars 1 forks source link

Rank view totals all 2X #123

Closed danrademacher closed 4 years ago

danrademacher commented 4 years ago

Christine noticed that we're reporting 2X results on all the Rank cards vs other views. This seems conistent across the board: image

image

I see why: downstream of the SQL we're adding up everything inside an entity to calc the totals:

      entity.totalKilled = d3.sum(entity.values, d => d.totalKilled);
      entity.totalInjured = d3.sum(entity.values, d => d.totalInjured);

When we added Vehicle Type allocations, the SQL includes a set of totals per mode (which add up correctly) and then a second set of allocations per mode per vehicle type, which separately add up to exactly the totals. Hence 2X.

There's probably a better way to solve this by handpicking what we want to sum, but these will be 2X 100% of the time, so we're just gonna divide those by 2.

danrademacher commented 4 years ago

Hmm, actually, it's not 100% of the time, so that fix won't work. Where we have crashes without Vehicle Type a /2 will undercount