I was trying to build the basic barchart just to see if I can do it via r2d3.
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://d3js.org/d3-selection-multi.v1.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("body").append("svg")
.attrs({
width: 500,
height: 500
})
svg.append("rect")
.attrs({
width: 317,
height: 100,
x: 200,
y: 62,
fill: "#3BA360"})
svg.append("text")
.text("attrs provided by d3-selection-multi")
.attrs({y: 200,
x: 120})
.style("font-size", 20)
.style("font-family", "monospace")
</script>
</body>
This is the kind of code I want to write. But somehow I think r2d3 doesn't recognize the attrs command. it gives me this error when I try to do that.
Error: undefined is not a constructor (evaluating 'svg.selectAll('rect') .data(data)
.enter().append('rect')
.attrs')
I want to add d3-select-multi library in the code But I don't know how to do it. I couldn't find it in docs. I even Tried.
r2d3(data=c(0.3, 0.6, 0.8, 0.95, 0.40, 0.20)
,script = "d3.js"
,dependencies = "https://d3js.org/d3-selection-multi.v1.min.js")
Please help me out because I think writing multiple attr statement one after another is not how you should write your code ever.
I am still trying to learn d3. Because I want to access the library so I may have some pitfall in the logic. Please be candid in letting me know if I am dead wrong.