Skip to main content

Display pretty Customer Journeys in Streamlit

Overview

The st_customer_journey component is designed for Streamlit applications to visualize and interact with customer journeys or similar flows. It allows the creation of a customizable and interactive journey map with main and child nodes, each representing different stages or steps in a customer journey. The component is highly customizable with options for colors, icons, labels, tooltips, and more.

Installation

To install the st_customer_journey component, run the following command:

pip install st-customer-journey

Usage

First, import the st_customer_journey function in your Streamlit app:

from st_customer_journey import st_customer_journey

Basic Example

Here's a basic example of how to use the st_customer_journey component in a Streamlit app:

import streamlit as st
from st_customer_journey import st_customer_journey

# Define your nodes
input_data = [ 
   {
    "id": 1,
    "name":"r&d",
    "label": "Research & Discover",
    "color": "#A3D2CE",
    "icon": "fa fa-magnifying-glass",
    "return_value": "r&d",
    "size": 20,
    "label_position": "top",
    "expand_direction": "down",
    "label_style": "font-weight: bold; font-size:15px;",
    "icon_style": "color: white;",
    "tooltip": "<b>Pretty Tooltip</b>",
    "children": [
        {
            "id": 2,
            "name": "advertising",
            "label": "See advertising",
            "color": "#A3D2CE",
            "return_value": "advertising",
            "size": 5,
            "label_position": "right",
            "label_style": "font-size:13px;",
            "tooltip": "Tooltip over multiple <br> lines.",
        },
        {
            "id": 3,
            "name": "read_marketing",
            "label": "Read marketing content on website",
            "color": "#A3D2CE",
            "return_value": "read_marketing",
            "size": 5,
            "label_position": "right",
            "label_style": "font-size:13px;",
            "disabled": True,
            "tooltip": "<code> Disabled = True </code>",
        },
    ],
},
    # Add more nodes as needed
]

# Render the customer journey component
clicked_node = st_customer_journey(input_data, key="cj1")

# Display the clicked node
st.write("Clicked Node: ", clicked_node)

Parameters

  • content: A list of dictionaries where each dictionary represents a node in the customer journey.
  • space_main_nodes: Horizontal space between main nodes.
  • space_between_child_nodes: Vertical space between child nodes.
  • key: A unique key for the component instance.
  • defaultValue: Default value to be used in the component; returned if nothing is clicked.
  • custom_font_awesome_url: URL for FontAwesome icons.
  • tooltipStyle: CSS properties for styling the tooltip.
  • height: Height of the component.
  • max_width: Maximum width of the component.
  • first_child_extra_space: Additional vertical space for the first child node.
  • mainLabelOffset: Offset for the main label.
  • custom_css: Custom CSS string for additional styling. Can be useful to add padding left or right if labels are cut off.

Node Attributes

Each node in the content list can have the following attributes:

  • id (int): Unique identifier for the node. It is mandatory and must be unique.
  • name (str): Name of the node. This is a mandatory field.
  • label (str, optional): Display label for the node. It can include HTML content.
  • color (str, optional): The fill color of the node. It can be specified in CSS color formats, like hex codes or color names.
  • size (int, optional): Size of the node, determining its diameter if circular. Default size differs for main nodes and child nodes.
  • icon (str, optional): FontAwesome icon class for display on the node. Example: 'fa fa-home'.
  • icon_style (str, optional): CSS styling applied to the icon. Example: 'color: white; background-color: red; border-radius: 50%;'.
  • expand_direction (str, optional): Direction ('up' or 'down') for child nodes expansion.
  • children (list, optional): Child nodes of this node. Each child can have the same attributes as the parent node except 'children'.
  • label_position (str, optional): Position of the label relative to the node ('bottom', 'top', 'left', 'right').
  • label_style (str, optional): CSS styling for the label text.
  • node_style (str, optional): Additional CSS styling for the node.
  • tooltip (str, optional): Tooltip text displayed on hover over the node. HTML content can be used for tooltips.
  • return_value (any, optional): Value returned when the node is interacted with. Default is the node's name.
  • disabled (bool, optional): If set to True, the node will not be interactive (i.e., it cannot be clicked).

Advanced Customization

You can further customize nodes with additional attributes like label_style, node_style, expand_direction, children, tooltip, etc., to create a detailed and interactive customer journey.

Example App

Click here to see the component in action Open in Streamlit

Metadata

Release files for st-customer-journey 0.0.2

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

Built distribution (wheel)

Table of built distributions (wheels) for st-customer-journey 0.0.2
File Interpreter ABI Platform
st_customer_journey-0.0.2-py3-none-any.whl Python 3 none any Details

Release files / st_customer_journey-0.0.2-py3-none-any.whl

Download URL st_customer_journey-0.0.2-py3-none-any.whl
Size 567.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
400744369b3313430394dcf09cd807af256a46b6aec21533235716bdeff79409
BLAKE2b-256 checksum
How to use checksums
1a2ace1636ea67ec260c25b196a74773c4ec5056fabacb35a25a74066ed60ed0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

1 release file

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