Year Quarter analysis Quarter on Quarter

Hello community. Have followed the docs and tutorials but somehow when I plot - the graph is empty. I want to do a quarterly view for one year. My filtered data does return the correct view. However plot is empty. code below:

avos['year'] = avos['date'].dt.year
avos['quarter'] = avos['date'].dt.quarter
avos['quarter'] = avos['date'].dt.to_period('Q')
quarterly_data = df.groupby(['year', 'quarter'])['total_volume'].sum().reset_index()
quarterly_data
selected_year = 2015  # Replace with your selected year
filtered_data = quarterly_data[quarterly_data['year'] == selected_year]
filtered_data


year	quarter	total_volume
0	2015	2015Q1	3.679696e+08
1	2015	2015Q2	4.010053e+08
2	2015	2015Q3	3.653920e+08
3	2015	2015Q4	3.244999e+08



fig = go.Figure()

fig.add_trace(go.Bar(
    x=filtered_data["quarter"].dt.end_time,  # Align to the start of each quarter
    y=filtered_data["total_volume"],
    xperiod="Q1",
    xperiodalignment="start",  # Align periods to the start
))

# Customize the layout
fig.update_layout(
    title=f"Total Value per Quarter for {selected_year}",
    xaxis_title="Quarter",
    yaxis_title="Total Value",
)

fig.update_xaxes(dtick="M3", tickformat="Q%q'%y")

# Show the plot
fig.show()

Update here: I was able to resolve this for my simple use-case. However I am not really happy with it - as I feel I werenโ€™t able to make the code work using the native datetime and period objects used within python and plotly.

    avos['quarter'] = avos['date'].dt.to_period('Q').astype(str)
    quarterly_data = avos.groupby(['year', 'quarter', 'type'])['total_volume'].median().reset_index()
    filtered_data = quarterly_data[(quarterly_data['year'] == year_selected) & (quarterly_data['type'] == type_selected)]


    fig = go.Figure(go.Bar(
        x=filtered_data["quarter"], 
        y=filtered_data["total_volume"],
    ))

    fig.update_layout(
        title="Total Value per Quarter",
        xaxis_title="Quarter",
        yaxis_title="Quarterly Volume",
        template="simple_white",
    )

    quarterly_figure = fig

newplot (1)