Datasette plugin providing data dashboards from metadata
Project description
datasette-dashboards
Datasette plugin providing data dashboards from metadata
Try out a live demo at https://datasette-dashboards-demo.vercel.app
WARNING: this plugin is still experimental and not ready for production. Some breaking changes might between releases before reaching version 1.0.0. Use it at your own risks!
Installation
Install this plugin in the same environment as Datasette:
$ datasette install datasette-dashboards
Usage
Define dashboards within metadata.yml
/ metadata.json
:
plugins:
datasette-dashboards:
my_dashboard:
title: My Dashboard
description: Showing some nice metrics
layout:
- [chart1]
- [chart2]
charts:
- title: Number of events by day
db: jobs
query: SELECT date(date) as day, count(*) as count FROM events GROUP BY day ORDER BY day
library: vega
display:
mark: { type: line, tooltip: true }
encoding:
x: { field: day, type: temporal }
y: { field: count, type: quantitative }
- title: Number of events by source
db: jobs
query: SELECT source, count(*) as count FROM events GROUP BY source ORDER BY count DESC
library: vega
display:
mark: { type: bar, tooltip: true }
encoding:
color: { field: source, type: nominal }
theta: { field: count, type: quantitative }
A new menu entry is now available, pointing at /-/dashboards
to access all defined dashboards.
Properties
Dashboard properties:
Property | Type | Description |
---|---|---|
title |
string |
Dashboard title |
description |
string |
Dashboard description |
layout |
array |
Dashboard layout |
Common chart properties for all chart types:
Property | Type | Description |
---|---|---|
title |
string |
Chart title |
db |
string |
Database name against which to run the query |
query |
string |
SQL query to run and extract data from |
library |
string |
One of supported libraries: vega , markdown |
display |
object |
Chart display specification (depend on the used library) |
Vega properties
Available configuration for vega
charts:
Property | Type | Description |
---|---|---|
library |
string |
Must be set to vega |
display |
object |
Vega specification object |
Notes about the display
property:
- Requires a valid Vega specification object
- Some fields are pre-defined:
$schema
,title
,width
,view
,config
,data
- All fields are passed along as-is (overriding pre-defined fields if any)
- Only
mark
andencoding
fields are required as the bare-minimum
Markdown properties
Available configuration for markdown
chart:
Property | Type | Description |
---|---|---|
library |
string |
Must be set to markdown |
display |
string |
Multi-line string containing the Markdown content |
Note :
- Some common properties do not apply and can be omitted:
title
,db
,query
- Markdown rendering is done by
datasette-render-markdown
- To configure Markdown rendering, extensions can be enabled in metadata
Dashboard layout
The default dashboard layout will present two charts per row (one per row on mobile).
To make use of custom dashboard layout using CSS Grid Layout,
define the layout
array property such as:
- Each entry represents a row of charts
- Each column is referred by the 1-indexed chart in the list (e.g. "chart1", "chart2, etc.)
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment and the required dependencies:
pipenv install -d
pipenv shell
To run the tests:
pytest
Demo
With the developmnent environment setup, you can run the demo locally:
datasette --metadata demo/metadata.yml demo/jobs.db
License
Licensed under Apache License, Version 2.0
Copyright (c) 2021 - present Romain Clement
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for datasette-dashboards-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51344d04685b5503e0f5752b511f0d4c816bea2dbaba1cf4a14cd1bb97ca4179 |
|
MD5 | 0a42ef7d693ddb9ff5dadb3271e2f964 |
|
BLAKE2b-256 | 984fbefdafa9bfc87a13ce0b457218d4b1229021c0402384964eb8153d3b85f1 |
Hashes for datasette_dashboards-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14bb1009bc0f405162ccdcbbab454408c7ef24215f361ecb3ec19fcd46bf0283 |
|
MD5 | 450c7296d02c6cf80238345a48497b52 |
|
BLAKE2b-256 | 87eada30e6d39a625e2cf4add5649141c852ef14f34559b7cd2460c18b22aa72 |