Coloring a map using D3.js
<p>I'm new to StackOverflow and I just started using D3.
I need to show the values on a map. I saw <a href="https://stackoverflow.com/questions/37635547/interactive-graph-of-europe-using-d3/37644652?noredirect=1#comment63001871_37644652">this question</a> that is very similar to what I should do.</p>

<p>What I'd like is to color the countries based on the values in the column <code>Date</code> to a CSV and based on selected year by user (radio button).
How can I do that?</p>

<p>I created a gray color scale and have included them in an array, then I created a method <code>chooseColor(value)</code> that returns the correct color based on the value of the country in that year.
I think it is not the most efficient method to do this thing...</p>

<p>Also in my CSV there are not all the countries present in the European Union. For example, I have no data on Russia so I "turned off" some countries putting an <code>if</code> inside the event on <code>mouseover</code>.
But I would also cut part of Russia in the map in order to enlarge the known countries. How can I do also that thing?</p>

<p>I looked at these examples: <em>Choropleth</em> and <em>Threshold Choropleth</em> by Mike Bostock on bl.ocks.org but I have not understand how to color the countries...
(I wanted to put links but I can't post more than 2 links because of my low reputation)</p>

<p><a href="https://plnkr.co/edit/F4byFugwvnflH4S46295?p=preview" rel="nofollow noreferrer">This is my code</a>. </p>

<p>I apologize for my bad English. Thank you all,</p>

<p>Pier</p>

<p><strong>EDIT</strong></p>

<p>I admit I did not understand some things in your code.</p>

<ol>
<li>Why I need events <code>on mouseover</code> and <code>mouseout</code>? And what are <code>hover</code> and <code>rhover</code>? I thought they were events related to <a href="https://stackoverflow.com/questions/37635547/interactive-graph-of-europe-using-d3/37644652?noredirect=1#comment63001871_37644652">this question</a>. But in my case I don't need it, no?</li>
<li>Use <code>array_values</code> or <code>d</code> is the same, right? Does not change if I use <code>d</code> or <code>array_values</code>, right? It is a stupid question but it confused me.</li>
<li><p>I modified the <code>makemap</code> method in this way. I understand correctly how to use your code?</p>

<p>function makemap(error, europe, dessease) {
    dess = dessease.slice();
    counties = topojson.feature(europe, europe.objects.collection);</p>

<pre><code>vector = svg.selectAll("path")
    .data(counties.features)
    .enter()
    .append("path")
    .attr("class", "county")
    .attr("id", function(d) { 
        return "coun" + d.properties.indx;
    })
    .attr("d", path)
    .style("fill", function(array_values) {
        return color(array_values[d.country]);
    });
</code></pre></li>
</ol>

<p>In this case there is an error concerning <code>d</code>, of course. Sorry, I do not know where I'm wrong...</p>