數(shù)據(jù)計算直接用nodejs提供 一個本地http服務(wù)
var http = require('http');
http.createServer(function (request, response) {
response.setHeader("Access-Control-Allow-Origin", "*")
response.writeHead(200, {'Content-Type': 'text/plain'})
//
let indata = fs.readFileSync('./point0_resp.txt').toString();
let outArray = [];
for (let index = 0; index < indataArray.length; index++) {
if (index%3 == 0) {
outArray.push(indataArray[index])
}
}
response.end(JSON.stringify(outArray));
}).listen(8081);
console.log('Server running at http://127.0.0.1:8081/');
圖表和顯示端:
直接用echart 在線代碼顯示 :順便加個放大和鼠標經(jīng)過數(shù)值顯示功能
https://echarts.apache.org/examples/zh/editor.html?c=line-simple
option = {
xAxis: {
type: 'category'
},
yAxis: {
type: 'value'
},
toolbox: {
show:true,
feature:{
dataZoom: {
yAxisIndex:"none"
},
//其他功能性按鈕查看官網(wǎng)進行增加,包括(顯示數(shù)據(jù),下載圖片,改為柱狀圖等)
}
},
tooltip : {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line'
}
]
};
//ajax 獲取處理過的數(shù)據(jù)
fetch('http://127.0.0.1:8081/')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
// console.log(myJson);
myChart.setOption({
series: [
{
data: myJson,
}
]
})
});