匿名用户
1级
2017-07-08 回答
<div id="p"></div>
// 路径配置
require.config({
paths: {
'echarts': '/public/echarts-2.2.7/doc/example/www/js'
}
});
// 使用
require(
[
'echarts',
'echarts/chart/pie'
.
.
.
], DrawCharts);
function DrawCharts(ec) {
var char1 = ec.init(document.getElementById('p'));
var ecConfig = require('echarts/config');
char1.on(ecConfig.EVENT.CLICK, eConsole);
......//正常的echarts
}
//点击事件
function eConsole(param) {
if (typeof param.seriesIndex == 'undefined') {
return;
}
if (param.type == 'click') {
var name = param.name;
alert(name)
}
}
重点就是 :
var ecConfig = require('echarts/config');
char1.on(ecConfig.EVENT.CLICK, eConsole);
这两步
请~~,谢谢