2013-03-25 38 views
0

使用VU量規樣本的一個有趣的小「怪癖」。當我嘗試重新定位測量窗格時,數字顯示屏會消失。如果我保持< = 100%的位置,顯示屏將顯示任何> 100%的數字顯示消失。Highcharts VU儀表數字顯示消失

我曾多次試圖強制顯示回到可以看到的位置,但沒有運氣。有任何想法嗎?這裏是最新的測試小提琴:

VU Meter Fiddle

調整元件是容易的,使用窗格:部與顯示面板移動整個量規,使用datalabel:部分移動數字顯示器。

$(function() { 
var chart = new Highcharts.Chart({ 
    chart: { 
     renderTo: 'container', 
     type: 'gauge', 
     plotBorderWidth: 1, 
     plotBackgroundColor: { 
      linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, 
      stops: [ 
       [0, '#FFF4C6'], 
       [0.3, '#FFFFFF'], 
       [1, '#FFF4C6'] 
      ] 
     }, 
     plotBackgroundImage: null, 
     height: 200 
    }, 

    title: { 
     text: 'Efficiencies' 
    }, 
    /*** 
     in order to move the gauge up or down in the pane, adjust the 'Y' element in 
     the center array. Adjusting this above 100% (to move the gauge DOWN) 
     will cause the numeric display to disappear 
    ***/ 
    pane: [{ 
     startAngle: -45, 
     endAngle: 45, 
     background: null, 
     center: ['25%', '100%'], 
     size: 200 
    }, { 
     startAngle: -45, 
     endAngle: 45, 
     background: null, 
     center: ['75%', '105%'], 
     size: 200 
    }],       

    yAxis: [{ 
     min: 0, 
     max: 110, 
     minorTickPosition: 'outside', 
     tickPosition: 'outside', 
     labels: { 
      rotation: 'auto', 
      distance: 20 
     }, 
     plotBands: [{ 
      from: 0, 
      to: 70, 
      color: '#DF5353', // red 
      innerRadius: '100%', 
      outerRadius: '105%' 
     }, { 
      from: 70, 
      to: 95, 
      color: '#DDDF0D', // yellow 
      innerRadius: '100%', 
      outerRadius: '105%' 
     }, { 
      from: 95, 
      to: 110, 
      color: '#55BF3B', // green 
      innerRadius: '100%', 
      outerRadius: '105%' 
     }], 
     pane: 0, 
     title: { 
      text: '<span style="font-size:10px">OEE %</span><br/><span style="font-size:8px">Machine 001</span>', 
      y: -30 
     } 
    }, { 
     min: 0, 
     max: 110, 
     minorTickPosition: 'outside', 
     tickPosition: 'outside', 
     labels: { 
      rotation: 'auto', 
      distance: 20 
     }, 
     plotBands: [{ 
      from: 0, 
      to: 70, 
      color: '#DF5353', // red 
      innerRadius: '100%', 
      outerRadius: '105%' 
     }, { 
      from: 70, 
      to: 95, 
      color: '#DDDF0D', // yellow 
      innerRadius: '100%', 
      outerRadius: '105%' 
     }, { 
      from: 95, 
      to: 110, 
      color: '#55BF3B', // green 
      innerRadius: '100%', 
      outerRadius: '105%' 
     }], 
     pane: 1, 
     title: { 
      text: '<span style="font-size:10px">Cycle Eff %</span><br/><span style="font-size:8px">Machine 001</span>', 
      y: -30 
     } 
    }], 

    plotOptions: { 
     gauge: { 
      /*** 
       Adjusting the position of the numeric display is also easy 
       Change the y: component more negative move the display UP, 
       decreasing the value move the display DOWN 
      ***/ 
      dataLabels: { 
       enabled: true, 
       x: 0, 
       y: -120 
      }, 
      dial: { 
       radius: '110%' 
      } 
     } 
    }, 
    series: [{ 
     data: [80], 
     yAxis: 0 
    }, { 
     data: [80], 
     yAxis: 1 
    }] 

}, 

// Let the music play 
function(chart) { 
    setInterval(function() { 
     var left = chart.series[0].points[0], 
      right = chart.series[1].points[0], 
      leftVal, 
      //inc = (Math.random() - 0.5) * 30; 
      inc1 = Math.random() * (30) + 70; 
      inc2 = Math.random() * (30) + 70; 

     leftVal = left.y + inc1; 
     rightVal = right.y + inc2; ///3; 
     if (leftVal < 0 || leftVal > 110) { 
      //leftVal = left.y - inc; 
      leftVal = 110 - inc1; 
     } 
     if (rightVal < 0 || rightVal > 110) { 
      rightVal = 110 - inc2; 
     } 

     left.update(parseInt(leftVal),false); 
     right.update(parseInt(rightVal), false);//, false); 
     chart.redraw(); 

    }, 1500); 

}); 
}); 
+0

報告的問題,請參見:https://github.com/highslide-software/highcharts.com/issues/1657 – 2013-03-28 16:20:16

回答

2

如果使用dataLabels.crop = false選項,它會顯示出來。但是根據API描述,如果數據標籤也位於繪圖區域之外,它也會顯示出來,您可能不想要。 highcharts的行爲很奇怪,因爲它會查看系列是否在繪圖區域之外,而不是數據標籤在隱藏標籤時的位置,所以我同意這是一個錯誤。

http://api.highcharts.com/highcharts#plotOptions.series.dataLabels.crop

上跟蹤