Skip to content

Commit

Permalink
Merge remote-tracking branch 'grafana/master' into table-fixes
Browse files Browse the repository at this point in the history
* grafana/master:
  Singlestat: fixes issue with value placement and line wraps (grafana#17249)
  Devenv: Update Graphite port in dev datasources (grafana#17255)
  • Loading branch information
ryantxu committed May 24, 2019
2 parents d89beb3 + 6acc7d3 commit 117396d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion devenv/datasources.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

apiVersion: 1

datasources:
- name: gdev-graphite
type: graphite
access: proxy
url: http://localhost:8080
url: http://localhost:8180
jsonData:
graphiteVersion: "1.1"

Expand Down
7 changes: 5 additions & 2 deletions public/app/plugins/panel/singlestat/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 1 addition & 5 deletions public/sass/components/_panel_singlestat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 117396d

Please sign in to comment.