Singlestat: fixes issue with value placement and line wraps (#17249)
Fixes #17237
(cherry picked from commit 6acc7d37da)
This commit is contained in:
committed by
Marcus Efraimsson
parent
dce4514f7f
commit
ef359424a5
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user