日期:2014-05-16 浏览次数:20668 次
waveLineImage = { chart: { renderTo: 'waveImage', //绘制到DIV容器中,根据ID defaultSeriesType: 'line', //绘制类型 目前是曲线 plotBorderWidth: 1, plotBorderColor: '#99CC99', marginRight: 12, showAxes: true }, title: { text: '', x: -20 //center }, xAxis: { tickWidth: 0, tickInterval: 5, gridLineWidth: 1, gridLineColor: '#99CC99', categories: [] }, yAxis: { title: { text: '' }, min: -1, tickInterval: 5, gridLineWidth: 1, gridLineColor: '#99CC99' }, plotOptions: { series: { animation: false, marker: { enabled: false } } }, tooltip: { enabled:false, formatter: function(){ return null; } }, legend: { enabled: false }, exporting: { enabled: false }, series: [{ name: "monitor", data: [] }, { name: "temp", data: [] }] }
maxSize = 0; lastSize = -1; var tempArray = null; function drawOscillogram(waveData){ if (waveData) { //传输过来的JSON数据 var dataArray = new Array(); var array = null, point = null, num = null,item = null; var waveDataLength = waveData.length; for (var i = 0; i < waveDataLength; i++) { array = waveData[i].split(","); point = 1 / array.length; for (var j = 0; j < array.length; j++) { num = i + Math.round((point * j) * 10) / 10; item = parseFloat(array[j]); if(maxSize<item) maxSize=item; dataArray.push([num, item]); num = null; } array = null; item = null; point = null; } if (waveDataLength < 60) { //当不足60个点时,创建一个临时的数据,绑定到temp当中 if (tempArray == null) { tempArray = new Array(); for (var i = 0; i < 61; i++) { tempArray.push([i, -6]); } } if(!waveLineImage.series[1]) waveLineImage.addSeries("",true,false); waveLineImage.series[1].data = tempArray; } else { tempArray = null; waveLineImage.series[1].remove(); } waveLineImage.series[0].data = dataArray; dataArray = null; waveDataLength = null; if(lastSize!=maxSize) { lastSize=maxSize; }else{ waveLineImage.redraw(); //重新绘制HighCharts图形,但是这个好像不能生成轴 } new Highcharts.Chart(waveLineImage); //绘制HIghcharts图形 } }