Skip to main content

A Streamlit component for rendering interactive timeseries charts with CDF integration

Project description

st-tschart

A Streamlit component for rendering interactive timeseries charts with Cognite Data Fusion (CDF) integration.

Features

  • ๐Ÿ“Š Multiple Timeseries Display: Visualize multiple timeseries on the same chart
  • ๐Ÿ” Interactive Zoom & Pan: Explore your data with intuitive controls
  • ๐Ÿ“ˆ Min/Max Bands: Display aggregated data with min/max visualization
  • ๐ŸŽจ Unit Grouping: Automatically group timeseries with the same units
  • ๐ŸŒ™ Theme Support: Inherits Streamlit's light/dark theme
  • โšก CDF Integration: Direct integration with Cognite Data Fusion
  • ๐Ÿ“ฑ Responsive Design: Adapts to different screen sizes

Installation

pip install st-tschart

Quick Start

import streamlit as st
from st_tschart import timeseries_chart

# Basic usage
result = timeseries_chart(
    items=[1222, 2323, 3333],  # List of timeseries IDs
    merge_units=True,           # Group same units on same y-axis
    show_min_max=True,          # Show min/max bands
    cdf_token="your-token",     # CDF API token
    cdf_project="your-project", # CDF project name
    cdf_base_url="https://api.cognitedata.com",
    height=600                  # Chart height in pixels
)

# Access the returned data
if result:
    st.write("Selected time range:", result['timerange'])
    st.write("Timeseries metadata:", result['items'])

Parameters

Required Parameters

  • items (List[Union[int, str]]): List of timeseries IDs to display
  • cdf_token (str): CDF API token for authentication
  • cdf_project (str): CDF project name

Optional Parameters

  • merge_units (bool, default=False): Whether to merge timeseries with the same units on the same y-axis
  • show_min_max (bool, default=False): Whether to show min/max bands for aggregated data
  • cdf_base_url (str, default="https://api.cognitedata.com"): CDF base URL
  • height (int, default=600): Height of the chart in pixels
  • start_date (str, optional): Start date for the time range (ISO format)
  • end_date (str, optional): End date for the time range (ISO format)
  • max_data_points (int, default=1000): Maximum number of data points to fetch per timeseries
  • key (str, optional): Unique component key for Streamlit

Return Value

The component returns a dictionary with two keys:

{
    'items': [...],      # List of metadata for the displayed timeseries
    'timerange': {       # The selected time range
        'start': '...',  # ISO format timestamp
        'end': '...'     # ISO format timestamp
    }
}

Development

Prerequisites

  • Node.js and npm
  • Python 3.9+
  • uv (for Python package management)

Building from Source

  1. Clone the repository:
git clone https://github.com/yourusername/st-tschart.git
cd st-tschart
  1. Build the component:
./build.sh
  1. Test locally:
uv run streamlit run example_app.py

Project Structure

st-tschart/
โ”œโ”€โ”€ st_tschart/
โ”‚   โ”œโ”€โ”€ __init__.py           # Python package entry point
โ”‚   โ””โ”€โ”€ frontend/             # React frontend
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ components/   # React components
โ”‚       โ”‚   โ”œโ”€โ”€ services/     # CDF client service
โ”‚       โ”‚   โ”œโ”€โ”€ hooks/        # React hooks
โ”‚       โ”‚   โ”œโ”€โ”€ types/        # TypeScript types
โ”‚       โ”‚   โ””โ”€โ”€ main.tsx      # Frontend entry point
โ”‚       โ””โ”€โ”€ package.json      # Frontend dependencies
โ”œโ”€โ”€ example_app.py            # Example Streamlit app
โ”œโ”€โ”€ build.sh                  # Build script
โ”œโ”€โ”€ pyproject.toml           # Python package configuration
โ””โ”€โ”€ README.md                # This file

Example App

Run the example app to see the component in action:

uv run streamlit run example_app.py

The example app demonstrates:

  • How to configure CDF credentials
  • Adding multiple timeseries IDs
  • Adjusting display options
  • Handling the component's return value

Theme Integration

The component automatically inherits Streamlit's theme colors. It adapts to both light and dark themes without any additional configuration.

Troubleshooting

Component not displaying

  1. Ensure CDF credentials are correctly provided
  2. Verify timeseries IDs exist in your CDF project
  3. Check browser console for any JavaScript errors

Build issues

  1. Ensure Node.js and npm are installed
  2. Run npm install in the frontend directory
  3. Check that uv is installed for Python package management

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please use the GitHub Issues page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

st_tschart-0.1.0.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

st_tschart-0.1.0-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file st_tschart-0.1.0.tar.gz.

File metadata

  • Download URL: st_tschart-0.1.0.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.9

File hashes

Hashes for st_tschart-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ed0faec83ee5238ecb817aec9cfb572021f9305df0f88aa20af0ca1c2a9e8326
MD5 46354e315b4015cc175010c163592dd0
BLAKE2b-256 666afe27c8cf46cc78e540f21dcbb9d0e5dd6a9f93d0c01850f52757e2dd4590

See more details on using hashes here.

File details

Details for the file st_tschart-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for st_tschart-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b8cf745d2331d10ac50cf2bd48495e81b0380d6b852a7a562c922bc23662452
MD5 fc21f9eaa86616e957560f5a3eefa5fd
BLAKE2b-256 03c28de7d262118d0c119f88b4e6b1c0df2c88c376fa16d146768f9969c52690

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page