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:
JavaScript on Observable is almost — but not entirely — vanilla. This is intentional: by building on the native language of the web, Observable is familiar. And you can use the libraries you know and love, such as D3, Lodash, and Apache Arrow....
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?
There are several ways to create and reference HTML elements in notebooks. I encourage you to have a look at the following guide:
In the Introduction to Code, we looked at cells that return data structures such as numbers, strings, arrays and objects. But what if we want text that includes some dynamic or reactive elements? For example, a sentence that displays a different...
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
jorexbc
December 9, 2022, 11:43am
8
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?