Skip to content

Bar chart with facet_row only rendering data for one facet #3715

@brylie

Description

@brylie

I have a bar chart with a facet_row defined as follows, with example data.

Example code and data for `facet_row` bug
tmp_data = [
    {
        "date": "2022-04-17",
        "role_name": "Nurse",
        "work_type": "Cleaning",
        "daily_total_minutes": 45,
        "percent_of_daily_role_total_minutes": 0.41,  
    },
    {
        "date": "2022-04-17",
        "role_name": "Nurse",
        "work_type": "Food preparation",
        "percent_of_daily_role_total_minutes": 0.59,  
    },
    {
        "date": "2022-04-17",
        "role_name": "Volunteer",
        "work_type": "Cleaning",
        "percent_of_daily_role_total_minutes": 0.26,  
    },
    {
        "date": "2022-04-17",
        "role_name": "Volunteer",
        "work_type": "Food preparation",
        "percent_of_daily_role_total_minutes": 0.74,  
    },
    {
        "date": "2022-05-06",
        "role_name": "Volunteer",
        "work_type": "Food preparation",
        "percent_of_daily_role_total_minutes": 1.0,  
    },
    {
        "date": "2022-05-07",
        "role_name": "Volunteer",
        "work_type": "Cleaning",
        "percent_of_daily_role_total_minutes": 0.49,  
    },
    {
        "date": "2022-05-07",
        "role_name": "Volunteer",
        "work_type": "Food preparation",
        "percent_of_daily_role_total_minutes": 0.51,  
    },
]

daily_work_by_caregiver_role_and_type_with_percent_chart = px.bar(
    tmp_data,
    x="date",
    y="percent_of_daily_role_total_minutes",
    facet_row="role_name",
    color="work_type",
    title=_("Daily work percent by caregiver role and work type"),
    labels={
        "role_name": _("Caregiver role"),
        "percent_of_daily_role_total_minutes": _("Work percent"),
        "work_type": _("Type of work"),
    },
    text_auto=True,
)
daily_work_by_caregiver_role_and_type_with_percent_chart.layout.yaxis.tickformat = ",.0%"

# render the chart
daily_work_by_caregiver_role_and_type_with_percent_chart.to_html()

When rendering the chart, the x axis correctly determines the data are dates and the y-axis on the bottom facet is correctly formatted as a percentage with the data rendering. However, the top facet doesn't render any data.

image

I have tried both with and without specifying the yaxis.tickformat and get a similar result, where the first facet series doesn't render any data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions