d3 scale issue

20 views
Skip to first unread message

Er Arijit

unread,
Jul 21, 2016, 8:39:50 AM7/21/16
to d3-js
I tried to plot some data using d3 but no output is showing 

my code 

<html>
<head>
<title>D3 example</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>


<body>
<script>


var data =[1,2,3,4,5];




var widthscale = d3.scale.linear()
 
.domain([1, 5])
 
.range([0, 200]);




var svg = d3.select("body").append("svg")
 
.attr("width", 250)
 
.attr("height", 250);




 
svg
.selectAll("rect")
   
.data(data)
 
.enter().append("rect")
 
.attr("x", function(d){return d*100;})
 
.attr("y",50)
 
.attr("width", 20)
 
.attr("height", 20);


</script>
</body>
</html>




I am getting erros due to 

var widthscale = d3.scale.linear()
 
.domain([1, 5])
 
.range([0, 200]);

So can any one suggest me a solution. 

Reply all
Reply to author
Forward
0 new messages