手动写的第一个eChart代码 ,第一感觉,杂乱无章
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>ECharts</title> </head> <body> <div id="main" class="" style="height:400px"></div> <script src="http://echarts.baidu.com/build/dist/echarts.js"></script> <script type="text/javascript"> <!-- //路径配置 require.config({ paths:{ echarts:'http://echarts.baidu.com/build/dist' } }); require( [ 'echarts', 'echarts/chart/bar' //是用柱状图就加载bar模块,按需加载 ], function(ec){ //基于准备好的dom,初始化echarts图标 var myChart = ec.init(document.getElementById('main')); var option={ tooltip:{ show:true }, legend:{ data:['销量'] }, xAxis:[ { type:'category', data:["衬衫","羊毛衫","雪纺纱","裤子","高跟鞋","袜子"] } ], yAxis:[ { type:'value' } ], series:[ { "name":"销量", "type":"bar", "data":[5,20,40,10,10,20] } ] }; myChart.setOption(option); } ); //--> </script> </body> </html>
都是啥玩意,一会是数组 一会是json 一会是函数,七拼八凑,图标结果还显示出来了,感觉是莫名其妙