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 displaycdf_token(str): CDF API token for authenticationcdf_project(str): CDF project name
Optional Parameters
merge_units(bool, default=False): Whether to merge timeseries with the same units on the same y-axisshow_min_max(bool, default=False): Whether to show min/max bands for aggregated datacdf_base_url(str, default="https://api.cognitedata.com"): CDF base URLheight(int, default=600): Height of the chart in pixelsstart_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 timeserieskey(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
- Clone the repository:
git clone https://github.com/yourusername/st-tschart.git
cd st-tschart
- Build the component:
./build.sh
- 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
- Ensure CDF credentials are correctly provided
- Verify timeseries IDs exist in your CDF project
- Check browser console for any JavaScript errors
Build issues
- Ensure Node.js and npm are installed
- Run
npm installin the frontend directory - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed0faec83ee5238ecb817aec9cfb572021f9305df0f88aa20af0ca1c2a9e8326
|
|
| MD5 |
46354e315b4015cc175010c163592dd0
|
|
| BLAKE2b-256 |
666afe27c8cf46cc78e540f21dcbb9d0e5dd6a9f93d0c01850f52757e2dd4590
|
File details
Details for the file st_tschart-0.1.0-py3-none-any.whl.
File metadata
- Download URL: st_tschart-0.1.0-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b8cf745d2331d10ac50cf2bd48495e81b0380d6b852a7a562c922bc23662452
|
|
| MD5 |
fc21f9eaa86616e957560f5a3eefa5fd
|
|
| BLAKE2b-256 |
03c28de7d262118d0c119f88b4e6b1c0df2c88c376fa16d146768f9969c52690
|