module.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. import _ from 'lodash';
  2. import $ from 'jquery';
  3. import 'vendor/flot/jquery.flot';
  4. import 'vendor/flot/jquery.flot.gauge';
  5. import 'app/features/panel/panellinks/link_srv';
  6. import {
  7. LegacyResponseData,
  8. getFlotPairs,
  9. getDisplayProcessor,
  10. convertOldAngulrValueMapping,
  11. getColorFromHexRgbOrName,
  12. } from '@grafana/ui';
  13. import kbn from 'app/core/utils/kbn';
  14. import config from 'app/core/config';
  15. import { MetricsPanelCtrl } from 'app/plugins/sdk';
  16. import {
  17. DataFrame,
  18. FieldType,
  19. reduceField,
  20. ReducerID,
  21. Field,
  22. GraphSeriesValue,
  23. DisplayValue,
  24. fieldReducers,
  25. KeyValue,
  26. } from '@grafana/data';
  27. import { auto } from 'angular';
  28. import { LinkSrv, LinkModel } from 'app/features/panel/panellinks/link_srv';
  29. import { PanelQueryRunnerFormat } from 'app/features/dashboard/state/PanelQueryRunner';
  30. import { getProcessedDataFrames } from 'app/features/dashboard/state/PanelQueryState';
  31. const BASE_FONT_SIZE = 38;
  32. export interface ShowData {
  33. field: Field;
  34. value: any;
  35. sparkline: GraphSeriesValue[][];
  36. display: DisplayValue;
  37. scopedVars: any;
  38. thresholds: any[];
  39. colorMap: any;
  40. }
  41. class SingleStatCtrl extends MetricsPanelCtrl {
  42. static templateUrl = 'module.html';
  43. data: Partial<ShowData> = {};
  44. fontSizes: any[];
  45. unitFormats: any[];
  46. fieldNames: string[] = [];
  47. invalidGaugeRange: boolean;
  48. panel: any;
  49. events: any;
  50. valueNameOptions: any[] = [
  51. { value: 'min', text: 'Min' },
  52. { value: 'max', text: 'Max' },
  53. { value: 'avg', text: 'Average' },
  54. { value: 'current', text: 'Current' },
  55. { value: 'total', text: 'Total' },
  56. { value: 'name', text: 'Name' },
  57. { value: 'first', text: 'First' },
  58. { value: 'delta', text: 'Delta' },
  59. { value: 'diff', text: 'Difference' },
  60. { value: 'range', text: 'Range' },
  61. { value: 'last_time', text: 'Time of last point' },
  62. ];
  63. // Set and populate defaults
  64. panelDefaults: any = {
  65. links: [],
  66. datasource: null,
  67. maxDataPoints: 100,
  68. interval: null,
  69. targets: [{}],
  70. cacheTimeout: null,
  71. format: 'none',
  72. prefix: '',
  73. postfix: '',
  74. nullText: null,
  75. valueMaps: [{ value: 'null', op: '=', text: 'N/A' }],
  76. mappingTypes: [{ name: 'value to text', value: 1 }, { name: 'range to text', value: 2 }],
  77. rangeMaps: [{ from: 'null', to: 'null', text: 'N/A' }],
  78. mappingType: 1,
  79. nullPointMode: 'connected',
  80. valueName: 'avg',
  81. prefixFontSize: '50%',
  82. valueFontSize: '80%',
  83. postfixFontSize: '50%',
  84. thresholds: '',
  85. colorBackground: false,
  86. colorValue: false,
  87. colors: ['#299c46', 'rgba(237, 129, 40, 0.89)', '#d44a3a'],
  88. sparkline: {
  89. show: false,
  90. full: false,
  91. ymin: null,
  92. ymax: null,
  93. lineColor: 'rgb(31, 120, 193)',
  94. fillColor: 'rgba(31, 118, 189, 0.18)',
  95. },
  96. gauge: {
  97. show: false,
  98. minValue: 0,
  99. maxValue: 100,
  100. thresholdMarkers: true,
  101. thresholdLabels: false,
  102. },
  103. tableColumn: '',
  104. };
  105. /** @ngInject */
  106. constructor($scope: any, $injector: auto.IInjectorService, private linkSrv: LinkSrv, private $sanitize: any) {
  107. super($scope, $injector);
  108. _.defaults(this.panel, this.panelDefaults);
  109. this.events.on('data-received', this.onDataReceived.bind(this));
  110. this.events.on('data-error', this.onDataError.bind(this));
  111. this.events.on('data-snapshot-load', this.onDataReceived.bind(this));
  112. this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
  113. this.dataFormat = PanelQueryRunnerFormat.frames;
  114. this.onSparklineColorChange = this.onSparklineColorChange.bind(this);
  115. this.onSparklineFillChange = this.onSparklineFillChange.bind(this);
  116. }
  117. onInitEditMode() {
  118. this.fontSizes = ['20%', '30%', '50%', '70%', '80%', '100%', '110%', '120%', '150%', '170%', '200%'];
  119. this.addEditorTab('Options', 'public/app/plugins/panel/singlestat/editor.html', 2);
  120. this.addEditorTab('Value Mappings', 'public/app/plugins/panel/singlestat/mappings.html', 3);
  121. this.unitFormats = kbn.getUnitFormats();
  122. }
  123. migrateToGaugePanel(migrate: boolean) {
  124. if (migrate) {
  125. this.onPluginTypeChange(config.panels['gauge']);
  126. } else {
  127. this.panel.gauge.show = false;
  128. this.render();
  129. }
  130. }
  131. setUnitFormat(subItem: { value: any }) {
  132. this.panel.format = subItem.value;
  133. this.refresh();
  134. }
  135. onDataError(err: any) {
  136. this.handleDataFrames([]);
  137. }
  138. // This should only be called from the snapshot callback
  139. onDataReceived(dataList: LegacyResponseData[]) {
  140. this.handleDataFrames(getProcessedDataFrames(dataList));
  141. }
  142. // Directly support DataFrame skipping event callbacks
  143. handleDataFrames(frames: DataFrame[]) {
  144. const { panel } = this;
  145. super.handleDataFrames(frames);
  146. this.loading = false;
  147. const distinct = getDistinctNames(frames);
  148. let fieldInfo = distinct.byName[panel.tableColumn]; //
  149. this.fieldNames = distinct.names;
  150. if (!fieldInfo) {
  151. fieldInfo = distinct.first;
  152. }
  153. if (!fieldInfo) {
  154. // When we don't have any field
  155. this.data = {
  156. value: 'No Data',
  157. display: {
  158. text: 'No Data',
  159. numeric: NaN,
  160. },
  161. };
  162. } else {
  163. this.data = this.processField(fieldInfo);
  164. }
  165. this.render();
  166. }
  167. processField(fieldInfo: FieldInfo) {
  168. const { panel, dashboard } = this;
  169. const name = fieldInfo.field.config.title || fieldInfo.field.name;
  170. let calc = panel.valueName;
  171. let calcField = fieldInfo.field;
  172. let val: any = undefined;
  173. if ('name' === calc) {
  174. val = name;
  175. } else {
  176. if ('last_time' === calc) {
  177. if (fieldInfo.frame.firstTimeField) {
  178. calcField = fieldInfo.frame.firstTimeField;
  179. calc = ReducerID.last;
  180. }
  181. }
  182. // Normalize functions (avg -> mean, etc)
  183. const r = fieldReducers.getIfExists(calc);
  184. if (r) {
  185. calc = r.id;
  186. // With strings, don't accidentally use a math function
  187. if (calcField.type === FieldType.string) {
  188. const avoid = [ReducerID.mean, ReducerID.sum];
  189. if (avoid.includes(calc)) {
  190. calc = panel.valueName = ReducerID.first;
  191. }
  192. }
  193. } else {
  194. calc = ReducerID.lastNotNull;
  195. }
  196. // Calculate the value
  197. val = reduceField({
  198. field: calcField,
  199. reducers: [calc],
  200. })[calc];
  201. }
  202. const processor = getDisplayProcessor({
  203. field: {
  204. ...fieldInfo.field.config,
  205. unit: panel.format,
  206. decimals: panel.decimals,
  207. mappings: convertOldAngulrValueMapping(panel),
  208. },
  209. theme: config.theme,
  210. isUtc: dashboard.isTimezoneUtc && dashboard.isTimezoneUtc(),
  211. });
  212. const data = {
  213. field: fieldInfo.field,
  214. value: val,
  215. display: processor(val),
  216. scopedVars: _.extend({}, panel.scopedVars),
  217. };
  218. data.scopedVars['__name'] = name;
  219. panel.tableColumn = this.fieldNames.length > 1 ? name : '';
  220. // Get the fields for a sparkline
  221. if (panel.sparkline && panel.sparkline.show && fieldInfo.frame.firstTimeField) {
  222. this.data.sparkline = getFlotPairs({
  223. xField: fieldInfo.frame.firstTimeField,
  224. yField: fieldInfo.field,
  225. nullValueMode: panel.nullPointMode,
  226. });
  227. }
  228. return data;
  229. }
  230. canModifyText() {
  231. return !this.panel.gauge.show;
  232. }
  233. setColoring(options: { background: any }) {
  234. if (options.background) {
  235. this.panel.colorValue = false;
  236. this.panel.colors = ['rgba(71, 212, 59, 0.4)', 'rgba(245, 150, 40, 0.73)', 'rgba(225, 40, 40, 0.59)'];
  237. } else {
  238. this.panel.colorBackground = false;
  239. this.panel.colors = ['rgba(50, 172, 45, 0.97)', 'rgba(237, 129, 40, 0.89)', 'rgba(245, 54, 54, 0.9)'];
  240. }
  241. this.render();
  242. }
  243. invertColorOrder() {
  244. const tmp = this.panel.colors[0];
  245. this.panel.colors[0] = this.panel.colors[2];
  246. this.panel.colors[2] = tmp;
  247. this.render();
  248. }
  249. onColorChange(panelColorIndex: number) {
  250. return (color: string) => {
  251. this.panel.colors[panelColorIndex] = color;
  252. this.render();
  253. };
  254. }
  255. onSparklineColorChange(newColor: string) {
  256. this.panel.sparkline.lineColor = newColor;
  257. this.render();
  258. }
  259. onSparklineFillChange(newColor: string) {
  260. this.panel.sparkline.fillColor = newColor;
  261. this.render();
  262. }
  263. removeValueMap(map: any) {
  264. const index = _.indexOf(this.panel.valueMaps, map);
  265. this.panel.valueMaps.splice(index, 1);
  266. this.render();
  267. }
  268. addValueMap() {
  269. this.panel.valueMaps.push({ value: '', op: '=', text: '' });
  270. }
  271. removeRangeMap(rangeMap: any) {
  272. const index = _.indexOf(this.panel.rangeMaps, rangeMap);
  273. this.panel.rangeMaps.splice(index, 1);
  274. this.render();
  275. }
  276. addRangeMap() {
  277. this.panel.rangeMaps.push({ from: '', to: '', text: '' });
  278. }
  279. link(scope: any, elem: JQuery, attrs: any, ctrl: any) {
  280. const $location = this.$location;
  281. const linkSrv = this.linkSrv;
  282. const $timeout = this.$timeout;
  283. const $sanitize = this.$sanitize;
  284. const panel = ctrl.panel;
  285. const templateSrv = this.templateSrv;
  286. let linkInfo: LinkModel | null = null;
  287. const $panelContainer = elem.find('.panel-container');
  288. elem = elem.find('.singlestat-panel');
  289. function applyColoringThresholds(valueString: string) {
  290. const data = ctrl.data;
  291. const color = getColorForValue(data, data.value);
  292. if (color) {
  293. return '<span style="color:' + color + '">' + valueString + '</span>';
  294. }
  295. return valueString;
  296. }
  297. function getSpan(className: string, fontSizePercent: string, applyColoring: any, value: string) {
  298. value = $sanitize(templateSrv.replace(value, ctrl.data.scopedVars));
  299. value = applyColoring ? applyColoringThresholds(value) : value;
  300. const pixelSize = (parseInt(fontSizePercent, 10) / 100) * BASE_FONT_SIZE;
  301. return '<span class="' + className + '" style="font-size:' + pixelSize + 'px">' + value + '</span>';
  302. }
  303. function getBigValueHtml() {
  304. const data: ShowData = ctrl.data;
  305. let body = '<div class="singlestat-panel-value-container">';
  306. if (panel.prefix) {
  307. body += getSpan('singlestat-panel-prefix', panel.prefixFontSize, panel.colorPrefix, panel.prefix);
  308. }
  309. body += getSpan('singlestat-panel-value', panel.valueFontSize, panel.colorValue, data.display.text);
  310. if (panel.postfix) {
  311. body += getSpan('singlestat-panel-postfix', panel.postfixFontSize, panel.colorPostfix, panel.postfix);
  312. }
  313. body += '</div>';
  314. return body;
  315. }
  316. function getValueText() {
  317. const data: ShowData = ctrl.data;
  318. let result = panel.prefix ? templateSrv.replace(panel.prefix, data.scopedVars) : '';
  319. result += data.display.text;
  320. result += panel.postfix ? templateSrv.replace(panel.postfix, data.scopedVars) : '';
  321. return result;
  322. }
  323. function addGauge() {
  324. const data: ShowData = ctrl.data;
  325. const width = elem.width();
  326. const height = elem.height();
  327. // Allow to use a bit more space for wide gauges
  328. const dimension = Math.min(width, height * 1.3);
  329. ctrl.invalidGaugeRange = false;
  330. if (panel.gauge.minValue > panel.gauge.maxValue) {
  331. ctrl.invalidGaugeRange = true;
  332. return;
  333. }
  334. const plotCanvas = $('<div></div>');
  335. const plotCss = {
  336. top: '5px',
  337. margin: 'auto',
  338. position: 'relative',
  339. height: height * 0.9 + 'px',
  340. width: dimension + 'px',
  341. };
  342. plotCanvas.css(plotCss);
  343. const thresholds = [];
  344. for (let i = 0; i < data.thresholds.length; i++) {
  345. thresholds.push({
  346. value: data.thresholds[i],
  347. color: data.colorMap[i],
  348. });
  349. }
  350. thresholds.push({
  351. value: panel.gauge.maxValue,
  352. color: data.colorMap[data.colorMap.length - 1],
  353. });
  354. const bgColor = config.bootData.user.lightTheme ? 'rgb(230,230,230)' : 'rgb(38,38,38)';
  355. const fontScale = parseInt(panel.valueFontSize, 10) / 100;
  356. const fontSize = Math.min(dimension / 5, 100) * fontScale;
  357. // Reduce gauge width if threshold labels enabled
  358. const gaugeWidthReduceRatio = panel.gauge.thresholdLabels ? 1.5 : 1;
  359. const gaugeWidth = Math.min(dimension / 6, 60) / gaugeWidthReduceRatio;
  360. const thresholdMarkersWidth = gaugeWidth / 5;
  361. const thresholdLabelFontSize = fontSize / 2.5;
  362. const options: any = {
  363. series: {
  364. gauges: {
  365. gauge: {
  366. min: panel.gauge.minValue,
  367. max: panel.gauge.maxValue,
  368. background: { color: bgColor },
  369. border: { color: null },
  370. shadow: { show: false },
  371. width: gaugeWidth,
  372. },
  373. frame: { show: false },
  374. label: { show: false },
  375. layout: { margin: 0, thresholdWidth: 0 },
  376. cell: { border: { width: 0 } },
  377. threshold: {
  378. values: thresholds,
  379. label: {
  380. show: panel.gauge.thresholdLabels,
  381. margin: thresholdMarkersWidth + 1,
  382. font: { size: thresholdLabelFontSize },
  383. },
  384. show: panel.gauge.thresholdMarkers,
  385. width: thresholdMarkersWidth,
  386. },
  387. value: {
  388. color: panel.colorValue ? getColorForValue(data, data.display.numeric) : null,
  389. formatter: () => {
  390. return getValueText();
  391. },
  392. font: {
  393. size: fontSize,
  394. family: config.theme.typography.fontFamily.sansSerif,
  395. },
  396. },
  397. show: true,
  398. },
  399. },
  400. };
  401. elem.append(plotCanvas);
  402. const plotSeries = {
  403. data: [[0, data.value]],
  404. };
  405. $.plot(plotCanvas, [plotSeries], options);
  406. }
  407. function addSparkline() {
  408. const data: ShowData = ctrl.data;
  409. const width = elem.width();
  410. if (width < 30) {
  411. // element has not gotten it's width yet
  412. // delay sparkline render
  413. setTimeout(addSparkline, 30);
  414. return;
  415. }
  416. if (!data.sparkline || !data.sparkline.length) {
  417. // no sparkline data
  418. return;
  419. }
  420. const height = ctrl.height;
  421. const plotCanvas = $('<div></div>');
  422. const plotCss: any = {};
  423. plotCss.position = 'absolute';
  424. plotCss.bottom = '0px';
  425. if (panel.sparkline.full) {
  426. plotCss.left = '0px';
  427. plotCss.width = width + 'px';
  428. const dynamicHeightMargin = height <= 100 ? 5 : Math.round(height / 100) * 15 + 5;
  429. plotCss.height = height - dynamicHeightMargin + 'px';
  430. } else {
  431. plotCss.left = '0px';
  432. plotCss.width = width + 'px';
  433. plotCss.height = Math.floor(height * 0.25) + 'px';
  434. }
  435. plotCanvas.css(plotCss);
  436. const options = {
  437. legend: { show: false },
  438. series: {
  439. lines: {
  440. show: true,
  441. fill: 1,
  442. lineWidth: 1,
  443. fillColor: getColorFromHexRgbOrName(panel.sparkline.fillColor, config.theme.type),
  444. zero: false,
  445. },
  446. },
  447. yaxis: {
  448. show: false,
  449. min: panel.sparkline.ymin,
  450. max: panel.sparkline.ymax,
  451. },
  452. xaxis: {
  453. show: false,
  454. mode: 'time',
  455. min: ctrl.range.from.valueOf(),
  456. max: ctrl.range.to.valueOf(),
  457. },
  458. grid: { hoverable: false, show: false },
  459. };
  460. elem.append(plotCanvas);
  461. const plotSeries = {
  462. data: data.sparkline,
  463. color: getColorFromHexRgbOrName(panel.sparkline.lineColor, config.theme.type),
  464. };
  465. $.plot(plotCanvas, [plotSeries], options);
  466. }
  467. function render() {
  468. if (!ctrl.data) {
  469. return;
  470. }
  471. const { data, panel } = ctrl;
  472. // get thresholds
  473. data.thresholds = panel.thresholds
  474. ? panel.thresholds.split(',').map((strVale: string) => {
  475. return Number(strVale.trim());
  476. })
  477. : [];
  478. // Map panel colors to hex or rgb/a values
  479. if (panel.colors) {
  480. data.colorMap = panel.colors.map((color: string) => getColorFromHexRgbOrName(color, config.theme.type));
  481. }
  482. const body = panel.gauge.show ? '' : getBigValueHtml();
  483. if (panel.colorBackground) {
  484. const color = getColorForValue(data, data.display.numeric);
  485. if (color) {
  486. $panelContainer.css('background-color', color);
  487. if (scope.fullscreen) {
  488. elem.css('background-color', color);
  489. } else {
  490. elem.css('background-color', '');
  491. }
  492. } else {
  493. $panelContainer.css('background-color', '');
  494. elem.css('background-color', '');
  495. }
  496. } else {
  497. $panelContainer.css('background-color', '');
  498. elem.css('background-color', '');
  499. }
  500. elem.html(body);
  501. if (panel.sparkline.show) {
  502. addSparkline();
  503. }
  504. if (panel.gauge.show) {
  505. addGauge();
  506. }
  507. elem.toggleClass('pointer', panel.links.length > 0);
  508. if (panel.links.length > 0) {
  509. linkInfo = linkSrv.getDataLinkUIModel(panel.links[0], data.scopedVars);
  510. } else {
  511. linkInfo = null;
  512. }
  513. }
  514. function hookupDrilldownLinkTooltip() {
  515. // drilldown link tooltip
  516. const drilldownTooltip = $('<div id="tooltip" class="">hello</div>"');
  517. elem.mouseleave(() => {
  518. if (panel.links.length === 0) {
  519. return;
  520. }
  521. $timeout(() => {
  522. drilldownTooltip.detach();
  523. });
  524. });
  525. elem.click(evt => {
  526. if (!linkInfo) {
  527. return;
  528. }
  529. // ignore title clicks in title
  530. if ($(evt).parents('.panel-header').length > 0) {
  531. return;
  532. }
  533. if (linkInfo.target === '_blank') {
  534. window.open(linkInfo.href, '_blank');
  535. return;
  536. }
  537. if (linkInfo.href.indexOf('http') === 0) {
  538. window.location.href = linkInfo.href;
  539. } else {
  540. $timeout(() => {
  541. $location.url(linkInfo.href);
  542. });
  543. }
  544. drilldownTooltip.detach();
  545. });
  546. elem.mousemove(e => {
  547. if (!linkInfo) {
  548. return;
  549. }
  550. drilldownTooltip.text('click to go to: ' + linkInfo.title);
  551. drilldownTooltip.place_tt(e.pageX, e.pageY - 50);
  552. });
  553. }
  554. hookupDrilldownLinkTooltip();
  555. this.events.on('render', () => {
  556. render();
  557. ctrl.renderingCompleted();
  558. });
  559. }
  560. }
  561. function getColorForValue(data: any, value: number) {
  562. if (!_.isFinite(value)) {
  563. return null;
  564. }
  565. for (let i = data.thresholds.length; i > 0; i--) {
  566. if (value >= data.thresholds[i - 1]) {
  567. return data.colorMap[i];
  568. }
  569. }
  570. return _.first(data.colorMap);
  571. }
  572. //------------------------------------------------
  573. // Private utility functions
  574. // Somethign like this should be avaliable in a
  575. // DataFrame[] abstraction helper
  576. //------------------------------------------------
  577. interface FrameInfo {
  578. firstTimeField?: Field;
  579. frame: DataFrame;
  580. }
  581. interface FieldInfo {
  582. field: Field;
  583. frame: FrameInfo;
  584. }
  585. interface DistinctFieldsInfo {
  586. first?: FieldInfo;
  587. byName: KeyValue<FieldInfo>;
  588. names: string[];
  589. }
  590. function getDistinctNames(data: DataFrame[]): DistinctFieldsInfo {
  591. const distinct: DistinctFieldsInfo = {
  592. byName: {},
  593. names: [],
  594. };
  595. for (const frame of data) {
  596. const info: FrameInfo = { frame };
  597. for (const field of frame.fields) {
  598. if (field.type === FieldType.time) {
  599. if (!info.firstTimeField) {
  600. info.firstTimeField = field;
  601. }
  602. } else {
  603. const f = { field, frame: info };
  604. if (!distinct.first) {
  605. distinct.first = f;
  606. }
  607. let t = field.config.title;
  608. if (t && !distinct.byName[t]) {
  609. distinct.byName[t] = f;
  610. distinct.names.push(t);
  611. }
  612. t = field.name;
  613. if (t && !distinct.byName[t]) {
  614. distinct.byName[t] = f;
  615. distinct.names.push(t);
  616. }
  617. }
  618. }
  619. }
  620. return distinct;
  621. }
  622. export { SingleStatCtrl, SingleStatCtrl as PanelCtrl, getColorForValue };