소스 검색

fix(singlestat): adds support for fontsizes in gagues

bergquist 9 년 전
부모
커밋
0c6841bdc7
1개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 10 2
      public/app/plugins/panel/singlestat/module.ts

+ 10 - 2
public/app/plugins/panel/singlestat/module.ts

@@ -328,7 +328,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
             value: {
             value: {
               color: panel.colorValue ? getColorForValue(data, data.valueRounded) : null,
               color: panel.colorValue ? getColorForValue(data, data.valueRounded) : null,
               formatter: function () { return data.valueFormated; },
               formatter: function () { return data.valueFormated; },
-              font: { size: 30 }
+              font: { size: getGaugeFontSize() }
             },
             },
             show: true
             show: true
           }
           }
@@ -344,6 +344,15 @@ class SingleStatCtrl extends MetricsPanelCtrl {
       $.plot(plotCanvas, [plotSeries], options);
       $.plot(plotCanvas, [plotSeries], options);
     }
     }
 
 
+    function getGaugeFontSize() {
+      if (panel.valueFontSize) {
+        var num = parseInt(panel.valueFontSize.substring(0, panel.valueFontSize.length - 1));
+        return 30 * (num / 100);
+      } else {
+        return 30;
+      }
+    }
+
     function addSparkline() {
     function addSparkline() {
       var width = elem.width() + 20;
       var width = elem.width() + 20;
       if (width < 30) {
       if (width < 30) {
@@ -405,7 +414,6 @@ class SingleStatCtrl extends MetricsPanelCtrl {
 
 
     function render() {
     function render() {
       if (!ctrl.data) { return; }
       if (!ctrl.data) { return; }
-
       data = ctrl.data;
       data = ctrl.data;
       setElementHeight();
       setElementHeight();