开发者

Assign colors to values to show the contrast to color analytics map

开发者 https://www.devze.com 2023-02-18 03:31 出处:网络
I\'m developing google-analytics-like analytics map, but i need to choose the correct colors to color the countries efficiently using some value (the count o users in these coutries) using some co开发

I'm developing google-analytics-like analytics map, but i need to choose the correct colors to color the countries efficiently using some value (the count o users in these coutries) using some co开发者_开发百科lor degrees (such as the green)?

public IList<Color> ColorCountries(IDectionary<string,int> coutryValues)
{
    .........
}


Look at Color Brewer for advice on color scales for maps.

As far as converting your values to colors, first scale your values to 0..1 using whatever way is appropriate to reflect relative importance. The simple approach would be to assign the lightest color to 0 and the darkest color to 1 and interpolate for values in between. However, since color perception is not linear, it's best to use a few more anchor points and do piecewise interpolations.

That is, pick a 6 color scale and assign the lightest to 0, the second lightest to 0.2, the third to 0.4, then 0.6, 0.8, and finally the darkest to 1.0. Interpolate colors for values in between. Now the colors are close enough it doesn't matter which color interpolation method you use (because Color Brewer has done the hard part for you).


Have you thought about just using the Heatmap Google Gadget? Depending on your requirements and the type of app your building, It could save you some time instead of implementing it yourself - http://www.google.com/ig/directory?url=www.google.com/ig/modules/heatmap.xml


A good solution is: Google GeoMap http://code.google.com/apis/visualization/documentation/gallery/geomap.html#Data_Format

0

精彩评论

暂无评论...
验证码 换一张
取 消