trading-tools / web /components /chart_viewer.py
Deploy Bot
Deploy Trading Analysis Platform to HuggingFace Spaces
a1bf219
"""
Chart viewer component for displaying candlestick charts.
"""
from pathlib import Path
from typing import Optional
import gradio as gr
def create_chart_viewer() -> gr.Image:
"""
Create chart viewer component.
Returns:
Gradio Image component for displaying charts
"""
return gr.Image(
label="Candlestick Chart",
type="filepath",
interactive=False,
show_label=True,
)
def display_chart(chart_path: Optional[str]) -> Optional[str]:
"""
Prepare chart for display.
Args:
chart_path: Path to chart image
Returns:
Chart path if exists, None otherwise
"""
if not chart_path:
return None
chart_file = Path(chart_path)
if not chart_file.exists():
return None
return str(chart_file)
def create_placeholder_message() -> str:
"""
Create placeholder message when no chart is available.
Returns:
Placeholder text
"""
return "Chart will appear here after analysis completes..."