点击柱子
import ReactEcharts from 'echarts-for-react';
const Demo = () => {
const getOption = {
grid: {
top: 80, right: 36, bottom: 70, left: 38,
},
title: [
{
text: '',
left: 'lefter',
},
],
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [120, 200, 150, 80, 70, 110, 130],
type: 'bar',
},
],
};
return <>
<ReactEcharts
style={{
height: '430px',
width: '1200',
border: '1px solid #dadada',
}}
option={getOption}
onEvents={{
click: (info) => {
console.log(
info.dataIndex,
info.seriesIndex,
info.value,
info.name,
info.seriesName,
info.seriesType,
info.color,
);
},
}}
/>
</>
}