{ /** * Create a [bar gauge panel](https://grafana.com/docs/grafana/latest/panels/visualizations/bar-gauge-panel/), * * @name barGaugePanel.new * * @param title Panel title. * @param description Panel description. * @param datasource Panel datasource. * @param unit The unit of the data. * @param thresholds An array of threashold values. * * @method addTarget(target) Adds a target object. * @method addTargets(targets) Adds an array of targets. */ new( title, description=null, datasource=null, unit=null, thresholds=[], ):: { type: 'bargauge', title: title, [if description != null then 'description']: description, datasource: datasource, targets: [ ], fieldConfig: { defaults: { unit: unit, thresholds: { mode: 'absolute', steps: thresholds, }, }, }, _nextTarget:: 0, addTarget(target):: self { // automatically ref id in added targets. local nextTarget = super._nextTarget, _nextTarget: nextTarget + 1, targets+: [target { refId: std.char(std.codepoint('A') + nextTarget) }], }, addTargets(targets):: std.foldl(function(p, t) p.addTarget(t), targets, self), }, }