simonw / django-sql-dashboard

Django app for building dashboards using raw SQL queries
https://django-sql-dashboard.datasette.io/
Apache License 2.0
437 stars 37 forks source link

Really basic charting support #10

Closed simonw closed 3 years ago

simonw commented 3 years ago

I could use that trick where if a query returns columns with specific names a charting mechanism kicks in. Could use Vega-Lite for this. Will be a little like datasette-vega but less flexible, at least for the first version. Probably implemented entirely in JavaScript.

simonw commented 3 years ago

For the first version I'm going to use Vega-Lite loaded from a CDN with a SRI. I'll support basic bar charts:

select value as bar_quantity, name as bar_label from sometable;
simonw commented 3 years ago

From the example on https://vega.github.io/vega-lite/tutorials/getting_started.html

    <script src="https://cdn.jsdelivr.net/npm/vega@5.19.1"></script>
    <script src="https://cdn.jsdelivr.net/npm/vega-lite@5.0.0"></script>
    <script src="https://cdn.jsdelivr.net/npm/vega-embed@6.15.1"></script>
simonw commented 3 years ago

Using https://www.srihash.org/

<script src="https://cdn.jsdelivr.net/npm/vega@5.19.1" integrity="sha384-dhyUMwHr1RzDslJIbzN+8UMRMobmqrmABSU3vFSBBnARl6XwbW37TVDCTQs+yEc5" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5.0.0" integrity="sha384-nAwfbn/eKhGkpj7MbyqVuoGEyL/iSeZq4XJ1NNOxA9nT7eXfJuUQgpxYd27m1tAO" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6.15.1" integrity="sha384-RvXMbul/5q2mGE4PXcky3u5+A/K3lk/jv+oizUX/InRPD9wELInOy6YwUxdk/tEu" crossorigin="anonymous"></script>