我已经使用 Echart JS 创建了一个条形图,如何自定义标题栏的点击。我曾尝试使用 triggerEvent,但它不适用于单击标题,它仅适用于统计信息。
var myChart = echarts.init(document.getElementById('main'));
function openTab(){
// Custom code will go here
return 'https://www.google.com'
}
option = {
title: {
x: 'left',
text: '12 total',
link : function(){
openTab();
}
},
grid: {
left: 50,
top: 50,
right: 50,
bottom: 0
},
xAxis: [{
type: 'category',
show: false,
data: ['Test 1', 'Test 2']
}],
yAxis: [{
type: 'value',
show: false,
min: 0
}],
series: [{
type: 'bar',
itemStyle: {
normal: {
color: '#3b4563',
label: {
show: true,
position: 'top',
formatter: '{c} {b}'
}
}
},
data: ['2', '10']
}]
};
myChart.setOption(option);
我用过https://ecomfe.github.io/echarts-examples/public/index.html#chart-type-bar