伊谢尔伦2017-04-10 18:09:42
题主创建mychart的时候还是ec.init() 等mychart2的时候怎么就变成echarts了。。。在function(ec){}中 统一用ec
阿神2017-04-10 18:09:42
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<p id="main" style="height:600px"></p>
<script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
<script>
require.config({
paths:{
echarts:'http://echarts.baidu.com/build/dist'
}
});
require(
[
'echarts',
'echarts/chart/bar'
],
function (ec){
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>