Both D3 and Observablehqcom are excellent product. Thanks to the authors!
I want to learn D3.
However a lot of D3 official examples are coding in Observablehq.com.
I don`t want to learn Observable, because I mainly use D3 for off-line academic Chart.
Could Mike Bostock give every D3 official examples a common Javascribe environment code?
Or ? Forcing everyone who want to learn D3 must learn how to use Observablehq.com first?
Hi there TigerZhao007,
Welcome to Observable. I hope that you find this platform useful and the community welcoming.
I empathize with the difficulties of encountering links to Observable notebooks via blocks.org examples. I too was surprised to find links to āstandardā blocks have started to point to Observable, such as with the Sankey, radial stacked bar, and Diamonds IIā¦ among others. I also often wish to use visualizations offline, in locally-hosted papers. As shown by my activity on this forum, Iāve encountered a lot of questions and challenges trying to move between Observable and standard / traditional JS.
As a newcomer to JS in general myself, I would encourage you to stick with Observable for a time. Observableās helped me to understand how pieces of a script play togetherā¦ to be able to see more clearly which elements can be separated out, which must stay together, etc. Hopefully youāll also find that your knowledge of D3 will improve more rapidly by tinkering with it in Observable.
Otherwise, except for Mikeās blocks, few (if any) of the bl.ocks.org examples link to Observable. I agree it would be cool of we could also see the original bl.ocks.org examples where they now link to Observable (and maybe Mike can figure out a way to do this), but barring that, thereās still an expansive world of examples onlineā¦ so hopefully you donāt feel forced into a learning approach that doesnāt fit you.
Sorry if this isnāt much help. The Observable community has been really caring and helpful toward me. I encourage you to ask questions where you do have difficulties. And again - welcome!
Dear aaronkyle, Thanks so much for your reply.
You not only answered my question, but also expressed exactly what i want to say. Thanks again.
And yes, I am a newcomer to JS and my major is not CS or Programmer. So it is a little bit difficult to learn D3 and JS. And it turned out a lot D3 examples are linked to Observable. I was like āWhat the f***ā, confused and helpless.
Thanks for your encouragement, I would stick with Observable for a while and try to understand.
I think youāll learn d3 faster using observable, than other online sandbox environments out there
Itās important to realize that Observable is just javascript. Itās not magic, it just adds reactivity to the language.
I donāt think the canonical examples of D3 figures here really exploit Observable-specific features very heavily. But if you really want vanilla-only D3 instruction, thereās a lot out there. Iād recommend Interactive Data Visualization for the Web by Scott Murray, which has a free online edition.
Hello!
As weāve been creating more D3 documentation and examples on observable (and more is comingā¦), I agree we have to be careful about this issue.
First, note that there is a lot of fantastic learning material out there ā in very different forms (blocks, codepens, independent web pages, etc) ā and a lot of them are linked from D3ās gallery and READMEs. But many authors are moving to Observable and creating exciting new stuff (testimony to how useful and productive the system is), so itās unavoidable that more links will be made with these new examples.
Strictly speaking about the series of examples at https://observablehq.com/@d3 that are linked to from the API documentation:
Ideally, one should be able to read them statically (as if in a book), and copy-paste to a web page or a node script without needing too many adaptations.
In general, weāre trying to avoid Observableās facilities, and prefer e.g. d3.create("svg").attr("width", width).attr("height", height).node()
over DOM.svg(width, height)
so that the code works almost immediately in the browser or in node.
However, sometimes it would add too much complexity not to use them:
ā viewof t = slider()
might help people mess around with the values more than an editable cell with t = 300
. The primary goal is to help people understand what the documented functions do.
ā asynchronous loading of data in its own cell is much simpler & easier to understand than promises and callbacks
ā using the built-in width
to make the notebook responsive
ā etc.
A separate issue is that the code in observable is fragmented into independent cells, which makes it difficult to copy / paste all in one swoop. Again, it helps to understand when youāre reading it, but gives you more work when you just want to reuse it. I have no good solution for this at the moment.
Maybe a tool, or a tutorial, could help with the necessary changes ā things like replacing require by <script>
, using async/await explicitely, etc.
Finally, I agree that it would be great to also have more D3 examples that could be directly usable offline (in node). I certainly learned a lot with d3-geoās test and bin scripts. But this type of link āTry d3-zoom in your browser.ā? ā Iām not sure anyone could learn anything from that.
This sounds like a cool idea! A tool would be awesome, but Iām not sure how it could be done. On the tutorial side, maybe something like the āinverseā of this notebook:
These two forum posts of mine come to mind ā maybe theyād be useful as case studies.
I also just found this notebook, which goes through the code of a D3 bar chart in 3 different styles (as a single Observable cell, as multiple Observable cells, and as it would be embedded in a standalone HTML page):
(I donāt like the āChart as a set of expressionsā version there though since it doesnāt really play well with Observableās reactivity.)
Yes, this is a good insight.
Thereās friction here in both directions. I often want to take an existing observable cell with a big bunch of code in it and split a few variables out into separate cells to play with them, and I also often want to take a bunch of separate cells and put them into one cell because they are not generally relevant to the whole notebook or I want to duplicate an output cell and tweak the parameters independently in the two copies. Itās not exactly hard to do this manually, but itās also not instant. I also donāt know exactly how it could/should be improved.
(These actions require more or less the same code transformations as porting external javascript code to notebooks / porting notebooks to plain javascript.)
observablehq is sure a genius project ā¦ but I was 100% fully satisfied with plain javascript. I can not do anything with observable. I am here to do and not to observe. D3.JS is so great, a fantastic tool. But whatever observable is usefool for some few, I am sure most of serious coders will blow a fuzz with this non sense. OR OR OR, simply add a raw script to be āobservableā with not change, I mean the raw one, the source ready to be tested in plain javascript, raw and immediately useable. That would be great : a great step toward the glory useful past.
THANKS !
I can not do anything with observable [ā¦] I am sure most of serious coders will blow a fuzz with this non sense [ā¦] step toward the glory useful past
I canāt figure out what you are trying to say.
If you want to write javascript code down in a text file and run it in your browser, nobody is stopping youā¦
2 posts were merged into an existing topic: Copyright and software licenses
Wellā¦ I agree with the original poster (this frustration lead me to this thread as the first search result) so to put it other words what is being said through an exampleā¦ currently the new tutorial of d3.js begins with a feature unique to observable javascriptā¦
All I was looking from a āgetting startedā tutorial was how to create a d3 element in a web pageā¦ Which is specifically not coveredā¦
This seems not to be the caseā¦ import {chart as temperatureHistogram} with {temperatures as data, height} from ā@d3/histogramā
So anyway, I wrote this just to let you know that probably many people who already know what
interactive data visualization means and have already developed websites will experience the kind of feelings expressed in this thread.
Iāve created an account just to express my frustration over this.
Why can we not simply download vanilla code examples without any āObservablenessā in them?
Is that really too much to ask?
Observable notebooks are like spreadsheets, where cells run automatically whenever you edit or values change. Thatās not how conventional (imperative) programming languages work, so sadly you canāt simply copy-paste a whole notebook into a vanilla JavaScript application.
We recognize that this is a change and a disruption: a new thing to learn. And we need to do a better job of helping you learn Observable (and explaining why you should bother).
Yet despite our shortcomings, we fundamentally believe that Observable is a better way to code: easier to understand, easier to tinker, easier to adapt and reuse, easier to collaborate and share.
You can download the vanilla JavaScript for any notebook by clicking Download Code in the notebook menu. (See Downloading and Embedding for details.) This code can be self-hosted so you can run whatever you create in Observable anywhere. And our embeds are much more powerful than iframes, allowing deep integration (e.g., with React). Weāre making this easier; see Jeremyās Handy Embed Code Generator for a start. This transpiled code isnāt intended to be edited directly; we recommend you edit on Observable.
As to the broader question of why go to the trouble to introduce a new language, a live editor, and a collaboration platform to accompany it: our goal is to help people help each other. We want to foster collaboration and creativity. For this to succeed, code must become more approachable, which means breaking a few eggs. Thereās an incredible community of people on Observable that can help you (through comments and suggestions) and a wealth of techniques to learn from and reuse (through forks and imports). With the Observable community, the D3 examples can be so much better than what I could ever make on my own.
Thanks for taking the time to provide a detailed reply.
This is why I still think this is an issue: choice
It may really be the case that Observable is the next big thing but, as it stands, I am not given any alternative when I come here from the d3 site, for example, apart from going elsewhere. I already tried using the Download Code feature, however, Observable is still within the code that you get. In order to do what I needed to, which was present a very quick demo of what we could do with d3 using our data, I had to spend much longer on it than I originally thought I would need.
Now, you could probably argue that I could have done my demo using Observable and it would be easier, quicker, and more malleable, but as the OP says in the title of the post here, what if I donāt want to right now? Instead of using Observable as something I depend on for delivering my code, what if instead I wanted to sandbox some ideas and then move to using straight JS code? There are a multitude of reasons why people would not want to change up everything theyāre doing today.
In my opinion not having an option to export an Observable notebook as regular code is severely limiting, and think I might have actually used it if it had this functionality. Without it, Iāve got a hell of a lot of buy in. For my demo, I ended up hacking around the d3 code from here to get what I wanted to work, which led to frustration and a desire for things to go back to how they used to be with the d3 example code.
Thanks,
Muhmud.
I greatly admire the Observable team and all the amazing work being done here, but I couldnāt agree more with @muhmud! Like many others, I found myself on this thread as a result of a lot of frustration.
I agree that Observable may be the way to go, and I do agree with a lot of the advantages being presented - but the problem is (and I think I see many others expressing similar views): why, oh why, canāt we have the copies of the āregularā code that we are used to, in addition to the observable versions? I think that being able to compare old with new would drastically ease the learning process for so many people. Of course after Observable becomes more mainstream and understood, the old code can be removed. As it stands right now, I feel like I would have to suspend a lot of my work in order to fully dive into and embrace Observable - unfortunately that is just not an option for many programmers like myself.
If there is a reason why the Observable team does not want to provide āregularā code with Observable code, it would be great to know what the reason is - part of the frustration comes from feeling that this is such a small ask, and yet weāre not getting it.
Thanks again for the awesome work.
Maintaining two parallel sets of examples, one Observable and one vanilla, is no small task. The D3 examples represent thousands of hours of work (418 notebooks on Observable and counting), and over the last few years weāve committed to Observable because we think the examples will be better the communityās help and itās a better way to learn D3.
There are plenty of vanilla D3 examples available on the web, such as the D3 Graph Gallery, and resources for using D3 with other frameworks, such as Amelia Wattenbergerās Fullstack D3 and Data Visualization. But these arenāt maintained by the D3 team as we are focusing our efforts on supporting the community at Observable.
Thank you very much, I appreciate the explanation.
But is it possible to leave the bl.ocks.org vanilla examples up after they are ported to Observable (with the caveat that they are no longer maintained and may even be slightly different from the new sample)? While it is true that there are many other D3 examples on the web, the bl.ocks.org examples that have been removed are the closest thing to the new Observable samples that we can use as a reference for understanding the transition.
All the blocks with D3 examples still exist as gists. If you find yourself trying to look at a block but being redirected to an Observable notebook, you can replace bl.ocks.org with gist.github.com in the exampleās url. Then you can clone or download the gist and open it up locally.
Thank you very much, I did not know that - this is very helpful information.