Echarts2绘制动态曲线图并给出完整代码
来源:互联网 发布:nginx 域名不能访问 编辑:程序博客网 时间:2024/05/17 08:18
标签式单文件引入
http://echarts.baidu.com/echarts2/doc/doc.html#引入ECharts2
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>ECharts</title></head><body><!--Step:1 Prepare a dom for ECharts which (must) has size (width & hight)--><!--Step:1 为ECharts准备一个具备大小(宽高)的Dom--><div id="main" style="height:500px;border:1px solid #ccc;padding:10px;"></div><!--Step:2 Import echarts-all.js--><!--Step:2 引入echarts-all.js<script src="js/echarts-all.js"></script>--><script src="http://echarts.baidu.com/build/dist/echarts-all.js"></script><script type="text/javascript">// Step:3 echarts & zrender as a Global Interface by the echarts-plain.js.// Step:3 echarts和zrender被echarts-plain.js写入为全局接口var timeTicket;var myChart = echarts.init(document.getElementById('main'));option = { title : { text: '动态数据', subtext: '纯属虚构' }, tooltip : { trigger: 'axis' }, legend: { data:['最新成交价', '预购队列'] }, toolbox: { show : true, feature : { mark : {show: true}, dataView : {show: true, readOnly: false}, magicType : {show: true, type: ['line', 'bar']}, restore : {show: true}, saveAsImage : {show: true} } }, dataZoom : { show : false, start : 0, end : 100 }, xAxis : [ { type : 'category', boundaryGap : true, data : (function (){ var now = new Date(); var res = []; var len = 10; while (len--) { res.unshift(now.toLocaleTimeString().replace(/^\D*/,'')); now = new Date(now - 2000); } return res; })() }, { type : 'category', boundaryGap : true, data : (function (){ var res = []; var len = 10; while (len--) { res.push(len + 1); } return res; })() } ], yAxis : [ { type : 'value', scale: true, name : '价格', boundaryGap: [0.2, 0.2] }, { type : 'value', scale: true, name : '预购量', boundaryGap: [0.2, 0.2] } ], series : [ { name:'预购队列', type:'bar', xAxisIndex: 1, yAxisIndex: 1, data:(function (){ var res = []; var len = 10; while (len--) { res.push(Math.round(Math.random() * 1000)); } return res; })() }, { name:'最新成交价', type:'line', data:(function (){ var res = []; var len = 10; while (len--) { res.push((Math.random()*10 + 5).toFixed(1) - 0); } return res; })() } ]};var lastData = 11;var axisData;clearInterval(timeTicket);timeTicket = setInterval(function (){ lastData += Math.random() * ((Math.round(Math.random() * 10) % 2) == 0 ? 1 : -1); lastData = lastData.toFixed(1) - 0; axisData = (new Date()).toLocaleTimeString().replace(/^\D*/,''); // 动态数据接口 addData myChart.addData([ [ 0, // 系列索引 Math.round(Math.random() * 1000), // 新增数据 true, // 新增数据是否从队列头部插入 false // 是否增加队列长度,false则自定删除原有数据,队头插入删队尾,队尾插入删队头 ], [ 1, // 系列索引 lastData, // 新增数据 false, // 新增数据是否从队列头部插入 false, // 是否增加队列长度,false则自定删除原有数据,队头插入删队尾,队尾插入删队头 axisData // 坐标轴标签 ] ]);}, 2100);myChart.setOption(option);</script></body></html>
0 0
- Echarts2绘制动态曲线图并给出完整代码
- Android 绘制动态的曲线图
- android 自定义View 动态绘制曲线图
- iOS开发的动态曲线图绘制
- C#语言绘制实时曲线图代码实例
- C#语言绘制实时曲线图代码实例
- java三个数排序比较大小的完整代码,并给出详细解释,初学者,谢谢
- 初涉C#之读取txt文件并绘制坐标曲线图
- C# 绘制曲线图,并保存为Gif格式文件 调试通过
- 一个从CStatic派生的动态曲线图绘制控件
- 如何在Unity中使用OpenGL函数绘制动态曲线图
- echarts2.2.7动态数据填充
- asp.net 绘制曲线图
- 用owc11绘制曲线图
- MFC GDI 曲线图绘制
- 用Excel绘制曲线图
- mschart绘制曲线图
- c#绘制曲线图
- WIN32 API 函数大全
- struts中的配置文件
- cuda测试caffe编译安装
- 使用socket与线程实现简单机器人聊天
- Revit API 进阶之隐藏dll讲解.
- Echarts2绘制动态曲线图并给出完整代码
- 简单使用多线程和Socket,实现自动问答
- hdu 1024 Max Sum Plus Plus
- 关于昨天和今天自己效率低下的总结
- Mac OS X 使用 rc.local 开机执行命令设置方法
- CentOS系统通过PXE实现批量无人值守安装
- 安卓 电话黑名单拦截
- PreparedStatement与Statement的区别
- java之继承!!