weaveworks / grafanalib

Python library for building Grafana dashboards
Apache License 2.0
1.86k stars 309 forks source link

TimeSeries showLegend defaults to False #582

Open Gnappuraz opened 1 year ago

Gnappuraz commented 1 year ago

What you expected to happen?

A TimeSeries object that has any of legendDisplayMode, legendPlacement, legendCalcs set, should show the legend panel automatically, or allow the flag to be set as ctor parameter.

What happened?

If any of the above is set, the legend becomes hidden.

Screenshot 2023-05-04 at 16 05 56

If manually enabled it will show the legend correctly set with all its attributes.

Screenshot 2023-05-04 at 16 06 11

How to reproduce it?

TimeSeries(
        title="some title",
        dataSource="any test datasource",
        targets="any test target",
        legendDisplayMode="table",
        legendPlacement="bottom",
        legendCalcs=["mean", "lastNotNull", "max"])

Adding

extraJson={
            "options": {
                "legend": {
                    "showLegend": True,
                }
            }
        }

as ctor param shows the legend correctly.

If confirmed I'll be happy to contribute with a PR to fix the issue.