I am starting to do my pininos with d3
in Python
(using Jupyter
), with something very simple, but no matter what I do, I have errors.
Go the code:
from IPython.core.display import HTML, Javascript
import json
#Llamo a d3 desde el directorio donde trabajo (bajé el zip y lo instalé en una carpeta)
HTML('''<script src="d3/d3.min.js"></script>''')
Now comes what is supposed to be done: a sign that says "Hello D3!" in orange letters
HTML('''
<style scoped>
.bedazzled {
color: orange;
}
</style>
<div id="d3-div-1"></div>
<script>
var size_data = [10,20,30];
d3.select("#d3-div-1").selectAll('.bedazzled')
.data(size_data)
.enter().append('p')
.attr("class","bedazzled")
.style("font-size", function(d){ return "" + d + "px";})
.text("Hello D3!");
</script>
''')
The error I have is:
Javascript error adding output!
ReferenceError: d3 is not defined
See your browser Javascript console for more details.
I've tried incorporating <script src="d3/d3.min.js"></script>
directly into the long code and into the first call to HTML
(first block of code in this post), using <script src="https://d3js.org/d3.v5.min.js"></script>
and even <script src="https://d3js.org/d3.v5.min"></script>
with exactly the same result.
As you can imagine, I am somewhat frustrated with this matter, so any suggestion I will thank you infinitely.