Chart gallery
Each screenshot links to a live demo of that chart in Datasette Lite, which runs Datasette in your browser.
The demos use two databases:
content, the database behind datasette.io and data, the Global Power Plant Database from the World Resources Institute.
Line charts
A count or an aggregate over time, optionally split into series.
-
Screenshot Weekly downloads, split by package
A sum per week with one line for each of the five most downloaded packages. The rest are grouped as Other.
Chart spec
Table:
statsin thecontentdatabase{ "v": 1, "type": "line", "encoding": { "x": { "column": "date", "timeUnit": "week" }, "y": { "column": "downloads", "aggregate": "sum" }, "series": { "column": "package", "limit": 5, "other": true } }, "options": {} } -
Screenshot Releases per quarter
A count of rows for each quarter of a timestamp column, with a callout on one quarter.
Chart spec
Table:
releasesin thecontentdatabase{ "v": 1, "type": "line", "encoding": { "x": { "column": "published_at", "timeUnit": "quarter" }, "y": { "aggregate": "count" } }, "options": {}, "annotations": [ { "type": "point", "x": "2020-Q3", "text": "153 releases in the third quarter of 2020" } ] } -
Screenshot A line chart of a SQL query
Charts work on the results of a SQL query in the same way as on a table. This one is monthly downloads of a single package.
Chart spec
SQL query:
select date, downloads from stats where package = 'datasette'in thecontentdatabase{ "v": 1, "type": "line", "encoding": { "x": { "column": "date", "timeUnit": "month" }, "y": { "column": "downloads", "aggregate": "sum" } }, "options": {} }
Bar charts
A count or an aggregate for each value of a category.
-
Screenshot Power plants by primary fuel
A count of rows for each value of a column, largest first.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "bar", "encoding": { "x": { "column": "primary_fuel", "limit": 20, "other": true }, "y": { "aggregate": "count" } }, "options": {} } -
Screenshot Total capacity for the top 12 countries
A sum for each category. The limit keeps the 12 largest and leaves out the rest.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "bar", "encoding": { "x": { "column": "country_long", "limit": 12, "other": false }, "y": { "column": "capacity_mw", "aggregate": "sum" } }, "options": {} } -
Screenshot Upright bars with annotations
Capacity by the decade each plant was commissioned, from a SQL query that works out the decade. It has a shaded range, a reference line and a text note.
Chart spec
SQL query:
select cast(commissioning_year as integer) / 10 * 10 as decade, capacity_mw from global_power_plant_database where commissioning_year >= 1950in thedatadatabase{ "v": 1, "type": "bar", "encoding": { "x": { "column": "decade", "sort": "key", "limit": 50, "other": false }, "y": { "column": "capacity_mw", "aggregate": "sum" } }, "options": { "orientation": "vertical" }, "annotations": [ { "type": "range", "x": 1950, "x2": 1990, "text": "Commissioned before 2000" }, { "type": "line", "y": 1000000, "text": "1,000,000 MW" }, { "type": "text", "left": 0.02, "top": 0.04, "text": "Plants with a known commissioning year" } ] }
Histograms
The distribution of a numeric column, on a log scale when it has a long tail.
-
Screenshot Power plant capacity, on a log scale
Most plants are small and a few are very large, so the bins are on a log scale.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "histogram", "encoding": { "x": { "column": "capacity_mw" } }, "options": { "scale": "log" } } -
Screenshot Latitude of power plants
Linear bins for a column without a long tail.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "histogram", "encoding": { "x": { "column": "latitude", "bin": { "maxbins": 40 } } }, "options": { "scale": "linear" } }
Scatter plots
Two numeric columns: points for small sources, a binned heatmap for large ones.
-
Screenshot Generation against capacity for nuclear plants
A filtered table. A source of up to 2,000 rows is drawn as one point per row.
Chart spec
Filtered table:
global_power_plant_databasewhereprimary_fuelisNuclearin thedatadatabase{ "v": 1, "type": "scatter", "encoding": { "x": { "column": "capacity_mw" }, "y": { "column": "generation_gwh_2017" } }, "options": {} } -
Screenshot Generation against capacity, counted in bins
A larger source is counted into bins by the database and drawn as a heatmap.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "scatter", "encoding": { "x": { "column": "capacity_mw" }, "y": { "column": "generation_gwh_2017" } }, "options": {} }
Maps
Latitude and longitude: points for small sources, grid cells for large ones.
-
Screenshot Every power plant, counted in grid cells
A large source is counted into grid cells, so the chart query returns a few thousand rows.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "map", "encoding": { "latitude": { "column": "latitude" }, "longitude": { "column": "longitude" } }, "options": {} } -
Screenshot Nuclear power plants, sized by capacity
A filtered table. With under 200 rows each plant is a point, sized by a numeric column.
Chart spec
Filtered table:
global_power_plant_databasewhereprimary_fuelisNuclearin thedatadatabase{ "v": 1, "type": "map", "encoding": { "latitude": { "column": "latitude" }, "longitude": { "column": "longitude" }, "size": { "column": "capacity_mw" } }, "options": {} }
Stacked and grouped bars
Two categories, or a category over time.
-
Screenshot Capacity by country and fuel
The ten countries with the most capacity, stacked by the six most common fuels.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "stacked_bar", "encoding": { "x": { "column": "country_long", "limit": 10, "other": false }, "series": { "column": "primary_fuel", "limit": 6, "other": true }, "y": { "column": "capacity_mw", "aggregate": "sum" } }, "options": { "layout": "stacked" } } -
Screenshot Fuel by where the location came from, side by side
The grouped layout draws a bar for each value in place of a stack.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "stacked_bar", "encoding": { "x": { "column": "primary_fuel", "limit": 5, "other": false }, "series": { "column": "geolocation_source", "limit": 3, "other": true }, "y": { "aggregate": "count" } }, "options": { "layout": "grouped" } } -
Screenshot PyPI uploads per year by package type
A category over time. The x axis is a timestamp column, counted by year.
Chart spec
Table:
pypi_releasesin thecontentdatabase{ "v": 1, "type": "stacked_bar", "encoding": { "x": { "column": "upload_time", "timeUnit": "year" }, "series": { "column": "packagetype", "limit": 6, "other": true }, "y": { "aggregate": "count" } }, "options": { "layout": "stacked" } }
Annotations
Notes drawn on a chart: lines, shaded ranges, callouts and text. They are part of the chart's spec, so they are kept in the link to the chart. Documentation for annotations.
-
Screenshot A line at an x value
A dashed line across the chart at a date, here the day of a release.
Chart spec
Table:
releasesin thecontentdatabase{ "v": 1, "type": "line", "encoding": { "x": { "column": "published_at", "timeUnit": "quarter" }, "y": { "aggregate": "count" } }, "options": {}, "annotations": [ { "type": "line", "x": "2022-11-29", "text": "Datasette 1.0a0" } ] } -
Screenshot A line at a y value
A reference line at a value, drawn solid and in red.
Chart spec
Table:
pypi_releasesin thecontentdatabase{ "v": 1, "type": "stacked_bar", "encoding": { "x": { "column": "upload_time", "timeUnit": "year" }, "series": { "column": "packagetype", "limit": 6, "other": true }, "y": { "aggregate": "count" } }, "options": { "layout": "stacked" }, "annotations": [ { "type": "line", "y": 500, "text": "500 uploads a year", "stroke": "solid", "color": "red" } ] } -
Screenshot A shaded range
A band between two x values, on a histogram.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "histogram", "encoding": { "x": { "column": "latitude", "bin": { "maxbins": 40 } } }, "options": { "scale": "linear" }, "annotations": [ { "type": "range", "x": -23.44, "x2": 23.44, "text": "The tropics" } ] } -
Screenshot A callout on a point
A dot on one data point with a line to its label. On a scatter plot the callout gives both x and y.
Chart spec
Filtered table:
global_power_plant_databasewhereprimary_fuelisNuclearin thedatadatabase{ "v": 1, "type": "scatter", "encoding": { "x": { "column": "capacity_mw" }, "y": { "column": "generation_gwh_2017" } }, "options": {}, "annotations": [ { "type": "point", "x": 5460, "y": 31471.106, "text": "Gravelines, France" } ] } -
Screenshot A text note
A note placed by fractions of the plot area. This is the one type a map takes, since it has no x or y axis.
Chart spec
Table:
global_power_plant_databasein thedatadatabase{ "v": 1, "type": "map", "encoding": { "latitude": { "column": "latitude" }, "longitude": { "column": "longitude" } }, "options": {}, "annotations": [ { "type": "text", "left": 0.02, "top": 0.95, "text": "Source: Global Power Plant Database, World Resources Institute" } ] } -
Screenshot Several annotations, with colors and line styles
A range, a dotted line and a callout on one chart, each in its own color. Their labels are laid out together so that none covers the data or another label.
Chart spec
Table:
releasesin thecontentdatabase{ "v": 1, "type": "line", "encoding": { "x": { "column": "published_at", "timeUnit": "quarter" }, "y": { "aggregate": "count" } }, "options": {}, "annotations": [ { "type": "range", "x": "2020-Q1", "x2": "2020-Q4", "text": "427 releases in 2020", "color": "orange" }, { "type": "line", "y": 100, "text": "100 a quarter", "stroke": "dotted", "color": "gray" }, { "type": "point", "x": "2023-Q1", "text": "137 releases", "color": "purple" } ] }