Observable Framework: where did Penguins come from??

I’m intrigued by Observable Framework.

If I create the example project and run it, I get a website with a couple of charts on the homepage. The code to generate this in index.md makes reference to variables aapl and penguins but it’s unclear where these come from.

Are they baked into the framework as global variables? This seems a little strange.

2 Likes

Yes, these are part of the Observable standard library. Not sure if we have documentation on them in the Framework docs yet, but they’re the same as the ones that can be used to get started in notebooks.

To add to @eagereyes’s reply, you can find the implicit imports from the Observable standard library here:

https://observablehq.com/framework/javascript/imports#implicit-imports

And in addition (but not yet mentioned in the Framework docs) are the sample datasets documented here:

You can find the relevant source code here:

The reason we do this is to make it convenient to get started. For example you can paste a snippet for a Plot bar chart, and it’ll just work without you also having to download a CSV file and place it alongside your Markdown.

Importantly, none of these implicit imports are evaluated unless you reference them. So you don’t pay any overhead to load these sample datasets, or any of the recommended libraries, unless you actually use them. And if you declare a top-level variable with the same name as one of these built-ins, your definition will take priority of the built-in definition. So you can pretend they don’t exist if you don’t like them. :sweat_smile: