2016-01-24 17:10:26 +01:00
|
|
|
///<reference path="../../../headers/common.d.ts" />
|
|
|
|
|
|
2016-02-04 15:04:07 +01:00
|
|
|
import angular from 'angular';
|
2016-01-24 17:10:26 +01:00
|
|
|
import _ from 'lodash';
|
|
|
|
|
import $ from 'jquery';
|
2016-01-27 19:07:39 -05:00
|
|
|
import 'jquery.flot';
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-02-04 15:04:07 +01:00
|
|
|
import kbn from 'app/core/utils/kbn';
|
2016-02-05 18:08:21 +01:00
|
|
|
import TimeSeries from 'app/core/time_series2';
|
|
|
|
|
import {MetricsPanelCtrl} from 'app/plugins/sdk';
|
2016-02-04 15:04:07 +01:00
|
|
|
|
|
|
|
|
// Set and populate defaults
|
|
|
|
|
var panelDefaults = {
|
|
|
|
|
links: [],
|
|
|
|
|
datasource: null,
|
|
|
|
|
maxDataPoints: 100,
|
|
|
|
|
interval: null,
|
|
|
|
|
targets: [{}],
|
|
|
|
|
cacheTimeout: null,
|
|
|
|
|
format: 'none',
|
|
|
|
|
prefix: '',
|
|
|
|
|
postfix: '',
|
|
|
|
|
nullText: null,
|
|
|
|
|
valueMaps: [
|
|
|
|
|
{ value: 'null', op: '=', text: 'N/A' }
|
|
|
|
|
],
|
|
|
|
|
nullPointMode: 'connected',
|
|
|
|
|
valueName: 'avg',
|
|
|
|
|
prefixFontSize: '50%',
|
|
|
|
|
valueFontSize: '80%',
|
|
|
|
|
postfixFontSize: '50%',
|
|
|
|
|
thresholds: '',
|
|
|
|
|
colorBackground: false,
|
|
|
|
|
colorValue: false,
|
|
|
|
|
colors: ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
|
|
|
|
|
sparkline: {
|
|
|
|
|
show: false,
|
|
|
|
|
full: false,
|
|
|
|
|
lineColor: 'rgb(31, 120, 193)',
|
|
|
|
|
fillColor: 'rgba(31, 118, 189, 0.18)',
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SingleStatCtrl extends MetricsPanelCtrl {
|
|
|
|
|
static templateUrl = 'public/app/plugins/panel/singlestat/module.html';
|
|
|
|
|
|
|
|
|
|
series: any[];
|
|
|
|
|
data: any[];
|
|
|
|
|
fontSizes: any[];
|
|
|
|
|
unitFormats: any[];
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
/** @ngInject */
|
2016-02-04 15:04:07 +01:00
|
|
|
constructor($scope, $injector, private $location, private linkSrv, private templateSrv) {
|
|
|
|
|
super($scope, $injector);
|
|
|
|
|
_.defaults(this.panel, panelDefaults);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initEditMode() {
|
|
|
|
|
super.initEditMode();
|
|
|
|
|
this.icon = "fa fa-dashboard";
|
|
|
|
|
this.fontSizes = ['20%', '30%','50%','70%','80%','100%', '110%', '120%', '150%', '170%', '200%'];
|
2016-02-05 11:05:47 +01:00
|
|
|
this.addEditorTab('Options', 'public/app/plugins/panel/singlestat/editor.html', 2);
|
2016-02-04 15:04:07 +01:00
|
|
|
this.unitFormats = kbn.getUnitFormats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setUnitFormat(subItem) {
|
|
|
|
|
this.panel.format = subItem.value;
|
|
|
|
|
this.render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshData(datasource) {
|
|
|
|
|
return this.issueQueries(datasource)
|
|
|
|
|
.then(this.dataHandler.bind(this))
|
|
|
|
|
.catch(err => {
|
|
|
|
|
this.series = [];
|
|
|
|
|
this.render();
|
|
|
|
|
throw err;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadSnapshot(snapshotData) {
|
2016-02-05 13:48:10 +01:00
|
|
|
// give element time to get attached and get dimensions
|
|
|
|
|
this.$timeout(() => this.dataHandler(snapshotData), 50);
|
2016-02-04 15:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dataHandler(results) {
|
|
|
|
|
this.series = _.map(results.data, this.seriesHandler.bind(this));
|
|
|
|
|
this.render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seriesHandler(seriesData) {
|
|
|
|
|
var series = new TimeSeries({
|
|
|
|
|
datapoints: seriesData.datapoints,
|
|
|
|
|
alias: seriesData.target,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);
|
|
|
|
|
return series;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setColoring(options) {
|
|
|
|
|
if (options.background) {
|
|
|
|
|
this.panel.colorValue = false;
|
|
|
|
|
this.panel.colors = ['rgba(71, 212, 59, 0.4)', 'rgba(245, 150, 40, 0.73)', 'rgba(225, 40, 40, 0.59)'];
|
|
|
|
|
} else {
|
|
|
|
|
this.panel.colorBackground = false;
|
|
|
|
|
this.panel.colors = ['rgba(50, 172, 45, 0.97)', 'rgba(237, 129, 40, 0.89)', 'rgba(245, 54, 54, 0.9)'];
|
|
|
|
|
}
|
|
|
|
|
this.render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
invertColorOrder() {
|
|
|
|
|
var tmp = this.panel.colors[0];
|
|
|
|
|
this.panel.colors[0] = this.panel.colors[2];
|
|
|
|
|
this.panel.colors[2] = tmp;
|
|
|
|
|
this.render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDecimalsForValue(value) {
|
|
|
|
|
if (_.isNumber(this.panel.decimals)) {
|
|
|
|
|
return {decimals: this.panel.decimals, scaledDecimals: null};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var delta = value / 2;
|
|
|
|
|
var dec = -Math.floor(Math.log(delta) / Math.LN10);
|
|
|
|
|
|
|
|
|
|
var magn = Math.pow(10, -dec),
|
|
|
|
|
norm = delta / magn, // norm is between 1.0 and 10.0
|
|
|
|
|
size;
|
|
|
|
|
|
|
|
|
|
if (norm < 1.5) {
|
|
|
|
|
size = 1;
|
|
|
|
|
} else if (norm < 3) {
|
|
|
|
|
size = 2;
|
|
|
|
|
// special case for 2.5, requires an extra decimal
|
|
|
|
|
if (norm > 2.25) {
|
|
|
|
|
size = 2.5;
|
|
|
|
|
++dec;
|
|
|
|
|
}
|
|
|
|
|
} else if (norm < 7.5) {
|
|
|
|
|
size = 5;
|
|
|
|
|
} else {
|
|
|
|
|
size = 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size *= magn;
|
|
|
|
|
|
|
|
|
|
// reduce starting decimals if not needed
|
|
|
|
|
if (Math.floor(value) === value) { dec = 0; }
|
|
|
|
|
|
|
|
|
|
var result: any = {};
|
|
|
|
|
result.decimals = Math.max(0, dec);
|
|
|
|
|
result.scaledDecimals = result.decimals - Math.floor(Math.log(size) / Math.LN10) + 2;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
var data: any = {};
|
|
|
|
|
this.setValues(data);
|
|
|
|
|
|
|
|
|
|
data.thresholds = this.panel.thresholds.split(',').map(function(strVale) {
|
|
|
|
|
return Number(strVale.trim());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
data.colorMap = this.panel.colors;
|
|
|
|
|
|
|
|
|
|
this.data = data;
|
|
|
|
|
this.broadcastRender();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setValues(data) {
|
|
|
|
|
data.flotpairs = [];
|
|
|
|
|
|
|
|
|
|
if (this.series.length > 1) {
|
2016-02-05 11:05:47 +01:00
|
|
|
var error: any = new Error();
|
|
|
|
|
error.message = 'Multiple Series Error';
|
|
|
|
|
error.data = 'Metric query returns ' + this.series.length +
|
2016-02-04 15:04:07 +01:00
|
|
|
' series. Single Stat Panel expects a single series.\n\nResponse:\n'+JSON.stringify(this.series);
|
2016-02-05 11:05:47 +01:00
|
|
|
throw error;
|
2016-02-04 15:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.series && this.series.length > 0) {
|
|
|
|
|
var lastPoint = _.last(this.series[0].datapoints);
|
|
|
|
|
var lastValue = _.isArray(lastPoint) ? lastPoint[0] : null;
|
|
|
|
|
|
|
|
|
|
if (_.isString(lastValue)) {
|
|
|
|
|
data.value = 0;
|
|
|
|
|
data.valueFormated = lastValue;
|
|
|
|
|
data.valueRounded = 0;
|
|
|
|
|
} else {
|
|
|
|
|
data.value = this.series[0].stats[this.panel.valueName];
|
|
|
|
|
data.flotpairs = this.series[0].flotpairs;
|
|
|
|
|
|
|
|
|
|
var decimalInfo = this.getDecimalsForValue(data.value);
|
|
|
|
|
var formatFunc = kbn.valueFormats[this.panel.format];
|
|
|
|
|
data.valueFormated = formatFunc(data.value, decimalInfo.decimals, decimalInfo.scaledDecimals);
|
|
|
|
|
data.valueRounded = kbn.roundValue(data.value, decimalInfo.decimals);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check value to text mappings
|
|
|
|
|
for (var i = 0; i < this.panel.valueMaps.length; i++) {
|
|
|
|
|
var map = this.panel.valueMaps[i];
|
|
|
|
|
// special null case
|
|
|
|
|
if (map.value === 'null') {
|
|
|
|
|
if (data.value === null || data.value === void 0) {
|
|
|
|
|
data.valueFormated = map.text;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// value/number to text mapping
|
|
|
|
|
var value = parseFloat(map.value);
|
|
|
|
|
if (value === data.value) {
|
|
|
|
|
data.valueFormated = map.text;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.value === null || data.value === void 0) {
|
|
|
|
|
data.valueFormated = "no value";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
removeValueMap(map) {
|
|
|
|
|
var index = _.indexOf(this.panel.valueMaps, map);
|
|
|
|
|
this.panel.valueMaps.splice(index, 1);
|
|
|
|
|
this.render();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
addValueMap() {
|
|
|
|
|
this.panel.valueMaps.push({value: '', op: '=', text: '' });
|
2016-01-27 19:07:39 -05:00
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
link(scope, elem, attrs, ctrl) {
|
|
|
|
|
var $location = this.$location;
|
|
|
|
|
var linkSrv = this.linkSrv;
|
|
|
|
|
var $timeout = this.$timeout;
|
|
|
|
|
var panel = ctrl.panel;
|
|
|
|
|
var templateSrv = this.templateSrv;
|
2016-02-05 13:48:10 +01:00
|
|
|
var data, linkInfo;
|
|
|
|
|
var $panelContainer = elem.parents('.panel-container');
|
|
|
|
|
// change elem to singlestat panel
|
|
|
|
|
elem = elem.find('.singlestat-panel');
|
|
|
|
|
hookupDrilldownLinkTooltip();
|
2016-01-27 19:07:39 -05:00
|
|
|
|
|
|
|
|
scope.$on('render', function() {
|
|
|
|
|
render();
|
|
|
|
|
ctrl.renderingCompleted();
|
|
|
|
|
});
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
function setElementHeight() {
|
|
|
|
|
try {
|
|
|
|
|
var height = scope.height || panel.height || ctrl.row.height;
|
|
|
|
|
if (_.isString(height)) {
|
|
|
|
|
height = parseInt(height.replace('px', ''), 10);
|
2016-01-24 17:10:26 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
height -= 5; // padding
|
|
|
|
|
height -= panel.title ? 24 : 9; // subtract panel title bar
|
|
|
|
|
|
|
|
|
|
elem.css('height', height + 'px');
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
return true;
|
|
|
|
|
} catch (e) { // IE throws errors sometimes
|
|
|
|
|
return false;
|
2016-01-24 17:10:26 +01:00
|
|
|
}
|
2016-01-27 19:07:39 -05:00
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
function applyColoringThresholds(value, valueString) {
|
|
|
|
|
if (!panel.colorValue) {
|
|
|
|
|
return valueString;
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
var color = getColorForValue(data, value);
|
|
|
|
|
if (color) {
|
|
|
|
|
return '<span style="color:' + color + '">'+ valueString + '</span>';
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
return valueString;
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
function getSpan(className, fontSize, value) {
|
|
|
|
|
value = templateSrv.replace(value);
|
|
|
|
|
return '<span class="' + className + '" style="font-size:' + fontSize + '">' +
|
|
|
|
|
value + '</span>';
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
function getBigValueHtml() {
|
|
|
|
|
var body = '<div class="singlestat-panel-value-container">';
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
if (panel.prefix) { body += getSpan('singlestat-panel-prefix', panel.prefixFontSize, panel.prefix); }
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
var value = applyColoringThresholds(data.valueRounded, data.valueFormated);
|
|
|
|
|
body += getSpan('singlestat-panel-value', panel.valueFontSize, value);
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
if (panel.postfix) { body += getSpan('singlestat-panel-postfix', panel.postfixFontSize, panel.postfix); }
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
body += '</div>';
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
return body;
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
function addSparkline() {
|
|
|
|
|
var width = elem.width() + 20;
|
|
|
|
|
var height = elem.height() || 100;
|
|
|
|
|
|
|
|
|
|
var plotCanvas = $('<div></div>');
|
|
|
|
|
var plotCss: any = {};
|
|
|
|
|
plotCss.position = 'absolute';
|
|
|
|
|
|
|
|
|
|
if (panel.sparkline.full) {
|
|
|
|
|
plotCss.bottom = '5px';
|
|
|
|
|
plotCss.left = '-5px';
|
|
|
|
|
plotCss.width = (width - 10) + 'px';
|
|
|
|
|
var dynamicHeightMargin = height <= 100 ? 5 : (Math.round((height/100)) * 15) + 5;
|
|
|
|
|
plotCss.height = (height - dynamicHeightMargin) + 'px';
|
|
|
|
|
} else {
|
|
|
|
|
plotCss.bottom = "0px";
|
|
|
|
|
plotCss.left = "-5px";
|
|
|
|
|
plotCss.width = (width - 10) + 'px';
|
|
|
|
|
plotCss.height = Math.floor(height * 0.25) + "px";
|
2016-01-24 17:10:26 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
plotCanvas.css(plotCss);
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
var options = {
|
|
|
|
|
legend: { show: false },
|
|
|
|
|
series: {
|
|
|
|
|
lines: {
|
|
|
|
|
show: true,
|
|
|
|
|
fill: 1,
|
|
|
|
|
lineWidth: 1,
|
|
|
|
|
fillColor: panel.sparkline.fillColor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
yaxes: { show: false },
|
|
|
|
|
xaxis: {
|
|
|
|
|
show: false,
|
|
|
|
|
mode: "time",
|
|
|
|
|
min: ctrl.range.from.valueOf(),
|
|
|
|
|
max: ctrl.range.to.valueOf(),
|
|
|
|
|
},
|
|
|
|
|
grid: { hoverable: false, show: false },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
elem.append(plotCanvas);
|
|
|
|
|
|
|
|
|
|
var plotSeries = {
|
|
|
|
|
data: data.flotpairs,
|
|
|
|
|
color: panel.sparkline.lineColor
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$.plot(plotCanvas, [plotSeries], options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function render() {
|
|
|
|
|
if (!ctrl.data) { return; }
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
data = ctrl.data;
|
|
|
|
|
setElementHeight();
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
var body = getBigValueHtml();
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
if (panel.colorBackground && !isNaN(data.valueRounded)) {
|
|
|
|
|
var color = getColorForValue(data, data.valueRounded);
|
|
|
|
|
if (color) {
|
|
|
|
|
$panelContainer.css('background-color', color);
|
|
|
|
|
if (scope.fullscreen) {
|
|
|
|
|
elem.css('background-color', color);
|
|
|
|
|
} else {
|
|
|
|
|
elem.css('background-color', '');
|
2016-01-24 17:10:26 +01:00
|
|
|
}
|
|
|
|
|
}
|
2016-01-27 19:07:39 -05:00
|
|
|
} else {
|
|
|
|
|
$panelContainer.css('background-color', '');
|
|
|
|
|
elem.css('background-color', '');
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
elem.html(body);
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
if (panel.sparkline.show) {
|
|
|
|
|
addSparkline();
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
elem.toggleClass('pointer', panel.links.length > 0);
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
if (panel.links.length > 0) {
|
|
|
|
|
linkInfo = linkSrv.getPanelLinkAnchorInfo(panel.links[0], panel.scopedVars);
|
|
|
|
|
} else {
|
|
|
|
|
linkInfo = null;
|
2016-01-24 17:10:26 +01:00
|
|
|
}
|
2016-01-27 19:07:39 -05:00
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
function hookupDrilldownLinkTooltip() {
|
|
|
|
|
// drilldown link tooltip
|
|
|
|
|
var drilldownTooltip = $('<div id="tooltip" class="">hello</div>"');
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
elem.mouseleave(function() {
|
|
|
|
|
if (panel.links.length === 0) { return;}
|
|
|
|
|
drilldownTooltip.detach();
|
|
|
|
|
});
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
elem.click(function(evt) {
|
|
|
|
|
if (!linkInfo) { return; }
|
|
|
|
|
// ignore title clicks in title
|
|
|
|
|
if ($(evt).parents('.panel-header').length > 0) { return; }
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
if (linkInfo.target === '_blank') {
|
|
|
|
|
var redirectWindow = window.open(linkInfo.href, '_blank');
|
|
|
|
|
redirectWindow.location;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
if (linkInfo.href.indexOf('http') === 0) {
|
|
|
|
|
window.location.href = linkInfo.href;
|
|
|
|
|
} else {
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$location.url(linkInfo.href);
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
drilldownTooltip.detach();
|
|
|
|
|
});
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
elem.mousemove(function(e) {
|
|
|
|
|
if (!linkInfo) { return;}
|
2016-01-24 17:10:26 +01:00
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
drilldownTooltip.text('click to go to: ' + linkInfo.title);
|
|
|
|
|
drilldownTooltip.place_tt(e.pageX+20, e.pageY-15);
|
|
|
|
|
});
|
2016-01-24 17:10:26 +01:00
|
|
|
}
|
2016-01-27 19:07:39 -05:00
|
|
|
}
|
2016-01-24 17:10:26 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-25 16:27:00 +01:00
|
|
|
function getColorForValue(data, value) {
|
|
|
|
|
for (var i = data.thresholds.length; i > 0; i--) {
|
2016-01-28 01:11:26 +01:00
|
|
|
if (value >= data.thresholds[i-1]) {
|
2016-01-25 16:27:00 +01:00
|
|
|
return data.colorMap[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return _.first(data.colorMap);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-27 19:07:39 -05:00
|
|
|
export {
|
2016-02-04 15:04:07 +01:00
|
|
|
SingleStatCtrl,
|
|
|
|
|
SingleStatCtrl as PanelCtrl,
|
2016-01-27 19:07:39 -05:00
|
|
|
getColorForValue
|
|
|
|
|
};
|