Today I would like to be able to add their own buttons in the Echarts Toolbox, and then read the Toolbox code, I tried, the verification is OK.
1. Effect drawing
2, Code
selfbuttons:{//custom button Danielinbiti, here is added, Selfbuttons can be arbitrarily named
show:true,//whether
title: ' Custom ',//mouse Move up to display text
icon: ' test.png ',//icon
option:{},
onclick:function (option1) {//click event, here option1 is chart option information
Alert (' 1 ')///Here you can add your own processing code, switch different graphics
}
}
The position in the Toolbox
Toolbox: {
show:true,
feature: {
mark: {show:true},
DataView: {show:true, readonly:false},
Mag Ictype: {show:true, type: [' line ', ' Bar ']},
restore: {show:true},
selfbuttons:{//custom button Danielinbiti, add here, Selfbuttons can take the name
show:true,//whether or not to display
title: ' Custom ',///mouse Move up to display the text
icon: ' test.png ',//icon
option:{},
onclick:function (option1) {//click event, where Option1 is the chart option message
alert (' 1 ');//Here you can add your own processing code, switch to different graphics
}
},
saveasimage: {show:true}
}
}
Of course, there are many icons built in, and these icons are all drawn.
iconLibrary: {
mark: _iconMark,
markUndo: _iconMarkUndo,
markClear: _iconMarkClear,
dataZoom: _iconDataZoom,
dataZoomReset: _iconDataZoomReset,
restore: _iconRestore,
lineChart: _iconLineChart,
barChart: _iconBarChart,
pieChart: _iconPieChart,
funnelChart: _iconFunnelChart,
forceChart: _iconForceChart,
chordChart: _iconChordChart,
stackChart: _iconStackChart,
tiledChart: _iconTiledChart,
dataView: _iconDataView,
saveAsImage: _iconSave,
cross: _iconCross,
circle: _iconCircle,
rectangle: _iconRectangle,
triangle: _iconTriangle,
diamond: _iconDiamond,
arrow: _iconArrow,
star: _iconStar,
heart: _iconHeart,
droplet: _iconDroplet,
pin: _iconPin,
image: _iconImage
}
With chart suffix are placed in the Magictype type, while the suffix chart not, the program will automatically splicing, such as Linechart, write ' line '