jQuery插件echarts实现的循环生成图效果示例【附

利用for循环生产多个气泡图,并且每个气泡都可以点击

2、实现源码:

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>echarts-循环生成图</title> <script type="text/javascript" src="https://www.jb51.net/jquery-1.4.2.min.js" ></script> <script type="text/javascript" src="https://www.jb51.net/echarts.js" ></script> <style> body,html,#div-chart{ width: 99%; height: 100%; font-family: "微软雅黑"; font-size: 12px; } .chart{ width: 1200px; height: 100px; } </style> <script> $(document).ready(function(){ buildChart(); buildChartJS(); }); function buildChart() { $("#div-chart").empty(); var chart = ""; for(var i=0;i<8;i++) { chart += "<div></div>"; } $("#div-chart").append(chart); } function buildChartJS() { for(var i=0;i<8;i++) { var chart = document.getElementById('chart'+i); var echart = echarts.init(chart); var option = { legend: { data:['scatter1'], show:false }, splitLine:{      show:false    }, grid:{ borderWidth:0 }, xAxis : [ { show:false, type : 'value', splitNumber: 2, scale: true, axisLine:{ show:false }, splitLine:{      show:false    }, axisTick:{ show:false } } ], yAxis : [ { show:false, type : 'value', splitNumber: 2, scale: true, axisLine:{ show:false }, splitLine:{      show:false    } } ], series : [ { name:'scatter1', type:'scatter', symbol: 'emptyCircle', symbolSize: 20, itemStyle : { normal: { color:'#0068B7', label:{ show: true, position: 'inside', textStyle : { fontSize : 26, fontFamily : '微软雅黑', color:'#0068B7' } } } }, data: randomDataArray() } ] }; function eConsole(param) { alert(param.value); console.dir(param); } echart.on("click", eConsole); echart.setOption(option); } } function randomDataArray() { var d = []; var arr = [3,5,7,9,10,1,2,4,8,6]; var len = 10; for(var i=0;i<len;i++) { d.push([i+1,0,arr[i],]); } return d; } </script> </head> <body> <div></div> </body> </html>

3、实现效果图:

jQuery插件echarts实现的循环生成图效果示例【附

附:完整实例代码点击此处本站下载

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery常用插件及用法总结》、《jquery中Ajax用法总结》、《jQuery表格(table)操作技巧汇总》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwzwzd.html