flag事件
调试运行
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>图形展示</title>
</head>
<body>
<div class="detail-section">
<div id="canvas">
</div>
</div>
<script src="http://g.tbcdn.cn/bui/acharts/1.0.32/acharts-min.js"></script>
<!-- https://g.alicdn.com/bui/acharts/1.0.29/acharts-min.js -->
<script type="text/javascript">
var chart = new AChart({
theme : AChart.Theme.SmoothBase,
id : 'canvas', //render改成 id
width : 950,
height : 500,
plotCfg : {
margin : [50,50,80] //画板的边距
},
xAxis : {
categories : ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
},
tooltip : {
valueSuffix : '°C'
},
seriesOptions: {
flagCfg:{
flags:{
events: {
//点击事件
flagclick: function(ev){
console.log('click');
},
//鼠标移入
flagover: function(ev){
console.log('over');
},
//鼠标移出
flagout: function(ev){
console.log('out');
}
}
}
}
},
series : [{
id: 's1',
type: 'line',
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
type: 'line',
name: 'Beijing',
data: [13.9, 14.2, 15.7, 18.5, 21.9, 25.2, 27.0, 26.6, 24.2, 20.3, 16.6, 14.8]
},{
name: 'flag',
data:[{
x : '一月',
html : '<span><img width="15.5" height="19" src="https://i.alipayobjects.com/i/ecmng/png/201408/3Ds9p7HMph_src.png" /></span>'
},{
x : '一月'
},{
x : '十一月'
},{
x : '十二月'
}],
type: 'flag',
onSeries: 's1' //定义flag坐落的series
}]
});
chart.render();
//绑定点击事件
chart.on('flagclick',function(ev){
console.log('click');
});
//绑定hover事件
chart.on('flagmouseover',function(ev){
console.log('over');
});
chart.on('flagmouseout',function(ev){
console.log('out');
});
</script>
</body>
</html>