Plotly go.Scatter relayoutData error

Hi. Work according to https://dash.plotly.com/interactive-graphing?_gl=11dby6hv_gaMTIxMTkxNzA0Ni4xNzAxNDMyOTAz_ga_6G7EE0JNSC*MTcxMDI0NDQ0Ni4yMC4xLjE3MTAyNDY0MTEuNjAuMC4w
I have graph:

def plot_updated(df, group_by, param1, param2):
    
    df['bet_ts'] = pd.to_datetime(df['bet_ts'])
    group_by == 'bet_ts' 
    fig = go.Figure()
    params = [plot_param1, plot_param2]
    for _, param in enumerate(params):
        cum_sum = df.groupby(group_by)[param].sum().reset_index()       
        fig.add_trace(go.Scatter(x=cum_sum[group_by],
                                 y=cum_sum[param], 
                                 mode='lines+markers',  
                                 name=param,
                                 marker=dict(color=color, size=3),
                                 hovertemplate='<extra></extra>',))
    fig.update_layout(
        xaxis_title=group_by,
        yaxis_title='PNL',
        legend=dict(x=1, y=1, traceorder='normal'),
        xaxis=dict(type='category'),
    )
    x_start = min(cum_sum[group_by_label])     
    x_end = max(cum_sum[group_by_label])
    # fig.show()
    return fig, x_start, x_end

and ag-grid:

def create_dash_aggrid(df, x_start, x_end):
    currency_columns = ['size', pnl', 'liability']
    df_filtered = df[(df['bet_ts'] >= x_start) & (df['bet_ts'] <= x_end)]

    columnDefs=[{'headerName': col, 'field': col, 'valueFormatter': {"function": "'Ā£' + (params.value.toFixed(2))"}} if col in currency_columns
                else {'headerName': col, 'field': col} for col in df.columns
    ]
    ag_grid = dag.AgGrid(
        id="ag-grid",,
        rowData=df_filtered.to_dict("records"),
        columnDefs=columnDefs,
        dashGridOptions={"pagination": True,  "paginationPageSize": 100,  )

    return ag_grid

I have small dash.app with:

app.layout = html.Div([
    dcc.Graph(
        id='scatter1',
        figure=fig1,
    ),
    html.Div(children=[], id='relayoutdata'),
    html.Div(children=[grid],
             id='ag-grid-div'),
])

only ag-grid and graph in app.
I want to connect graph with ag-grid. use callback:

@app.callback(
    [Output('relayoutdata', 'children'),
    Output('ag-grid-div', 'children')],
    [Input('scatter1', 'relayoutData')],
    prevent_initial_call=True
)
def update_grid(relayout_data):
    rd_raw_from = relayout_data.get('xaxis.range[0]', None)
    rd_raw_to = relayout_data.get('xaxis.range[1]', None)
    print(rd_raw_from, rd_raw_to)

    str_rd_raw_from = str(rd_raw_from) if rd_raw_from else None
    str_rd_raw_to = str(rd_raw_to) if rd_raw_to else None
    try:
        relayoutData_from = datetime.strptime(rd_raw_from,'%Y-%m-%d %H:%M:%S.%f') if rd_raw_from else None
    except ValueError:
        relayoutData_from = datetime.strptime(rd_raw_from,'%Y-%m-%d') if rd_raw_from else None
    try:
        relayoutData_to = datetime.strptime(rd_raw_to,'%Y-%m-%d %H:%M:%S.%f') if rd_raw_to else None
    except ValueError:
        relayoutData_to = datetime.strptime(rd_raw_to,'%Y-%m-%d') if rd_raw_to else None
    output = f'{relayoutData_from}, {relayoutData_to}'
    print(relayoutData_from, relayoutData_to)
    if rd_raw_from != None or rd_raw_to != None:
        return output, create_dash_aggrid(data_df, relayoutData_from, relayoutData_to)
    else:
        return no_update, no_update

for example rd_raw_from, rd_raw_to = 183.47803981884988 348.38447406647873(float). If I use: str_rd_raw_from = str(rd_raw_from) if rd_raw_from else None
str_rd_raw_to = str(rd_raw_to) if rd_raw_to else None
its also dont work.
do it by analogy of this: https://gist.github.com/radupm/46913b8b567444785e132f25313b6cfd
My graph x-coord: timestamp


Why i get rd_raw_from, rd_raw_to = 183.47803981884988 348.38447406647873. not timestamp
How to decide it? Thanks

if use state - figure:

@app.callback(
    [Output('relayoutdata', 'children'),
    Output('ag-grid-div', 'children')],
    [Input('scatter1', 'relayoutData')],
    State('scatter1', 'figure'),
    prevent_initial_call=True
)

similar data
state: [59.405579765872005, 262.7901820046142]
59.405579765872005 262.7901820046142

Iā€™m guessing a bit, but I wonder whether

xaxis=dict(type='category')

might not work well with a datetime axis?

Yes, indeed, it solved the problem with range. thanks

state: [ā€˜2023-05-14 10:25:21.6302ā€™, ā€˜2023-05-19 19:27:42.7373ā€™]
2023-05-14 10:25:21.6302 2023-05-19 19:27:42.7373

Iā€™m going to test the data now