Singlestat: fixes issue with value placement and line wraps (#17249)

Fixes #17237
This commit is contained in:
Torkel Ödegaard 2019-05-24 08:52:47 +02:00 committed by Dominik Prokop
parent a7aaed49b5
commit 6acc7d37da
2 changed files with 6 additions and 7 deletions

View File

@ -11,6 +11,8 @@ import TimeSeries from 'app/core/time_series2';
import { MetricsPanelCtrl } from 'app/plugins/sdk';
import { GrafanaThemeType, getValueFormat, getColorFromHexRgbOrName, isTableData } from '@grafana/ui';
const BASE_FONT_SIZE = 38;
class SingleStatCtrl extends MetricsPanelCtrl {
static templateUrl = 'module.html';
@ -384,10 +386,11 @@ class SingleStatCtrl extends MetricsPanelCtrl {
return valueString;
}
function getSpan(className, fontSize, applyColoring, value) {
function getSpan(className, fontSizePercent, applyColoring, value) {
value = $sanitize(templateSrv.replace(value, data.scopedVars));
value = applyColoring ? applyColoringThresholds(value) : value;
return '<span class="' + className + '" style="font-size:' + fontSize + '">' + value + '</span>';
const pixelSize = (parseInt(fontSizePercent, 10) / 100) * BASE_FONT_SIZE;
return '<span class="' + className + '" style="font-size:' + pixelSize + 'px">' + value + '</span>';
}
function getBigValueHtml() {

View File

@ -6,17 +6,13 @@
}
.singlestat-panel-value-container {
// line-height 0 is imporant here as the font-size is on this
// level but overriden one level deeper and but the line-height: is still
// based on the base font size on this level. Using line-height: 0 fixes that
line-height: 0;
display: table-cell;
vertical-align: middle;
text-align: center;
position: relative;
z-index: 1;
font-weight: $font-weight-semi-bold;
font-size: 38px;
line-height: 1;
}
// Helps