import plotly.graph_objects as go
import plotly.io as pio

# Data
dates = ["2025-05-27", "2025-05-28", "2025-05-29", "2025-05-30", "2025-05-31", "2025-06-01", "2025-06-02"]
completion_rates = [70.0, 75.0, 60.0, 60.0, 70.0, 65.0, 75.0]
overall_average = 67.86

# Create the line chart
fig = go.Figure()

# Add main line with markers using brand color
fig.add_trace(go.Scatter(
    x=dates,
    y=completion_rates,
    mode='lines+markers',
    line=dict(color='#1FB8CD', width=3),
    marker=dict(size=8, color='#1FB8CD'),
    name='Completion Rate',
    cliponaxis=False
))

# Add horizontal average line
fig.add_hline(
    y=overall_average,
    line_dash="dash",
    line_color="red",
    line_width=2
)

# Update layout
fig.update_layout(
    title="Habit Completion Rate by Day",
    xaxis_title="Date",
    yaxis_title="Completion Rate (%)",
    yaxis=dict(range=[0, 100]),
    showlegend=False
)

# Save the chart
fig.write_image("habit_completion_chart.png")