framework
framework copied to clipboard
Allow vgplot to use DuckDBClient
From https://talk.observablehq.com/t/observable-framework-using-duckdbclient-sql-with-vgplot/9676/3:
I would like to load data using DuckDBClient.sql() and display with vgplot. I am able to do this with Observable Plot:
```js
const sql = DuckDBClient.sql({ rand: FileAttachment("./rand-xy.csv") });
```
```sql id=data
SELECT * FROM rand
```
```js
display(
Plot.plot({
height: 200,
marks: [
Plot.dot(data, {
x: "x",
y: "y",
}),
],
})
);
```
but not with vgplot:
```js
const sql = DuckDBClient.sql({ rand: FileAttachment("./rand-xy.csv") });
```
```js
display(
vg.plot(
vg.height(200),
vg.dot(vg.from("rand"), {
x: "x",
y: "y",
})
)
);
```
@mbostock responded:
Overriding the definition of sql doesn’t work (currently) with our implementation of vgplot. You’ll need to use the SQL front matter instead.