Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added extra fields to TimeSeries panel #674

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions grafanalib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,10 @@ class TimeSeries(Panel):
:param legendCalcs: which calculations should be displayed in the legend. Defaults to an empty list.
Possible values are: allIsNull, allIsZero, changeCount, count, delta, diff, diffperc,
distinctCount, firstNotNull, max, mean, min, logmin, range, step, total. For more information see
:param legendSortBy: what to sort legend based on.
Possible values are same as legendCalcs values
:param legendSortByOrder: In what order to sort legend
Possible values: ascending, descending
:param lineInterpolation: line interpolation
linear (Default), smooth, stepBefore, stepAfter
:param lineWidth: line width, default 1
Expand All @@ -2297,6 +2301,7 @@ class TimeSeries(Panel):
:param tooltipSort: To sort the tooltips
none (Default), asc, desc
:param unit: units
:param noValue: text to display when there is nothing to display
:param thresholdsStyleMode: thresholds style mode off (Default), area, line, line+area
:param valueMin: Minimum value for Panel
:param valueMax: Maximum value for Panel
Expand Down Expand Up @@ -2342,6 +2347,33 @@ class TimeSeries(Panel):
iterable_validator=instance_of(list),
),
)
legendSortBy = attr.ib(
default = '',
validator=in_([
'',
'lastNotNull',
'min',
'mean',
'max',
'last',
'firstNotNull',
'first',
'sum',
'count',
'range',
'delta',
'step',
'diff',
'logmin',
'allIsZero',
'allIsNull',
'changeCount',
'distinctCount',
'diffperc',
'allValues'
]),
)
legendSortByOrder = attr.ib(default='ascending', validator=in_(['ascending','descending']))
lineInterpolation = attr.ib(default='linear', validator=instance_of(str))
lineWidth = attr.ib(default=1, validator=instance_of(int))
mappings = attr.ib(default=attr.Factory(list))
Expand All @@ -2355,6 +2387,7 @@ class TimeSeries(Panel):
tooltipMode = attr.ib(default='single', validator=instance_of(str))
tooltipSort = attr.ib(default='none', validator=instance_of(str))
unit = attr.ib(default='', validator=instance_of(str))
noValue = attr.ib(default='', validator=instance_of(str))
thresholdsStyleMode = attr.ib(default='off', validator=instance_of(str))

valueMin = attr.ib(default=None, validator=attr.validators.optional(instance_of(int)))
Expand Down Expand Up @@ -2403,15 +2436,18 @@ def to_json_data(self):
"min": self.valueMin,
"max": self.valueMax,
"decimals": self.valueDecimals,
'unit': self.unit
'unit': self.unit,
'noValue': self.noValue
},
'overrides': self.overrides
},
'options': {
'legend': {
'displayMode': self.legendDisplayMode,
'placement': self.legendPlacement,
'calcs': self.legendCalcs
'calcs': self.legendCalcs,
'sortBy': self.legendSortBy,
'sortDesc': True if self.legendSortByOrder == 'descending' else False
},
'tooltip': {
'mode': self.tooltipMode,
Expand Down