Working in the notebook with Python, you may face the need to use the data visualization library that might not have a version for Python. Sure, Python has a rich ecosystem and chances that you'll find an alternative solution are quite high. But what if above all other libraries you'd like to use exactly this one you like most?
Observable notebooks offer features you'd expect from a traditional notebook:
- Quick prototyping of visualizations
- Running code in cells is accompanied by visual outputs
But the thing that makes Observable different is the concept of reactivity.
How often do you face an exception once you run a cell and it didn't contain a variable which the current code is dependent on? I bet quite often. This is what can be solved by bringing reactivity to the cells. Reactivity means the following: once a certain cell is changed, every other cell that references it is updated as well to reflect the applied modifications. Plus, there is no need to refresh the page once you edit code. The output is changed in real-time.
To dig deeper, you can read about topological order. I hope you’ll find it fascinating and innovative as I do.
Before we dive into the practical part of this article, here are fundamental differences you should pay attention to:
The first difference that you may find unusual is that the output is always above the code you run.
The way you write a multi-line statement. To run it in a single cell, you need to surround it with curly braces.
In contrast to Jupyter, cells are not executed in top-to-bottom order. As previously mentioned, the order depends on the connections between cells' contents.
Next, I've defined a
<div> container using an HTML template literal. After, I've created an instance of a pivot table which would help me to summarize raw data. To see the pivot table tool rendered, I've run the cell. Then I set a report by dragging and dropping the fields on the grid, filtered the records and highlighted values with colors. And all this interactively.
Note that if you're editing the report interactively, you need to save the results to JSON via the Toolbar button. This JSON can be inserted into the pivot table configuration or uploaded via the setReport API call.
Let’s check out the results we achieved so far:
The code is worth a thousand words. You can fork my notebook and play with it. I encourage you to come with your unique ways of exploring data with Flexmonster and Observable.
Please share your thoughts in the comments below. I'd be happy if you shared your experience in using Observable and other ways to avoid clumsy workarounds on making third-party libraries work in the Jupyter environment.