Text Reports
How to use our web editor to create long-form reports
‌One of the challenges with building reports in Python is working with long chunks of text. To make this easier, we've introduced a web-based Report editor where you can build rich long-form reports for articles or tutorials and seamlessly include interactive elements from your Python environment.
To get started, choose a template through the Home page.
You can also create a TextReport directly in Python by running the following code:
1
import datapane as dp
2
import altair as alt
3
from vega_datasets import data
4
5
source = data.cars()
6
7
plot1 = alt.Chart(source).mark_circle(size=60).encode(
8
x='Horsepower',
9
y='Miles_per_Gallon',
10
color='Origin',
11
tooltip=['Name', 'Origin', 'Horsepower', 'Miles_per_Gallon']
12
).interactive()
13
14
dp.TextReport(
15
dp.Plot(plot1),
16
dp.DataTable(source)
17
).upload(name="Hello world")
Copied!
You'll need to be logged into Datapane.com or your Teams instance to use this feature - it is not currently supported on the open-source version.

Writing your first report

You can get started writing straight away with Markdown - check out this cheat sheet for more information or use the formatting icons at the top of the text area.
For example, try the following Markdown in the Text editor:
1
# This is a heading
2
**This is bold text**
3
*This is text in italics*
4
- These
5
- are
6
1. list
7
2. items
8
> This is a quote
9
[Click me](thisisalink.com)
Copied!
This will generate a report which looks as follows:

Inserting blocks

Aside from Markdown, you can enrich your report by adding special blocks, For example, clicking on the Formula block will insert the following snippet into the web editor:
1
```datapane
2
block: Formula
3
formula: x^2 + y^2 = z^2
4
```
Copied!
When you click 'Preview', you'll see this display as follows:
You can edit the content inside the blocks, just make sure the parameters follow YAML syntax (indentations can be tricky). For more information check out the pages about the block types:

Uploading Blocks from Python

You can push up assets to your existing report from Python by passing in the report id to a TextReport object, like this:
1
dp.TextReport(df=df, plot=plot).upload(id="REPORT_ID")
Copied!
‌(You'll need to replace df and plot with your own assets).
Make sure to save your report before viewing or sharing it, otherwise you might lose your work!
Last modified 3mo ago