Skip to main content
For a chart in a published dashboard or note, get its numbers, aggregate them on the server, and get its image.

Two steps

1. Find the chart name

Run fetch with the id of the dashboard or note. In the result, metadata.charts holds the name, the aggregation (values) and the filters of each chart.
Replace <id> with an id from a search result. The result below was run on the dashboard Sales Orders Dashboard (id pQ9rS0tU1v). Long output is trimmed. Result
If metadata.charts lists the name of each chart, you have the chart names.

2. Get the numbers

Pass a name to --chart and run chart get-data.
Replace <id> with the id of the dashboard and <chart> with the name of the chart. The result below is for the chart qR0sT1uV (Monthly Sales Trend) in the dashboard with the id pQ9rS0tU1v. Long output is trimmed. Result
rows holds the numbers, and chart.encoding the column and aggregation of each axis. context holds the publication time, the data time and the parameter values. The numbers are the values as published. When has_more is true, there are more rows. Pass the number of rows you have already read to --offset to read on. One call returns at most 100 rows.
If the first 5 rows are in rows, you have the numbers.

Aggregate (optional)

For totals, rankings or the rows that match a condition, use chart query. It takes the same inputs as dataset query.
Replace <id> and <chart> with the id of the dashboard and the name of the chart. Take column names from query.columns in the result of chart get-data. The result below is for the chart kL8mN9oP (Sales by Region). The top 3 regions match the first 3 rows of the chart. Result
The table queried is the chart’s table as published. If you sum or average a column the chart already averaged, counted distinct or computed as a ratio, the warning CHART_REAGGREGATION appears. Then say so when you report the result, or use result.excluded_totals. When result.has_more is true, there are rows that are not in the result. There is no paging, so narrow the filters or aggregate. The warning RESULT_TRUNCATED above shows this case.
If the aggregated result is in rows, the query worked.

See the shape of the chart (optional)

To see the trend or layout of a chart, get its image.
Example of the output shape; values are illustrative. The example is for the chart qR0sT1uV (Monthly Sales Trend). The image_path line (where the image is saved) is trimmed. Result
The image is the one saved when the item was published, so it can be older than the data. Check result.image.may_be_stale. The image is saved on the computer that runs expl, and image_path shows where. You can also choose the location with --output. Read exact numbers with chart get-data, not from the image.
If result.image describes the image, you have it.

Troubleshooting

Every flag is described in chart get-data, how to aggregate in chart query, and getting the image in chart get-image.