From sheets to sankey chart

I now imported my data thru d3.tsvParse

then import {sankey} and import {sankeyChart}

from there, I am stuck. I’m following tutorials and they ‘const’ but when I used it, I only get SyntaxError.

If anyone can suggest a tutorial to what I envision, it would be a huge help.

Thank you so much

Hi @jorexbc, JavaScript works slightly differently in Observable notebooks. I recommend that you start here:

1 Like

is it possible to source the javascript in html if the two is on the same notebook?

for example, above cell i have HTML, below is the Javascript. can i use ? if so, how can I source the below cell?

If you mean whether you can use <script> tags in Observable notebooks, then the answer is no.

1 Like

… But I think you actually asked how to reference HTML in another JavaScript cell? :sweat_smile:

There are several ways to create and reference HTML elements in notebooks. I encourage you to have a look at the following guide:

1 Like

cause this is the tutorial I am following now, though it didn’t use Observable.

he created a separate html and javascript. what I wanted is to work this out on Observable

I don’t know what tutorial you are following. Did you mean to share a link?

1 Like

oh i figured it out now. i followed the tutorial u gave me on putting html with javascript

can i ask something, on how to include values in a graph and make the bar graph start at the very center. here’s my code. My Division_1 has negative values

const bar1 = bars
.append(‘rect’)
.classed(‘division1’, true)
.style(‘height’, data => data.Division_1 / 10000 +‘px’)
.style(‘width’, ‘50%’)
.style(‘background-color’, ‘red’)
.append(‘text’)
.text(data => data.Division_1)

Can you share a link to your notebook?