因此,当我有一个只有 0 数据(例如丢包测量)的图表时,除非您隐式定义最大值和最小值,否则不会绘制 Y 轴。
但是,我需要使用 0 数据自动绘制图表而不指定最大值,因为可能并不总是知道最大值(例如数据吞吐量)。
http://jsfiddle.net/fYkQy/2/显示了我得到的。见附件代码
$(document).ready(function () {
Highcharts.setOptions({
global: {
useUTC: false
}
});
PacketLoss = new Highcharts.StockChart({
chart: {
renderTo: 'container',
defaultSeriesType: 'line',
spacingRight: 30,
spacingBottom: 45,
width: 600,
height: 400
},
rangeSelector: {
enabled: false
},
title: {
text: 'PacketLoss'
},
scrollbar: {
liveRedraw: true
},
navigator: {
adaptToUpdatedData: true
},
xAxis: {
type: 'datetime',
tickPixelInterval: 80,
maxZoom: 1440 * 1000
},
yAxis: {
minPadding: 0.2,
maxPadding: 0.2,
min: 0,
offset: 35,
title: {
text: 'PacketLoss (%)',
margin: 12
}
},
tooltip: {
valueDecimals: 2,
valueSuffix: "%"
},
plotOptions: {
line: {
marker: {
enabled: false,
states: {
hover: {
enabled: true,
radius: 5
}
}
},
shadow: false
}
},
legend: {
enabled: true,
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
x: 30,
y: 35,
floating: true,
shadow: true
},
series: [{
name: 'PacketLoss',
color: '#660000',
zIndex: 100,
data: [[1373354992000,0],[1373361195000,0],[1373363923000,0],[1373380804000,0],[1373388550000,0],[1373392475000,0],[1373399655000,0],[1373409555000,0],[1373409858000,0],[1373410160000,0],[1373410765000,0],[1373411067000,0],[1373411369000,0],[1373411670000,0],[1373411971000,0],[1373412273000,0],[1373412574000,0],[1373412875000,0],[1373413177000,0],[1373413479000,0],[1373413780000,0],[1373414082000,0],[1373414384000,0],[1373414686000,0],[1373414988000,0],[1373415289000,0],[1373415591000,0],[1373415893000,0],[1373416196000,0],[1373416497000,0],[1373416799000,0],[1373417101000,0],[1373417402000,0],[1373417704000,0],[1373418006000,0],[1373418308000,0],[1373418610000,0],[1373418911000,0],[1373419212000,0],[1373419514000,0],[1373419819000,0],[1373420120000,0],[1373420421000,0],[1373420723000,0],[1373421025000,0],[1373421326000,0],[1373421628000,0],[1373421929000,0],[1373422231000,0],[1373422532000,0],[1373422834000,0],[1373423136000,0],[1373425197000,0],[1373432327000,0]]
}]
});
});
http://jsfiddle.net/aBsqz/显示了设置最大值和最小值的外观(适用于百分比值,但不适用于未知值。
$(document).ready(function () {
Highcharts.setOptions({
global: {
useUTC: false
}
});
PacketLoss = new Highcharts.StockChart({
chart: {
renderTo: 'container',
defaultSeriesType: 'line',
spacingRight: 30,
spacingBottom: 45,
width: 600,
height: 400
},
rangeSelector: {
enabled: false
},
title: {
text: 'PacketLoss'
},
scrollbar: {
liveRedraw: true
},
navigator: {
adaptToUpdatedData: true
},
xAxis: {
type: 'datetime',
tickPixelInterval: 80,
maxZoom: 1440 * 1000
},
yAxis: {
minPadding: 0.2,
maxPadding: 0.2,
min: 0,
max: 100,
offset: 35,
title: {
text: 'PacketLoss (%)',
margin: 12
}
},
tooltip: {
valueDecimals: 2,
valueSuffix: "%"
},
plotOptions: {
line: {
marker: {
enabled: false,
states: {
hover: {
enabled: true,
radius: 5
}
}
},
shadow: false
}
},
legend: {
enabled: true,
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
x: 30,
y: 35,
floating: true,
shadow: true
},
series: [{
name: 'PacketLoss',
color: '#660000',
zIndex: 100,
data: [[1373354992000,0],[1373361195000,0],[1373363923000,0],[1373380804000,0],[1373388550000,0],[1373392475000,0],[1373399655000,0],[1373409555000,0],[1373409858000,0],[1373410160000,0],[1373410765000,0],[1373411067000,0],[1373411369000,0],[1373411670000,0],[1373411971000,0],[1373412273000,0],[1373412574000,0],[1373412875000,0],[1373413177000,0],[1373413479000,0],[1373413780000,0],[1373414082000,0],[1373414384000,0],[1373414686000,0],[1373414988000,0],[1373415289000,0],[1373415591000,0],[1373415893000,0],[1373416196000,0],[1373416497000,0],[1373416799000,0],[1373417101000,0],[1373417402000,0],[1373417704000,0],[1373418006000,0],[1373418308000,0],[1373418610000,0],[1373418911000,0],[1373419212000,0],[1373419514000,0],[1373419819000,0],[1373420120000,0],[1373420421000,0],[1373420723000,0],[1373421025000,0],[1373421326000,0],[1373421628000,0],[1373421929000,0],[1373422231000,0],[1373422532000,0],[1373422834000,0],[1373423136000,0],[1373425197000,0],[1373432327000,0]]
}]
});
});
这是一个错误吗?还是我启动错误?不确定此错误是否仅在 highstock 前叉中可见。
谢谢