企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## code ``` <div id="local_cpu" style="width: 550px;height:300px;"></div> <script type="text/javascript"> var myChart, option; var now_time=new Date().getTime(); var data = []; var data1 = []; myChart = echarts.init(document.getElementById('local_cpu')); option = { tooltip: { trigger: 'axis', }, xAxis: { // value用于连续, category用于散点,因为x轴为日期,所以用category // 用 time, 后 y 轴数据是二维的,第一行数据为时间(new Date()) type: 'time', name: "时间(秒)", }, yAxis: { type: 'value', boundaryGap: [0, '100%'], show: true, name: "值" }, dataZoom: { type: "inside" }, series: [ { name: "测试1", data: data, type: 'line', smooth: true, showSymbol: false, }, { name: "测试2", data: data1, type: 'line', smooth: true, showSymbol: false, } ] }; myChart.setOption(option) setInterval(function () { let date = new Date(); data.push([date,Math.random().toFixed(2)*100]); data1.push([date,Math.random().toFixed(2)*80]); myChart.setOption({ series: [ { data: data }, { data: data1 } ] }) }, 1000) </script> ``` 效果图 ![](https://img.kancloud.cn/47/2d/472d59ea9dd9b29f400806862f9a1bbb_537x314.png)