Type Definitions
This module contains all type definitions used throughout the package.
Main Types Module
Type definitions for Streamlit Lightweight Charts Pro.
This module re-exports type definitions from lightweight_charts_pro and adds any Streamlit-specific type definitions.
- class streamlit_lightweight_charts_pro.type_definitions.AnnotationPosition[source]
-
Annotation position enumeration.
Defines where annotations should be positioned relative to the data point or price level on the chart.
- ABOVE
Position annotation above the data point.
- BELOW
Position annotation below the data point.
- INLINE
Position annotation inline with the data point.
- __new__(value)
- ABOVE = 'above'
- BELOW = 'below'
- INLINE = 'inline'
- class streamlit_lightweight_charts_pro.type_definitions.AnnotationType[source]
-
Annotation type enumeration.
Defines the available types of annotations that can be placed on charts to mark important points, draw shapes, or add visual indicators.
- TEXT
Text annotation - displays text at a specific location.
- ARROW
Arrow annotation - points to a specific location with an arrow.
- SHAPE
Shape annotation - draws geometric shapes (circles, squares, etc.).
- LINE
Line annotation - draws horizontal or vertical lines.
- RECTANGLE
Rectangle annotation - draws rectangular shapes.
- CIRCLE
Circle annotation - draws circular shapes.
- __new__(value)
- TEXT = 'text'
- ARROW = 'arrow'
- SHAPE = 'shape'
- LINE = 'line'
- RECTANGLE = 'rectangle'
- CIRCLE = 'circle'
- class streamlit_lightweight_charts_pro.type_definitions.BackgroundGradient[source]
Bases:
Options,ABCGradient background configuration.
This class represents a gradient background for charts, transitioning from a top color to a bottom color. It provides type safety and validation for both color values.
The class inherits from Options and ABC to provide consistent interface with other chart options and enable proper serialization.
- style
The background style, always set to VERTICAL_GRADIENT for this class.
Example
```python # Create a white to black gradient bg = BackgroundGradient(top_color=”#ffffff”, bottom_color=”#000000”)
# Create a blue to red gradient bg = BackgroundGradient(top_color=”blue”, bottom_color=”red”)
- Raises:
ValueError – If either color format is invalid.
Note
Both top_color and bottom_color are validated during initialization using the _is_valid_color function.
- __init__(top_color='#ffffff', bottom_color='#000000', style=BackgroundStyle.VERTICAL_GRADIENT)
- Parameters:
top_color (str)
bottom_color (str)
style (BackgroundStyle)
- Return type:
None
- __post_init__()[source]
Post-initialization validation.
Validates both color formats after the dataclass is initialized. Raises a ValueError if either color is not in a valid format.
- Raises:
ValueError – If either color format is invalid.
- style: BackgroundStyle = 'gradient'
- class streamlit_lightweight_charts_pro.type_definitions.BackgroundSolid[source]
Bases:
Options,ABCSolid background color configuration.
This class represents a solid color background for charts. It provides type safety and validation for color values, ensuring that only valid color formats are accepted.
The class inherits from Options and ABC to provide consistent interface with other chart options and enable proper serialization.
- style
The background style, always set to SOLID for this class.
Example
```python # Create a solid white background bg = BackgroundSolid(color=”#ffffff”)
# Create a solid red background bg = BackgroundSolid(color=”red”)
- Raises:
ValueError – If the color format is invalid.
Note
The color attribute is validated during initialization using the is_valid_color function.
- __init__(color='#ffffff', style=BackgroundStyle.SOLID)
- Parameters:
color (str)
style (BackgroundStyle)
- Return type:
None
- __post_init__()[source]
Post-initialization validation.
Validates the color format after the dataclass is initialized. Raises a ValueError if the color is not in a valid format.
- Raises:
ValueError – If the color format is invalid.
- style: BackgroundStyle = 'solid'
- class streamlit_lightweight_charts_pro.type_definitions.BackgroundStyle[source]
-
Background style enumeration.
Defines how chart backgrounds should be styled. Controls whether backgrounds use solid colors or gradients.
- SOLID
Solid background color.
- VERTICAL_GRADIENT
Vertical gradient background.
- __new__(value)
- SOLID = 'solid'
- VERTICAL_GRADIENT = 'gradient'
- class streamlit_lightweight_charts_pro.type_definitions.ChartType[source]
-
Chart type enumeration.
Defines the available chart types that can be created and rendered. Each chart type corresponds to a specific visualization style and data format requirements.
- AREA
Area chart - filled area below a line.
- BAND
Band chart - multiple lines with fill areas (e.g., Bollinger Bands).
- BASELINE
Baseline chart - values relative to a baseline.
- HISTOGRAM
Histogram chart - bar chart for volume or distribution.
- LINE
Line chart - simple line connecting data points.
- BAR
Bar chart - OHLC bars for price data.
- CANDLESTICK
Candlestick chart - traditional Japanese candlesticks.
- RIBBON
Ribbon chart - upper and lower bands with fill areas.
- GRADIENT_RIBBON
Gradient ribbon chart - ribbon with gradient fills.
- TREND_FILL
Trend fill chart - fills between trend lines and candle body midpoints.
- SIGNAL
Signal chart - background coloring based on signal values.
- __new__(value)
- AREA = 'area'
- BAND = 'band'
- BASELINE = 'baseline'
- HISTOGRAM = 'histogram'
- LINE = 'line'
- BAR = 'bar'
- CANDLESTICK = 'candlestick'
- RIBBON = 'ribbon'
- GRADIENT_RIBBON = 'gradient_ribbon'
- TREND_FILL = 'trend_fill'
- SIGNAL = 'signal'
- class streamlit_lightweight_charts_pro.type_definitions.ColorType[source]
-
Color type enumeration.
Defines how colors should be applied to chart elements. Controls whether colors are solid or use gradient effects.
- SOLID
Solid color - uniform color across the element.
- VERTICAL_GRADIENT
Vertical gradient - color gradient from top to bottom.
- __new__(value)
- SOLID = 'solid'
- VERTICAL_GRADIENT = 'gradient'
- class streamlit_lightweight_charts_pro.type_definitions.ColumnNames[source]
-
Column name enumeration for DataFrame integration.
Defines the standard column names used when converting pandas DataFrames to chart data. These names ensure consistent mapping between DataFrame columns and chart data fields.
- TIME
Time or datetime column.
- OPEN
Open price column (for OHLC data).
- HIGH
High price column (for OHLC data).
- LOW
Low price column (for OHLC data).
- CLOSE
Close price column (for OHLC data).
- VOLUME
Volume column (for OHLCV data).
- DATETIME
Datetime column (alternative to TIME).
- VALUE
Value column (for single-value data like line charts).
- __new__(value)
- TIME = 'time'
- OPEN = 'open'
- HIGH = 'high'
- LOW = 'low'
- CLOSE = 'close'
- VOLUME = 'volume'
- DATETIME = 'datetime'
- VALUE = 'value'
- class streamlit_lightweight_charts_pro.type_definitions.CrosshairMode[source]
Bases:
IntEnumCrosshair mode enumeration.
Defines how the crosshair behaves when hovering over the chart. Controls whether the crosshair snaps to data points or moves freely.
- NORMAL
Normal mode - crosshair moves freely across the chart.
- MAGNET
Magnet mode - crosshair snaps to nearest data points.
- __new__(value)
- NORMAL = 0
- MAGNET = 1
- class streamlit_lightweight_charts_pro.type_definitions.HorzAlign[source]
-
Horizontal alignment enumeration.
Defines horizontal text alignment for labels, annotations, and other text elements on the chart.
- LEFT
Left alignment - text aligned to the left.
- CENTER
Center alignment - text centered horizontally.
- RIGHT
Right alignment - text aligned to the right.
- __new__(value)
- LEFT = 'left'
- CENTER = 'center'
- RIGHT = 'right'
- class streamlit_lightweight_charts_pro.type_definitions.LastPriceAnimationMode[source]
Bases:
IntEnumLast price animation mode enumeration.
Defines how the last price line should be animated when new data is added to the chart.
- DISABLED
No animation - last price line updates instantly.
- CONTINUOUS
Continuous animation - smooth transitions for all updates.
- ON_DATA_UPDATE
Update animation - animation only when new data arrives.
- __new__(value)
- DISABLED = 0
- CONTINUOUS = 1
- ON_DATA_UPDATE = 2
- class streamlit_lightweight_charts_pro.type_definitions.LineStyle[source]
Bases:
IntEnumLine style enumeration.
Defines the visual style of lines in charts, including borders, grid lines, and series lines.
- SOLID
Solid line - continuous line without breaks.
- DOTTED
Dotted line - series of dots.
- DASHED
Dashed line - series of short dashes.
- LARGE_DASHED
Large dashed line - series of long dashes.
- __new__(value)
- SOLID = 0
- DOTTED = 1
- DASHED = 2
- LARGE_DASHED = 3
- class streamlit_lightweight_charts_pro.type_definitions.LineType[source]
Bases:
IntEnumLine type enumeration.
Defines how lines should be drawn between data points. Controls the interpolation method used for line series.
- SIMPLE
Simple line - straight lines between points.
- CURVED
Curved line - smooth curves between points.
- __new__(value)
- SIMPLE = 0
- WITH_STEPS = 1
- CURVED = 2
- class streamlit_lightweight_charts_pro.type_definitions.MarkerPosition[source]
-
Marker position enumeration for chart markers.
Defines where markers should be positioned relative to the data bars or points on the chart.
- ABOVE_BAR
Position marker above the data bar/point.
- BELOW_BAR
Position marker below the data bar/point.
- IN_BAR
Position marker inside the data bar/point.
- __new__(value)
- ABOVE_BAR = 'aboveBar'
- BELOW_BAR = 'belowBar'
- IN_BAR = 'inBar'
- AT_PRICE_TOP = 'atPriceTop'
- AT_PRICE_BOTTOM = 'atPriceBottom'
- AT_PRICE_MIDDLE = 'atPriceMiddle'
- class streamlit_lightweight_charts_pro.type_definitions.MarkerShape[source]
-
Marker shape enumeration for chart markers.
Defines the available shapes for chart markers that can be displayed on charts to highlight specific data points or events.
- CIRCLE
Circular marker shape.
- SQUARE
Square marker shape.
- ARROW_UP
Upward-pointing arrow marker.
- ARROW_DOWN
Downward-pointing arrow marker.
- __new__(value)
- CIRCLE = 'circle'
- SQUARE = 'square'
- ARROW_UP = 'arrowUp'
- ARROW_DOWN = 'arrowDown'
- class streamlit_lightweight_charts_pro.type_definitions.PriceLineSource[source]
-
Price line source enumeration.
Defines the source to use for the value of the price line. Controls which data point determines the price line position.
- LAST_BAR
Last bar - use the last visible bar’s price.
- LAST_VISIBLE
Last visible - use the last visible data point’s price.
- __new__(value)
- LAST_BAR = 'lastBar'
- LAST_VISIBLE = 'lastVisible'
- class streamlit_lightweight_charts_pro.type_definitions.PriceScaleMode[source]
Bases:
IntEnumPrice scale mode enumeration.
Defines how the price scale (y-axis) should be displayed and calculated. Controls the scale type and reference point for price values.
- NORMAL
Normal scale - linear price scale.
- LOGARITHMIC
Logarithmic scale - log-based price scale.
- PERCENTAGE
Percentage scale - values as percentages.
- INDEXED_TO_100
Indexed scale - values relative to 100.
- __new__(value)
- NORMAL = 0
- LOGARITHMIC = 1
- PERCENTAGE = 2
- INDEXED_TO_100 = 3
- class streamlit_lightweight_charts_pro.type_definitions.TooltipPosition[source]
-
Tooltip position enumeration.
Defines how tooltips should be positioned relative to the cursor or chart elements.
- CURSOR
Cursor position - tooltip follows the mouse cursor.
- FIXED
Fixed position - tooltip appears at a fixed location.
- AUTO
Auto position - tooltip position is automatically determined.
- __new__(value)
- CURSOR = 'cursor'
- FIXED = 'fixed'
- AUTO = 'auto'
- class streamlit_lightweight_charts_pro.type_definitions.TooltipType[source]
-
Tooltip type enumeration.
Defines the types of tooltips supported by the system. Each type corresponds to a specific data format and display style.
- OHLC
OHLC tooltip - displays open, high, low, close, and volume data.
- SINGLE
Single value tooltip - displays a single data value.
- MULTI
Multi-series tooltip - displays data from multiple series.
- CUSTOM
Custom tooltip - displays custom content using templates.
- TRADE
Trade tooltip - displays trade information (entry, exit, P&L).
- MARKER
Marker tooltip - displays marker-specific information.
- __new__(value)
- OHLC = 'ohlc'
- SINGLE = 'single'
- MULTI = 'multi'
- CUSTOM = 'custom'
- TRADE = 'trade'
- MARKER = 'marker'
- class streamlit_lightweight_charts_pro.type_definitions.TrackingActivationMode[source]
-
Tracking activation mode enumeration.
Defines when the tracking mode should be activated.
- ON_MOUSE_ENTER
Activate tracking mode when mouse enters chart.
- ON_TOUCH_START
Activate tracking mode when touch starts.
- __new__(value)
- ON_MOUSE_ENTER = 'ON_MOUSE_ENTER'
- ON_TOUCH_START = 'ON_TOUCH_START'
- class streamlit_lightweight_charts_pro.type_definitions.TrackingExitMode[source]
-
Tracking exit mode enumeration.
Defines when the tracking mode should exit.
- EXIT_ON_MOVE
Exit tracking mode when mouse moves.
- EXIT_ON_CROSS
Exit tracking mode when crosshair crosses series.
- NEVER_EXIT
Never exit tracking mode automatically.
- __new__(value)
- EXIT_ON_MOVE = 'EXIT_ON_MOVE'
- EXIT_ON_CROSS = 'EXIT_ON_CROSS'
- NEVER_EXIT = 'NEVER_EXIT'
- class streamlit_lightweight_charts_pro.type_definitions.TradeType[source]
-
Trade type enumeration.
Defines the direction of a trade (long or short). Used for trade visualization and profit/loss calculations.
- LONG
Long trade - profit when price goes up.
- SHORT
Short trade - profit when price goes down.
- __new__(value)
- LONG = 'long'
- SHORT = 'short'
- class streamlit_lightweight_charts_pro.type_definitions.TradeVisualization[source]
-
Trade visualization style enumeration.
Defines how trades should be visualized on the chart. Multiple visualization styles can be combined to create comprehensive trade displays.
- MARKERS
Display entry/exit markers only.
- RECTANGLES
Display rectangle spanning from entry to exit.
- BOTH
Display both markers and rectangles.
- LINES
Display connecting lines between entry and exit.
- ARROWS
Display directional arrows from entry to exit.
- ZONES
Display colored zones with transparency around trades.
- __new__(value)
- MARKERS = 'markers'
- RECTANGLES = 'rectangles'
- BOTH = 'both'
- LINES = 'lines'
- ARROWS = 'arrows'
- ZONES = 'zones'
- class streamlit_lightweight_charts_pro.type_definitions.VertAlign[source]
-
Vertical alignment enumeration.
Defines vertical text alignment for labels, annotations, and other text elements on the chart.
- TOP
Top alignment - text aligned to the top.
- CENTER
Center alignment - text centered vertically.
- BOTTOM
Bottom alignment - text aligned to the bottom.
- __new__(value)
- TOP = 'top'
- CENTER = 'center'
- BOTTOM = 'bottom'
Type Categories
The type system is organized into:
Chart Types: Basic chart configuration and options
Series Types: Different data series configurations (line, area, candlestick, etc.)
Style Types: Styling and appearance options
Data Types: Data structure definitions
Event Types: User interaction event types
Usage Example
from streamlit_lightweight_charts_pro.type_definitions import (
ChartOptions,
SeriesType,
LineStyle
)
options: ChartOptions = {
'height': 400,
'layout': {
'background': {'color': '#ffffff'},
'textColor': '#333333'
}
}