问题——
1.数据没有显示;
2.series 里的name值不给图例就不显示
methos——
// 获取 websocket 返还数据
WS_2websocket.onmessage = function (res) {
// 转换接收到数据格式
let val = JSON.parse(res.data)
val = JSON.parse(val.listWS);
// 清空上次数据
that.cdata.Wind_Direction_2 = [];
that.cdata.Wind_Speed_2 = [];
//循环添加数据
for (let i=0; i<val.length; i++)
{
// that.cdata.lineData.push(val[i].time_ws_2);
that.cdata.Wind_Direction_2.push(val[i].Wind_Direction_2);
that.cdata.Wind_Speed_2.push(val[i].Wind_Speed_2);
console.log( that.cdata.Wind_Speed_2)//如图
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/687742152746189.png "#left")
}
option——
legend: {
show: true,
top: 70,
right: 0,
data: [
'24.5-28.4m/s',
'20.8-24.4m/s',
'17.2-20.7m/s',
'13.9-17.1m/s',
'10.8-13.8m/s',
'8.0-10.7m/s',
'5.5-7.9m/s',
'3.4-5.4m/s',
'1.6-3.3m/s',
'0.3-1.5m/s',
'0.0-0.2m/s'
],}
angleAxis: {
type: 'category',
// data: ['N', 'E', 'S', 'W', ],
data:newData.Wind_Direction_2,
}
series: [{
type: 'bar',
data:newData.Wind_Speed_2,
coordinateSystem: 'polar',
name: '0.0-0.2m/s',//要是不给这个,图例就不显示
},