The flourishcharts packages are provided by Canva as open source software under the MIT license(opens in a new tab or window).

Extending the Flourish base visualization ID

from flourishcharts import Flourish
from flourishcharts.datasets import gapminder
PYTHON
library(flourishcharts)
R

Flourish allows users to extend visualizations created in the app online via the API. This feature uses a base visualization ID to call the original chart.

The original chart must be published via the app. Every Flourish URL pointing to a chart made in the editor cotains a unique ID - this is the base visualization ID. As an example, we published this chart using the default data source that Flourish provides: https://public.flourish.studio/visualisation/17833871/(opens in a new tab or window).

The base visualization ID is 17833871.

We are able to recreate this graph inside R or Python by passing the base visualization ID to the flourish() function in R or the Flourish() class in Python.

graph = Flourish(base_visualisation_id = 17833871)
PYTHON
graph <- flourish(base_visualisation_id = 17833871)
R

In addition to recreating it, we can also extend the graph by writing over data, data bindings, or chart settings.

df = (
gapminder[gapminder['year'] == gapminder['year'].max()]
.assign(lifeExp=lambda x: x['lifeExp'].round())
.sort_values(by='lifeExp')
.head(10)
)
Flourish(
base_visualisation_id = 17833871
).bind_line_bar_pie_data(
data = df,
label = "country",
value = "lifeExp"
).set_line_bar_pie_details(
chart_y_axis_title = "Bottom 10 Life Expectancy in 2007"
)
PYTHON
df <- gapminder |>
filter(year == max(year)) |>
mutate(lifeExp = round(lifeExp)) |>
arrange(lifeExp) |>
slice_head(n = 10)
graph |>
bind_line_bar_pie_data(
data = df,
label = "country",
value = "lifeExp"
) |>
set_line_bar_pie_details(
chart_y_axis_title = "Bottom 10 Life Expectancy in 2007"
)
R

This is a powerful notion because we can publish graphs with dummy data and write over them with real data locally. This is important for conserving the privacy of enterprise data.

Additionally, as the Flourish team note in their documentation - the base visualization ID enables non-technical stakeholders to build and style graphs to which technical stakeholders can then add data. Moreover, if a non-technical stakeholder were to update the graph inside the website, the changes will flow down into the API.