smoningi / SF-Environment-Benchmark

Set of applications to visualize SF building energy consumption and greenhouse gas emissions.
6 stars 11 forks source link

use d3 color scale instead of switch #8

Closed thfield closed 8 years ago

thfield commented 8 years ago

@geoffnet, since you want to get more familiar with D3 this is a good place to implement a common D3 pattern and clean up the code a little.

In main.js there is a switch statement to decide the background color of the switchbox element, but we should be able to use the color variable, which is a d3 quantize scale.

I believe it would be a matter of changing the switch to something like scorebox.style.backgroundColor = color(escore) with an if to set the text color accordingly

geoffnet commented 8 years ago

Makes sense. I'll take a stab at it.

thfield commented 8 years ago

lmk if you have questions, I didn't mean to sound brusk and just pass this off but it seemed like a good use of d3

geoffnet commented 8 years ago

Best way to learn -- found and squashed a bug in the process. Thanks, Tyler.