没错,只要在option里加入toolbox就行
toolbox: {
show : true,
feature : {
/* line是折线图,bar是柱形图*/
magicType: {show: true, type: ['line', 'bar']},
}
},
完整代码:
option = {
title : {
text: '测试',
x: 'center',//标题居中
subtext:"查看明细",//副标题
sublink:'#',//副标题点击跳转路径
subtarget:'self',//当前页面跳转
subtextStyle: {//副标题的属性
color: '#25664A',
fontStyle:'normal',//主标题文字字体风格,默认normal,有italic(斜体),oblique(斜体)
fontWeight:"lighter",//可选normal(正常),bold(加粗),bolder(加粗),lighter(变细),100|200|300|400|500...
fontFamily:"san-serif",//主题文字字体,默认微软雅黑
fontSize:12
},
},
tooltip : {
trigger: 'axis'
},
//柱形图和折线图相互切换
toolbox: {
show : true,
feature : {
/* line是折线图,bar是柱形图*/
magicType: {show: true, type: ['line', 'bar']},
}
},
calculable : false,//图形固定不能移动
xAxis : [
{
type : 'category',
data : ['Ⅰ级','Ⅱ级','Ⅲ级','Ⅳ级','Ⅴ级']
}
],
yAxis : [
{
type : 'value',
name : '数量',
axisLabel : {
formatter: '{value}'
}
}
],
series : [
{
name:'单位数量',
type:'bar',
barWidth:40,//宽度
data:mainData,
//显示数值
itemStyle : { normal: {label : {
show: true
}}}
}
]
};
效果图如下: