first of stack chart dataset django

PHOTO EMBED

Tue Mar 29 2022 14:27:18 GMT+0000 (Coordinated Universal Time)

Saved by @jacopo #python

if grouped:
    last_value = None
    for obj in data["datasets"]:
        if obj["stack"] == last_value:
            obj["first_of_stack"] = ""
        else:
            obj["first_of_stack"] = True
        last_value = obj["stack"]
        
        
data["datasets"].append(
                {
                    "data": labels,
                    "label": el.name,
                    "backgroundColor": el.color,
                    "info": ...,
                    "date": f"{report_month:02d}/{str(report_year)[-2:]}",
                    "stack": f"Report {report_pk}",
                    "first_of_stack": "",
                }
            )
content_copyCOPY