Is it possible to use Perspective Data Grid in observablehq?

Viewed 36

I tried to use Perpective Data Grid in observablehq, but I am struggling to reproduce even the simpliest examples from the Perspective documentation such as the one below. I fear it is because I do not know how to import the modules. I tried perspective = require("@finos/perspective"), but it does not seem to be working. My end goal is to create a data exploration tool such as this one.

<script>
    const worker = window.perspective.worker();
    const table = await worker.table({ A: [1, 2, 3] });
    const view = await table.view({ sort: [["A", "desc"]] });

    const viewer = document.createElement("perspective-viewer");
    viewer.load(table);
    document.body.appendChild(viewer);
</script>
1 Answers

Unfortunately, the way this package seems to work is almost entirely incompatible with the way Observable works. It is essentially creating its own reactive data flow and injecting code and elements into the DOM, which ends up clashing with Observable's way of working.

Unless you specifically want to use this library, there are many examples of interactive exploration tools on Observable, though. Here's one using a scatterplot for example, or another nice walkthrough using maps, tables, etc. And you can easily find many more.

Related