Timestamp xaxis bars thin when frequenxy become uneven

I use a plain timestamp for xpos for my graphs, and it looks great if interval is even:


But if interval is uneven with reruns, the bars become thinner the less the interval become:

How can I just stack them up,

  "xpos": [
    "2023-12-26T06:10",
    "2023-12-27T06:10",
    "2023-12-28T06:10",
    "2023-12-29T06:10",
    "2023-12-30T06:10",
    "2023-12-31T06:10",
    "2024-01-01T06:10",
    "2024-01-02T06:10",
    "2024-01-03T06:10",
    "2024-01-04T06:10",
    "2024-01-05T06:10",
    "2024-01-06T06:10",
    "2024-01-07T06:10",
    "2024-01-08T06:10",
    "2024-01-09T06:10",
    "2024-01-10T06:10",
    "2024-01-11T06:10",
    "2024-01-11T12:10",
    "2024-01-11T15:35",
    "2024-01-12T06:10"
  ]
    fig = go.Figure(
        data = [
            go.Bar(name="Success", x=data['xpos'], y=data['success_count'], marker={'color':'green'}, text=data['success_tests'], textposition='none'),
            go.Bar(name="Failed", x=data['xpos'], y=data['failed_count'], marker={'color':'red'}, text=data['failed_tests'], textposition='none')
        ],
        layout = go.Layout(barmode='stack')
    )

    for i,px in enumerate(data['xpos']):
        nice = timegraph['nice'][i]
        fig.add_annotation(x=px, xshift=10, y=0, yshift=80, text=f"{px} - {nice}", textangle=270, bgcolor="#FFFFFF")
    

    fig.add_trace(
        go.Scatter(
            x=data['xpos'],
            y=timegraph['ygrid'],
            yaxis="y2",
            name="Total Testrun Time",
            marker={'color': 'gray', 'size': 15},
            text=timegraph['nice'],
            mode='markers'
        )
    )
    fig.update_layout(
        plot_bgcolor=plot_bgcolor,
        paper_bgcolor=plot_bgcolor,
        yaxis = {
            'title':{'text':"Number of Tests"},
            'side':"left",
            'color': 'green',
            'gridcolor': 'green'
        },
        yaxis2 = {
            'title':{'text':"Total Testrun Time(s)"},
            'side': "right",
            'overlaying': "y",
            'color': 'gray',
            'showgrid': False,
            'tickformat': '%M:%S'
        },
        title=f"TestHistory for {desc}<br>{sr}</br>(rendertime:{time.time()-starttime:.2f}sec)",
    )
    fig.update_xaxes(showticklabels=False)

    return fig.to_html(config={'displayModeBar': False})

Hey @mortenb123 welcome to the forums.

This is because the x-pos values get interpreted as timestamp and a time axis is used. If there are gaps in your data, this is shown as is in the graph. Try specifying the axis type as category:

layout = go.Layout(barmode='stack', xaxis= {'type': 'category'})
1 Like