<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: aroub72</title>
    <description>The latest articles on DEV Community by aroub72 (@aroub72).</description>
    <link>https://dev.to/aroub72</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F167188%2Fb29ceae6-ce3d-406e-86f0-0871e867aec8.png</url>
      <title>DEV Community: aroub72</title>
      <link>https://dev.to/aroub72</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aroub72"/>
    <language>en</language>
    <item>
      <title>Creating a network graph using nodes and links(loop) D3</title>
      <dc:creator>aroub72</dc:creator>
      <pubDate>Mon, 13 May 2019 22:19:53 +0000</pubDate>
      <link>https://dev.to/aroub72/creating-a-network-graph-using-nodes-and-links-loop-d3-2hmc</link>
      <guid>https://dev.to/aroub72/creating-a-network-graph-using-nodes-and-links-loop-d3-2hmc</guid>
      <description>&lt;p&gt;I am trying to plot a network graph using nodes and links.&lt;br&gt;
so far I was able to plot the nodes only.&lt;/p&gt;

&lt;p&gt;Nodes graph:&lt;/p&gt;

&lt;p&gt;to draw the links between those nodes I have to iterate through the data to extract the nodes location. Below is a sample of the data:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"links": [
    {"node01": "site05", "node02": "site08", "amount": 10},
    {"node01": "site05", "node02": "site02", "amount": 120},
    {"node01": "site05", "node02": "site03", "amount": 50},
    {"node01": "site05", "node02": "site07", "amount": 80},
    {"node01": "site05", "node02": "site09", "amount": 210},
    {"node01": "site05", "node02": "site10", "amount": 350}]

"nodes": [
    {
      "id": "site09",
      "x": 317.5,
      "y": 282.5
    },
    {
      "id": "site01",
      "x": 112,
      "y": 47
    },
    {
      "id": "site03",
      "x": 69.5,
      "y": 287
    }]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I tried using a for loop but I don't think my approach is correct.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.onload = function(){
var svgCanvas = d3.select("svg") //setting up the canvas
.attr("width", 960) 
.attr("height", 540) 
.attr("class", "svgCanvas");


    d3.json("map.json", function(data) {
        console.log(data);

 svgCanvas.selectAll("circle.nodes")
        .data(data.nodes).enter() 
        .append("circle") 
        .append("svg:circle")
        .attr("cx", function(data){
            return data.x;})
        .attr("cy", function(data){
            return data.y;})
        .attr("r", 10);

var myMap=new Map();
myMap.set(links.data,nodes.data);
for (var [key,value] of myMap){
    console.log(key+'='+value);
}
    })
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
