2016-03-05 52 views
1

我有一個使用HighCharts的腳本。下面是處理形成所述yAxis的腳本的yAxis部分。我知道PHP變量「$ row_Rooms ['Rooms']」contains「400」,但是當我運行這個腳本時,我想知道PHP變量「$ row_Rooms ['Rooms']」 Y軸最大顯示 「420」Highcharts yaxis max

$(function() { 

var categories=[]; 
var data2 =[]; 


var chart; 
$(document).ready(function() { 

     $.getJSON("temp_hot_chart.php", function(json) { 
     $.each(json,function(i,el) { 
     if (el.name=="Count") 
     categories = el.data; 
     else data2.push(el); 
     }); 



     $('#container1').highcharts({ 
      chart: { 
       renderTo: 'container', 
       type: 'column', 
       marginTop: 60, 
       marginRight: 30, 
       marginBottom: 90, 
       plotBackgroundColor: '#FCFFC5' 
      }, 
      title: { 
       text: 'Failed hot water temperatures', 
       x: -20, //center 
       style: { 
       fontFamily: 'Tahoma', 
       color: '#000000', 
       fontWeight: 'bold', 
       fontSize: '11px' 
       } 
      }, 
      subtitle: { 
       text: '', 
       x: -20 
      }, 
      xAxis: { 
       labels: { 
        enabled: false 
       } 
      }, 

      yAxis: { 
       max:<?php echo $row_Rooms['Rooms'];?>, 
       reversedStacks: false, 
       showFirstLabel: false, 
       lineColor:'#999', 
       lineWidth:1, 
       tickColor:'#666', 
       tickWidth:1, 
       tickLength:2, 
       tickInterval: 10, 
       gridLineColor:'#ddd', 
       title: { 
        text: '', 
        style: { 
       fontFamily: 'Tahoma', 
       color: '#000000', 
       fontWeight: 'bold', 
       fontSize: '12px' 
       } 
       }, 
       plotLines: [{ 

        color: '#808080' 
       }] 
      }, 

       legend: { 
        enabled: true 
       }, 




       colors: [ 
       '#0066CC', 
       '#FF2F2F', 
       ], 

       plotOptions: { 

       series: { 
        legendIndex:0, 
        dataLabels: { 
        enabled: true, 
        //rotation: -90, 
        color: '#000000', 
        align: 'center', 
        //format: '{point.y:.1f}', // one decimal 
        y: 20, // 10 pixels down from the top 
        style: { 
         fontSize: '12px', 
         fontFamily: 'Verdana, sans-serif' 
         } 
        } 
       } 

      }, 




      credits: { 
       enabled: false 
      }, 


      series: data2 
     }); 
    }); 

}); 

});

誰能扔任何光線上爲什麼會發生很多感謝您的時間

問候

+0

嘗試將endOnTick值爲false作爲其默認的是真實的,可以實現最大的價值。 http://api.highcharts.com/highcharts#yAxis.max – Todd

+0

嗨託德,閱讀HighCharts文件Max是自動取整的,所以我不認爲我可以做我需要的。但許多人會回答您的問題。 – DCJones

+0

你有沒有嘗試Todd的解決方案? –

回答

1

使用endOnTick並將其設置爲false, 作爲文檔http://api.highcharts.com/highcharts#yAxis.endOnTickhttp://api.highcharts.com/highcharts#yAxis.max

如果endOnTick選項爲true,最高值可能會四捨五入

請檢查下面example描述:

$(function() { 
    $('#container').highcharts({ 
     chart: { 
      plotBorderWidth: 1 
     }, 
     xAxis: { 
      categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] 
     }, 
     yAxis: { 
      endOnTick: false, 
      max:101, 
     }, 
     series: [{ 
      data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] 
     }] 
    }); 
}); 
0

嘗試添加alignTicks:假到圖表塊:

chart: { 
     alignTicks: false 
    } 

希望它可以幫助