九州编程
var socket = io.connect(); //测试返回数据,连接成功 socket.on("test", function (data) { //console.log(data); }); var option = { chart: { renderTo: 'main', type: 'spline' /* 图标类型 */ }, title: { text: 'canvas', x: -20 //center }, xAxis: { categories: [] }, yAxis: { tickInterval: 100, //自定义刻度 max: 0, //纵轴的最大值 min: -100000, //纵轴的最小值 title: { text: 'dbm' } }, series: [{ data: [] },] } var chart =new Highcharts.Chart(option); //接收转发数据,格式json socket.on('pushToWebClient', function (useData) { var low = 100; //数据低频 var high = 900; //数据高频 var xArray = new function () { this.getJson = function () { var arr1 = []; for (var k = low; k < high; k++) { arr1.push(k); } return {'hz': arr1} } }(); var xData = xArray.getJson(); chart.series[0].setData(useData.dbm); chart.xAxis.categories=xData.hz; });