liveBook · Manning

Href channel

As explained in Data Storytelling with Altair and AI

A URL channel maps data values to external resource locations associated with visual marks.

The href channel maps a visual mark’s data value to an external resource location. In Altair, it can turn chart text into a link, extending a visualization with sources or next steps. section 9.2.2 section 3.3.2

Use the href channel to connect chart content with supporting actions or evidence:

  • Attach a data-source URL to a text mark placed beneath a chart title. section 3.3.2
  • Add a learn-more link as a next step in a layered data story. section 9.2.2

Link a chart’s data source

Create a row containing display text and its URL, then encode both fields on a text mark: df_subtitle = pd.DataFrame({'text': ['source: World Bank'], 'href': 'https://data.worldbank.org/indicator/SP.POP.TOTL'}); subtitle = alt.Chart(df_subtitle).mark_text(y=0).encode(text='text', href='href').

How Data Storytelling with Altair and AI covers it

How deep it goes
Demonstrates href through text-mark encodings for data sources and learn-more actions, without developing its broader implementation.
Examples
Uses a World Bank source link and a swimming-pool case-study learn-more exercise.
What it assumes
Assumes basic Altair chart construction and mark_text usage.
What you can do after
Apply it via Altair to link chart text to a data source or external website.
How it connects
Connects Altair mark encodings with text annotations, data sources, and external websites.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Storytelling with Altair and AI. The section links point to the parts of the book it draws on.