Adding multiple class name to an element D3
<p>I am working on a D3 Scatter Plot having data from different regions - here regions are Continent names like Europe, Asia etc. I want to associate the region with a class name so that I can perform common activities for one region. </p>

<p>Below is my code to add multiple classes together to an element:</p>

<pre><code>var dot = svg.append("g")
                .attr("class", "dots")
                .selectAll(".dot")
                .data(interpolateData(1900))
                .enter().append("circle")
                .attr("class", "dot " + function(d) { return d.Region; });
</code></pre>

<p>When I write the following code to check what classes are associated with the current object.</p>

<pre><code>alert(this.getAttribute('class'));
</code></pre>

<p>I got this output:</p>

<p><a href="https://i.stack.imgur.com/ZVyyw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZVyyw.png" alt="enter image description here"></a></p>

<p>So I can see that it is adding "dot" class successfully but not able to add Region dynamically.</p>

<p>TIA</p>