v-charts 和 websocket實現數據展示動態推送
v-charts
https://v-charts.js.org/#/
ELEMENT力作:
在使用 echarts 生成圖表時,經常需要做繁瑣的數據類型轉化、修改復雜的配置項,v-charts 的出現正是為了解決這個痛點。基於 Vue2.0 和 echarts 封裝的 v-charts 圖表組件,只需要統一提供一種對前後端都友好的數據格式設置簡單的配置項,便可輕松生成常見的圖表。
websocket (socket.io)
https://socket.io/
實時分析,例如淘寶的雙十一的大屏幕。
二進制流媒體, 圖片、音頻、視頻。
即時消息,聊天應用。
Real-time analytics
Push data to clients that gets represented as real-time counters, charts or logs.
Binary streaming
Starting in 1.0, it‘s possible to send any blob back and forth: image, audio, video.
Instant messaging and chat
Socket.IO‘s "Hello world" is a chat app in just a few lines of code.
Document collaboration
Allow users to concurrently edit a document and see each other‘s changes.
例子
https://socket.io/get-started/chat/
自我實現例子
https://github.com/fanqingsong/web_data_visualization
實現思路:
1、 後臺定時推送數據到前臺(websocket-server and client)。
2、 前臺接收到數據後,使用v-charts柱狀圖顯示。
後臺更新數據推送時刻,前臺就徽更新柱狀圖。
運行命令
# serve with hot reload at localhost:8080
npm run dev
# start websocket server
npm run websocket
v-charts 和 websocket實現數據展示動態推送