Many times, your report will have different blocks, but you may wish to share only a subset, for instance it's often useful to embed a specific chart or dataset into another platform - especially if you are refreshing it on a cadence.
Instead of creating a report for each block, Datapane provides an
block_name query parameter you can add to your report link that allows you to query your report, so you can embed only the relevant blocks.
Here are a few of the most common examples and use-cases you will encounter.
The easiest way to embed only a single block is to assign a
name to your block when creating it, e.g.
dp.Plot(plot, name="my-plot"), and then use a simple query of the following form to select it in your embed URL,
?block_name=my-plot is a URL param that will extract any report block with the
For instance, the plot in this report has a name of
block-7, and so the following query will select just that plot: https://datapane.com/leo/reports/continent_covid_cases/?block_name=block-7
As mentioned, Reports are comprised of multiple block types, such as
Text, and so on - we can select just blocks of a specific type using XPath, and even select the specific index of a particular block type or a range.
Let's say there are both Table and Plot blocks in your report, and you want to only embed the plots from your report. Simply add
/?blocksquery=//Plot at the end of the report link. For example, to extract all the plots in this report you can use the following query,
If you want to query only the first plot of the report, just add an index to the Plot query, i.e.,
https://datapane.com/u/leo/reports/google-trends/embed/?blocksquery=//Plot will select the first plot, and https://datapane.com/u/leo/reports/google-trends/embed/?blocksquery=//Plot will the second.