我有一个使用HighCharts的脚本。下面是处理所述yAxis的形成的脚本的yAxis部分。其中我有"yAxis:max我正在尝试使用由查询产生的PHP变量。
我知道PHP变量"$row_Rooms'Rooms'“包含"400",但是当我运行脚本时,yAxis最大值显示为"420”。
$(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
});
});
});});
有没有人能解释为什么会发生这种情况。非常感谢您的宝贵时间。
致以问候。
发布于 2016-03-05 23:16:44
使用endOnTick并将其设置为false,如文档http://api.highcharts.com/highcharts#yAxis.endOnTick和http://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]
}]
});
});发布于 2016-05-09 15:43:00
尝试将alignTicks: false添加到图表块:
chart: {
alignTicks: false
}希望能有所帮助
https://stackoverflow.com/questions/35815314
复制相似问题