This example demonstrates importing a notebook from ObervableHQ and replacing its data with data of our own (the code and data for this example were originally published here).
First we read from a local JSON file into population:

population = FileAttachment("population.json").json()





Then we import from https://observablehq.com/@d3/zoomable-sunburst and specify that we’d like to use population instead of the data built in to the notebook:

import { chart } with { population as data } from "@d3/zoomable-sunburst"





Finally, we display the chart:

chart






 




Source Code
---
title: "Population"
format: 
  html:
    code-tools: true
    toc: false
---

This example demonstrates importing a notebook from ObervableHQ and replacing its data with data of our own (the code and data for this example were originally published  [here](https://github.com/observablehq/examples/tree/main/custom-data)).

First we read from a local JSON file into `population`:

```{ojs}
population = FileAttachment("population.json").json()
```

Then we import from <https://observablehq.com/@d3/zoomable-sunburst> and specify that we'd like to use `population` instead of the data built in to the notebook:

```{ojs}
import { chart } with { population as data } from "@d3/zoomable-sunburst"
```

Finally, we display the chart:

```{ojs}
chart
```