Skip to content

Overly-strict validation for TimeSeries.legendCalcs #690

@JoshKarpel

Description

@JoshKarpel

The TimeSeries.legendCalcs field validates the values that can go in its list:

grafanalib/grafanalib/core.py

Lines 2315 to 2342 in 3ed1a9c

legendCalcs = attr.ib(
factory=list,
validator=attr.validators.deep_iterable(
member_validator=in_([
'lastNotNull',
'min',
'mean',
'max',
'last',
'firstNotNull',
'first',
'sum',
'count',
'range',
'delta',
'step',
'diff',
'logmin',
'allIsZero',
'allIsNull',
'changeCount',
'distinctCount',
'diffperc',
'allValues'
]),
iterable_validator=instance_of(list),
),
)

Other chart types don't, e.g. BarChart:

legendCalcs = attr.ib(factory=list, validator=instance_of(list))

At least on my Grafana instance, there are more legend calculations available, such as p95 (not sure if this a plugin or just some new feature that's been added since the code was originally written). It would be convenient if this client-side validation was dropped, in case the user's Grafana has more options available.

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