I recently created a bar graph using Echart JS, but I'm struggling to customize the click event on the title bar. I attempted to use triggerEvent, but it only seems to work on statistics rather than the title itself.
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);
I referenced the following URL for guidance: