module.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. LinkModel,
  27. } from '@grafana/data';
  28. import { auto } from 'angular';
  29. import { LinkSrv } from 'app/features/panel/panellinks/link_srv';
  30. import { getProcessedDataFrames } from 'app/features/dashboard/state/runRequest';
  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-frames-received', this.onFramesReceived.bind(this));
  110. this.events.on('data-error', this.onDataError.bind(this));
  111. this.events.on('data-snapshot-load', this.onSnapshotLoad.bind(this));
  112. this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
  113. this.useDataFrames = true;
  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. onSnapshotLoad(dataList: LegacyResponseData[]) {
  139. this.onFramesReceived(getProcessedDataFrames(dataList));
  140. }
  141. onFramesReceived(frames: DataFrame[]) {
  142. const { panel } = this;
  143. if (frames && frames.length > 1) {
  144. this.data = {
  145. value: 0,
  146. display: {
  147. text: 'Only queries that return single series/table is supported',
  148. numeric: NaN,
  149. },
  150. };
  151. this.render();
  152. return;
  153. }
  154. const distinct = getDistinctNames(frames);
  155. let fieldInfo = distinct.byName[panel.tableColumn]; //
  156. this.fieldNames = distinct.names;
  157. if (!fieldInfo) {
  158. fieldInfo = distinct.first;
  159. }
  160. if (!fieldInfo) {
  161. // When we don't have any field
  162. this.data = {
  163. value: 'No Data',
  164. display: {
  165. text: 'No Data',
  166. numeric: NaN,
  167. },
  168. };
  169. } else {
  170. this.data = this.processField(fieldInfo);
  171. }
  172. this.render();
  173. }
  174. processField(fieldInfo: FieldInfo) {
  175. const { panel, dashboard } = this;
  176. const name = fieldInfo.field.config.title || fieldInfo.field.name;
  177. let calc = panel.valueName;
  178. let calcField = fieldInfo.field;
  179. let val: any = undefined;
  180. if ('name' === calc) {
  181. val = name;
  182. } else {
  183. if ('last_time' === calc) {
  184. if (fieldInfo.frame.firstTimeField) {
  185. calcField = fieldInfo.frame.firstTimeField;
  186. calc = ReducerID.last;
  187. }
  188. }
  189. // Normalize functions (avg -> mean, etc)
  190. const r = fieldReducers.getIfExists(calc);
  191. if (r) {
  192. calc = r.id;
  193. // With strings, don't accidentally use a math function
  194. if (calcField.type === FieldType.string) {
  195. const avoid = [ReducerID.mean, ReducerID.sum];
  196. if (avoid.includes(calc)) {
  197. calc = panel.valueName = ReducerID.first;
  198. }
  199. }
  200. } else {
  201. calc = ReducerID.lastNotNull;
  202. }
  203. // Calculate the value
  204. val = reduceField({
  205. field: calcField,
  206. reducers: [calc],
  207. })[calc];
  208. }
  209. const processor = getDisplayProcessor({
  210. config: {
  211. ...fieldInfo.field.config,
  212. unit: panel.format,
  213. decimals: panel.decimals,
  214. mappings: convertOldAngulrValueMapping(panel),
  215. },
  216. theme: config.theme,
  217. isUtc: dashboard.isTimezoneUtc && dashboard.isTimezoneUtc(),
  218. });
  219. const sparkline: any[] = [];
  220. const data = {
  221. field: fieldInfo.field,
  222. value: val,
  223. display: processor(val),
  224. scopedVars: _.extend({}, panel.scopedVars),
  225. sparkline,
  226. };
  227. data.scopedVars['__name'] = name;
  228. panel.tableColumn = this.fieldNames.length > 1 ? name : '';
  229. // Get the fields for a sparkline
  230. if (panel.sparkline && panel.sparkline.show && fieldInfo.frame.firstTimeField) {
  231. data.sparkline = getFlotPairs({
  232. xField: fieldInfo.frame.firstTimeField,
  233. yField: fieldInfo.field,
  234. nullValueMode: panel.nullPointMode,
  235. });
  236. }
  237. return data;
  238. }
  239. canModifyText() {
  240. return !this.panel.gauge.show;
  241. }
  242. setColoring(options: { background: any }) {
  243. if (options.background) {
  244. this.panel.colorValue = false;
  245. this.panel.colors = ['rgba(71, 212, 59, 0.4)', 'rgba(245, 150, 40, 0.73)', 'rgba(225, 40, 40, 0.59)'];
  246. } else {
  247. this.panel.colorBackground = false;
  248. this.panel.colors = ['rgba(50, 172, 45, 0.97)', 'rgba(237, 129, 40, 0.89)', 'rgba(245, 54, 54, 0.9)'];
  249. }
  250. this.render();
  251. }
  252. invertColorOrder() {
  253. const tmp = this.panel.colors[0];
  254. this.panel.colors[0] = this.panel.colors[2];
  255. this.panel.colors[2] = tmp;
  256. this.render();
  257. }
  258. onColorChange(panelColorIndex: number) {
  259. return (color: string) => {
  260. this.panel.colors[panelColorIndex] = color;
  261. this.render();
  262. };
  263. }
  264. onSparklineColorChange(newColor: string) {
  265. this.panel.sparkline.lineColor = newColor;
  266. this.render();
  267. }
  268. onSparklineFillChange(newColor: string) {
  269. this.panel.sparkline.fillColor = newColor;
  270. this.render();
  271. }
  272. removeValueMap(map: any) {
  273. const index = _.indexOf(this.panel.valueMaps, map);
  274. this.panel.valueMaps.splice(index, 1);
  275. this.render();
  276. }
  277. addValueMap() {
  278. this.panel.valueMaps.push({ value: '', op: '=', text: '' });
  279. }
  280. removeRangeMap(rangeMap: any) {
  281. const index = _.indexOf(this.panel.rangeMaps, rangeMap);
  282. this.panel.rangeMaps.splice(index, 1);
  283. this.render();
  284. }
  285. addRangeMap() {
  286. this.panel.rangeMaps.push({ from: '', to: '', text: '' });
  287. }
  288. link(scope: any, elem: JQuery, attrs: any, ctrl: any) {
  289. const $location = this.$location;
  290. const linkSrv = this.linkSrv;
  291. const $timeout = this.$timeout;
  292. const $sanitize = this.$sanitize;
  293. const panel = ctrl.panel;
  294. const templateSrv = this.templateSrv;
  295. let linkInfo: LinkModel<any> | null = null;
  296. const $panelContainer = elem.find('.panel-container');
  297. elem = elem.find('.singlestat-panel');
  298. function applyColoringThresholds(valueString: string) {
  299. const data = ctrl.data;
  300. const color = getColorForValue(data, data.value);
  301. if (color) {
  302. return '<span style="color:' + color + '">' + valueString + '</span>';
  303. }
  304. return valueString;
  305. }
  306. function getSpan(className: string, fontSizePercent: string, applyColoring: any, value: string) {
  307. value = $sanitize(templateSrv.replace(value, ctrl.data.scopedVars));
  308. value = applyColoring ? applyColoringThresholds(value) : value;
  309. const pixelSize = (parseInt(fontSizePercent, 10) / 100) * BASE_FONT_SIZE;
  310. return '<span class="' + className + '" style="font-size:' + pixelSize + 'px">' + value + '</span>';
  311. }
  312. function getBigValueHtml() {
  313. const data: ShowData = ctrl.data;
  314. let body = '<div class="singlestat-panel-value-container">';
  315. if (panel.prefix) {
  316. body += getSpan('singlestat-panel-prefix', panel.prefixFontSize, panel.colorPrefix, panel.prefix);
  317. }
  318. body += getSpan('singlestat-panel-value', panel.valueFontSize, panel.colorValue, data.display.text);
  319. if (panel.postfix) {
  320. body += getSpan('singlestat-panel-postfix', panel.postfixFontSize, panel.colorPostfix, panel.postfix);
  321. }
  322. body += '</div>';
  323. return body;
  324. }
  325. function getValueText() {
  326. const data: ShowData = ctrl.data;
  327. let result = panel.prefix ? templateSrv.replace(panel.prefix, data.scopedVars) : '';
  328. result += data.display.text;
  329. result += panel.postfix ? templateSrv.replace(panel.postfix, data.scopedVars) : '';
  330. return result;
  331. }
  332. function addGauge() {
  333. const data: ShowData = ctrl.data;
  334. const width = elem.width();
  335. const height = elem.height();
  336. // Allow to use a bit more space for wide gauges
  337. const dimension = Math.min(width, height * 1.3);
  338. ctrl.invalidGaugeRange = false;
  339. if (panel.gauge.minValue > panel.gauge.maxValue) {
  340. ctrl.invalidGaugeRange = true;
  341. return;
  342. }
  343. const plotCanvas = $('<div></div>');
  344. const plotCss = {
  345. top: '5px',
  346. margin: 'auto',
  347. position: 'relative',
  348. height: height * 0.9 + 'px',
  349. width: dimension + 'px',
  350. };
  351. plotCanvas.css(plotCss);
  352. const thresholds = [];
  353. for (let i = 0; i < data.thresholds.length; i++) {
  354. thresholds.push({
  355. value: data.thresholds[i],
  356. color: data.colorMap[i],
  357. });
  358. }
  359. thresholds.push({
  360. value: panel.gauge.maxValue,
  361. color: data.colorMap[data.colorMap.length - 1],
  362. });
  363. const bgColor = config.bootData.user.lightTheme ? 'rgb(230,230,230)' : 'rgb(38,38,38)';
  364. const fontScale = parseInt(panel.valueFontSize, 10) / 100;
  365. const fontSize = Math.min(dimension / 5, 100) * fontScale;
  366. // Reduce gauge width if threshold labels enabled
  367. const gaugeWidthReduceRatio = panel.gauge.thresholdLabels ? 1.5 : 1;
  368. const gaugeWidth = Math.min(dimension / 6, 60) / gaugeWidthReduceRatio;
  369. const thresholdMarkersWidth = gaugeWidth / 5;
  370. const thresholdLabelFontSize = fontSize / 2.5;
  371. const options: any = {
  372. series: {
  373. gauges: {
  374. gauge: {
  375. min: panel.gauge.minValue,
  376. max: panel.gauge.maxValue,
  377. background: { color: bgColor },
  378. border: { color: null },
  379. shadow: { show: false },
  380. width: gaugeWidth,
  381. },
  382. frame: { show: false },
  383. label: { show: false },
  384. layout: { margin: 0, thresholdWidth: 0 },
  385. cell: { border: { width: 0 } },
  386. threshold: {
  387. values: thresholds,
  388. label: {
  389. show: panel.gauge.thresholdLabels,
  390. margin: thresholdMarkersWidth + 1,
  391. font: { size: thresholdLabelFontSize },
  392. },
  393. show: panel.gauge.thresholdMarkers,
  394. width: thresholdMarkersWidth,
  395. },
  396. value: {
  397. color: panel.colorValue ? getColorForValue(data, data.display.numeric) : null,
  398. formatter: () => {
  399. return getValueText();
  400. },
  401. font: {
  402. size: fontSize,
  403. family: config.theme.typography.fontFamily.sansSerif,
  404. },
  405. },
  406. show: true,
  407. },
  408. },
  409. };
  410. elem.append(plotCanvas);
  411. const plotSeries = {
  412. data: [[0, data.value]],
  413. };
  414. $.plot(plotCanvas, [plotSeries], options);
  415. }
  416. function addSparkline() {
  417. const data: ShowData = ctrl.data;
  418. const width = elem.width();
  419. if (width < 30) {
  420. // element has not gotten it's width yet
  421. // delay sparkline render
  422. setTimeout(addSparkline, 30);
  423. return;
  424. }
  425. if (!data.sparkline || !data.sparkline.length) {
  426. // no sparkline data
  427. return;
  428. }
  429. const height = ctrl.height;
  430. const plotCanvas = $('<div></div>');
  431. const plotCss: any = {};
  432. plotCss.position = 'absolute';
  433. plotCss.bottom = '0px';
  434. if (panel.sparkline.full) {
  435. plotCss.left = '0px';
  436. plotCss.width = width + 'px';
  437. const dynamicHeightMargin = height <= 100 ? 5 : Math.round(height / 100) * 15 + 5;
  438. plotCss.height = height - dynamicHeightMargin + 'px';
  439. } else {
  440. plotCss.left = '0px';
  441. plotCss.width = width + 'px';
  442. plotCss.height = Math.floor(height * 0.25) + 'px';
  443. }
  444. plotCanvas.css(plotCss);
  445. const options = {
  446. legend: { show: false },
  447. series: {
  448. lines: {
  449. show: true,
  450. fill: 1,
  451. lineWidth: 1,
  452. fillColor: getColorFromHexRgbOrName(panel.sparkline.fillColor, config.theme.type),
  453. zero: false,
  454. },
  455. },
  456. yaxis: {
  457. show: false,
  458. min: panel.sparkline.ymin,
  459. max: panel.sparkline.ymax,
  460. },
  461. xaxis: {
  462. show: false,
  463. mode: 'time',
  464. min: ctrl.range.from.valueOf(),
  465. max: ctrl.range.to.valueOf(),
  466. },
  467. grid: { hoverable: false, show: false },
  468. };
  469. elem.append(plotCanvas);
  470. const plotSeries = {
  471. data: data.sparkline,
  472. color: getColorFromHexRgbOrName(panel.sparkline.lineColor, config.theme.type),
  473. };
  474. $.plot(plotCanvas, [plotSeries], options);
  475. }
  476. function render() {
  477. if (!ctrl.data) {
  478. return;
  479. }
  480. const { data, panel } = ctrl;
  481. // get thresholds
  482. data.thresholds = panel.thresholds
  483. ? panel.thresholds.split(',').map((strVale: string) => {
  484. return Number(strVale.trim());
  485. })
  486. : [];
  487. // Map panel colors to hex or rgb/a values
  488. if (panel.colors) {
  489. data.colorMap = panel.colors.map((color: string) => getColorFromHexRgbOrName(color, config.theme.type));
  490. }
  491. const body = panel.gauge.show ? '' : getBigValueHtml();
  492. if (panel.colorBackground) {
  493. const color = getColorForValue(data, data.display.numeric);
  494. if (color) {
  495. $panelContainer.css('background-color', color);
  496. if (scope.fullscreen) {
  497. elem.css('background-color', color);
  498. } else {
  499. elem.css('background-color', '');
  500. }
  501. } else {
  502. $panelContainer.css('background-color', '');
  503. elem.css('background-color', '');
  504. }
  505. } else {
  506. $panelContainer.css('background-color', '');
  507. elem.css('background-color', '');
  508. }
  509. elem.html(body);
  510. if (panel.sparkline.show) {
  511. addSparkline();
  512. }
  513. if (panel.gauge.show) {
  514. addGauge();
  515. }
  516. elem.toggleClass('pointer', panel.links.length > 0);
  517. if (panel.links.length > 0) {
  518. linkInfo = linkSrv.getDataLinkUIModel(panel.links[0], data.scopedVars, {});
  519. } else {
  520. linkInfo = null;
  521. }
  522. }
  523. function hookupDrilldownLinkTooltip() {
  524. // drilldown link tooltip
  525. const drilldownTooltip = $('<div id="tooltip" class="">hello</div>"');
  526. elem.mouseleave(() => {
  527. if (panel.links.length === 0) {
  528. return;
  529. }
  530. $timeout(() => {
  531. drilldownTooltip.detach();
  532. });
  533. });
  534. elem.click(evt => {
  535. if (!linkInfo) {
  536. return;
  537. }
  538. // ignore title clicks in title
  539. if ($(evt).parents('.panel-header').length > 0) {
  540. return;
  541. }
  542. if (linkInfo.target === '_blank') {
  543. window.open(linkInfo.href, '_blank');
  544. return;
  545. }
  546. if (linkInfo.href.indexOf('http') === 0) {
  547. window.location.href = linkInfo.href;
  548. } else {
  549. $timeout(() => {
  550. $location.url(linkInfo.href);
  551. });
  552. }
  553. drilldownTooltip.detach();
  554. });
  555. elem.mousemove(e => {
  556. if (!linkInfo) {
  557. return;
  558. }
  559. drilldownTooltip.text('click to go to: ' + linkInfo.title);
  560. drilldownTooltip.place_tt(e.pageX, e.pageY - 50);
  561. });
  562. }
  563. hookupDrilldownLinkTooltip();
  564. this.events.on('render', () => {
  565. render();
  566. ctrl.renderingCompleted();
  567. });
  568. }
  569. }
  570. function getColorForValue(data: any, value: number) {
  571. if (!_.isFinite(value)) {
  572. return null;
  573. }
  574. for (let i = data.thresholds.length; i > 0; i--) {
  575. if (value >= data.thresholds[i - 1]) {
  576. return data.colorMap[i];
  577. }
  578. }
  579. return _.first(data.colorMap);
  580. }
  581. //------------------------------------------------
  582. // Private utility functions
  583. // Somethign like this should be avaliable in a
  584. // DataFrame[] abstraction helper
  585. //------------------------------------------------
  586. interface FrameInfo {
  587. firstTimeField?: Field;
  588. frame: DataFrame;
  589. }
  590. interface FieldInfo {
  591. field: Field;
  592. frame: FrameInfo;
  593. }
  594. interface DistinctFieldsInfo {
  595. first?: FieldInfo;
  596. byName: KeyValue<FieldInfo>;
  597. names: string[];
  598. }
  599. function getDistinctNames(data: DataFrame[]): DistinctFieldsInfo {
  600. const distinct: DistinctFieldsInfo = {
  601. byName: {},
  602. names: [],
  603. };
  604. for (const frame of data) {
  605. const info: FrameInfo = { frame };
  606. for (const field of frame.fields) {
  607. if (field.type === FieldType.time) {
  608. if (!info.firstTimeField) {
  609. info.firstTimeField = field;
  610. }
  611. } else {
  612. const f = { field, frame: info };
  613. if (!distinct.first) {
  614. distinct.first = f;
  615. }
  616. let t = field.config.title;
  617. if (t && !distinct.byName[t]) {
  618. distinct.byName[t] = f;
  619. distinct.names.push(t);
  620. }
  621. t = field.name;
  622. if (t && !distinct.byName[t]) {
  623. distinct.byName[t] = f;
  624. distinct.names.push(t);
  625. }
  626. }
  627. }
  628. }
  629. return distinct;
  630. }
  631. export { SingleStatCtrl, SingleStatCtrl as PanelCtrl, getColorForValue };