Skip to main content

Streamlit Net Bars

A reusable Streamlit component with diverging stacked bars and an overlaid net line. Click any bar segment to hide that entire series across all x positions. Toggle legend buttons to restore individual series, or select Show all. Use Undo to reverse visibility changes one at a time, including legend toggles and Show all. Undo is disabled until a change is made. History is kept per chart across Streamlit reruns for the current session.

Positive values stack above the centered zero line; negative values stack below. The line is the signed sum of the visible series at each position. All hidden means a zero line. The symmetric y scale adjusts to the visible contributions.

Toggle Cumulative net to show the running signed sum of the visible net values, starting at the first x position. For net values [40, 50, -20], the cumulative line is [40, 90, 70]. Positions use the supplied order, so sort time data before passing it in. Bars keep their per-position contributions, and the shared axis expands to fit the line. Toggle off to return to per-position net. Mode survives reruns; hiding, restoring, and Undo work in either mode. Undo continues to reverse visibility changes, independently of the selected mode.

Copy image copies a PNG of the current chart, title, visible-series legend, and net mode at double resolution. It includes the full plot even when the chart scrolls horizontally. Paste into an app that accepts images. Copying requires a browser that supports image clipboard writes and a secure context (HTTPS or localhost). A Download PNG link is offered after copying, and also as a fallback if clipboard access is unavailable or denied. Copying does not change visibility, mode, or Undo history.

Run the demo

python -m venv .venv
.venv\Scripts\python -m pip install -e .
.venv\Scripts\python -m streamlit run app.py

Once published on PyPI, install with python -m pip install interactive-streamlit-bar-plot.

Use the component

import streamlit as st
from streamlit_net_bars import net_bar_chart

result = net_bar_chart(
    x=["Jan", "Feb", "Mar"],
    series={"Revenue": [100, 120, 140], "Costs": [-60, -70, -80]},
    key="cashflow",  # unique, stable key per chart
    title="Monthly cashflow",
    height=420,  # plot height in pixels; header and legend add height
)
st.write(result.net)      # [40, 50, 60] with all series visible
st.write(result.hidden)   # names of hidden series
st.write(result.visible)  # names of visible series
st.write(result.cumulative)  # whether cumulative mode is selected
st.write(result.line_values)  # displayed line, including cumulative mode

Pass a mapping of names to equally sized numeric sequences. DataFrame columns work with series={name: df[name].tolist() for name in columns}. Values must be finite; fill or drop missing values before calling. Labels are displayed in the provided order; duplicate labels remain distinct positions. Series names are their identities, so use stable names when updating data. Visibility survives Streamlit reruns; new series start visible and removed series are ignored.

Use on_change=callback for a Streamlit callback when visibility or line mode changes. The returned net values are recalculated in Python from the current visibility and input data. Multiple chart instances are independent when given different keys.

Development

The frontend is plain JavaScript and SVG, with no Node build or CDN dependency. Assets ship inside the Python package. The component uses Streamlit Components v2 (Streamlit 1.51 or newer). Bars support Enter/Space and provide native hover tooltips. The legend also supports hiding zero-only series. Long charts scroll horizontally; long x labels are abbreviated in the plot and shown fully in tooltips.

python -m unittest discover -s tests -v
Get-Content streamlit_net_bars/frontend/chart.js -Raw | node --input-type=module --check

The demo uses illustrative monthly contributions, not real financial data.

Releases

See PUBLISHING.md for the GitHub Actions Trusted Publishing setup and release procedure. Licensed under MIT; copyright John Della Rosa.

Metadata

Release files for interactive-streamlit-bar-plot 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for interactive-streamlit-bar-plot 0.1.0
File Size Uploaded Provenance
interactive_streamlit_bar_plot-0.1.0.tar.gz 15.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for interactive-streamlit-bar-plot 0.1.0
File Interpreter ABI Platform
interactive_streamlit_bar_plot-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.6 kB

Release files / interactive_streamlit_bar_plot-0.1.0.tar.gz

Download URL interactive_streamlit_bar_plot-0.1.0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
02472fd2764c6f6f4e1c7c53e8be391d0bc6be66b3d877f6d812982918c2fca8
BLAKE2b-256 checksum
How to use checksums
e4a31feb514bf0b21feb4bcf37c19b135f2111ce4a120757c04a474ff69d03fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / interactive_streamlit_bar_plot-0.1.0-py3-none-any.whl

Download URL interactive_streamlit_bar_plot-0.1.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4033d71472ba7bd43b0936059db9ef3772f12de309b37d33d53285b261b0a933
BLAKE2b-256 checksum
How to use checksums
58e3980bc9c8c462b9559fefa944436d3464855f43a39add29d1b99dc2de96e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for interactive-streamlit-bar-plot 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for interactive_streamlit_bar_plot-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page