我制作了一张高价图表,但无法显示2期数据。 1.行只能在单击图例“db2”后显示,但如果再次单击“db2”图例,则两行同时消失。 2.如果单击导航栏,则无法再显示这些行。
在图表中有更多数据时,我找不到错误,与数据集有关系吗?
任何回应都表示赞赏。
http://jsfiddle.net/freedba/PE8w9/
$(function() {
chart = new Highcharts.StockChart({
chart : {
renderTo : 'container',
events: {
load: function(){
this.series[1].hide();
}}
},
title : {
text : 'CPU Usage'
},
rangeSelector : {
inputEnabled: false,
enabled : false
},
legend : {
enabled : true,
align: 'center',
margin: 1,
verticalAlign: 'top',
y: 40
},
series : [{
name: 'db1',
data: [[1362329987000,66.392],[1362329987000,58.461],[1362333587000,69.202],[1362335387000,57.733],[1362337187000,64.396],[1362337187000,95.374],[1362340786000,70.336],[1362342587000,68.595],[1362342587000,57.584],[1362344386000,70.062],[1362346247000,57.603],[1362347987000,57.104],[1362351586000,58.707],[1362351586000,62.229],[1362353387000,66.306],[1362355186000,71.908],[1362356987000,75.329],[1362358787000,76.908],[1362360586000,78.672],[1362362387000,80.002],[1362366047000,76.953],[1362366047000,76.454],[1362367787000,77.292],[1362369587000,79.394],[1362371386000,79.407],[1362373187000,74.773],[1362376787000,73.813],[1362376787000,74.348],[1362380387000,80.611],[1362380387000,76.722],[1362383986000,74.372],[1362385787000,75.392],[1362385787000,77.195],[1362387587000,75.174],[1362389387000,76.475],[1362391187000,82.395],[1362392987000,73.701],[1362394787000,70.803],[1362396587000,68.749],[1362398387000,67.568],[1362400187000,69.154],[1362402047000,66.909],[1362403786000,76.237],[1362405587000,74.917],[1362407387000,65.742],[1362409187000,61.779],[1362410987000,60.812],[1362412786000,69.091],[1362416447000,64.922],[1362418187000,57.811],[1362418187000,66.428],[1362419986000,59.138],[1362423587000,56.253],[1362425387000,92.792],[1362427187000,78.373],[1362428987000,65.787],[1362430847000,63.182],[1362430847000,64.234],[1362432587000,64.637],[1362436186000,57.338],[1362437987000,59.004],[1362439787000,63.968],[1362439787000,67.604],[1362443387000,72.238],[1362443387000,74.873],[1362445187000,81.961],[1362447047000,82.649],[1362448786000,66.152],[1362452387000,57.261],[1362452387000,57.403],[1362454186000,55.278],[1362455987000,60.189],[1362457787000,63.292],[1362459587000,63.357]]
},{
name: 'db2',
data: [[1362328192000,19.118],[1362329992000,18.965],[1362333592000,19.702],[1362335392000,18.79],[1362335392000,20.061],[1362338992000,23.215],[1362340792000,21.204],[1362340792000,18.421],[1362344391000,17.965],[1362344391000,18.741],[1362347992000,17.357],[1362347992000,18.137],[1362351592000,19.581],[1362353392000,21.412],[1362353392000,21.419],[1362355192000,28.231],[1362356991000,30.765],[1362358792000,32.987],[1362362391000,33.341],[1362362391000,32.515],[1362366052000,32.571],[1362366052000,31.088],[1362367792000,29.784],[1362369591000,29.558],[1362371391000,29.819],[1362374992000,30.587],[1362374992000,29.463],[1362376791000,30.728],[1362378592000,30.446],[1362380392000,30.851],[1362382191000,36.051],[1362383991000,35.441],[1362385792000,33.209],[1362387591000,31.225],[1362389392000,30.339],[1362391192000,34.573],[1362392991000,27.501],[1362394792000,26.62],[1362396592000,26.338],[1362398392000,25.419],[1362400192000,25.533],[1362402052000,21.722],[1362403791000,24.724],[1362405592000,27.066],[1362407392000,26.831],[1362410992000,22.171],[1362410992000,20.194],[1362414591000,18.257],[1362416392000,19.01],[1362418192000,19.03],[1362418192000,19.437],[1362421792000,18.887],[1362421792000,20.634],[1362425391000,23.431],[1362427192000,20.834],[1362428992000,18.702],[1362428992000,18.851],[1362432592000,18.274],[1362434391000,17.454],[1362436192000,18.367],[1362436192000,19.625],[1362437991000,21.239],[1362439792000,21.598],[1362441592000,28.303],[1362443392000,30.406],[1362445191000,32.64],[1362447052000,31.959],[1362450591000,33.007],[1362450591000,31.138],[1362452391000,31.826],[1362454192000,29.662],[1362455991000,28.68],[1362457792000,29.442],[1362459591000,29.61]]
}]
});
});
答案 0 :(得分:0)
在StockChart
构造函数中添加:
xAxis: {
ordinal: false
},
我认为,由于您有一些具有重复X值的数据点,因此图表绘图会在没有此值的情况下失败。我注意到在加载页面时JS控制台中存在一些错误,与“宽度”或“x”属性为NaN相关,可能是因为某些地方delta-X值被用作除数或类似值。