Spaces:
Sleeping
Sleeping
import pandas as pd | |
import plotly.graph_objects as go | |
def plot_sales_tool(file_path: str, date_col: str = "Month") -> str: | |
""" | |
Builds an interactive Plotly line chart for Sales. | |
Saves a PNG fallback (sales_plot.png) for Streamlit thumbnail. | |
""" | |
df = pd.read_csv(file_path) | |
if date_col not in df.columns or "Sales" not in df.columns: | |
return f"β '{date_col}' or 'Sales' column missing." | |
fig = go.Figure( | |
go.Scatter( | |
x=df[date_col], | |
y=df["Sales"], | |
mode="lines+markers", | |
line=dict(width=2), | |
) | |
) | |
fig.update_layout(title="Sales Trend", template="plotly_dark") | |
fig.write_image("sales_plot.png") # still save for PNG fallback | |
return fig | |