svelte-echarts icon indicating copy to clipboard operation
svelte-echarts copied to clipboard

Click Event for bar chart

Open MuslemRahimi opened this issue 1 year ago • 1 comments

Hi,

I have a simple bar chart where i want to add a click event when the user clicks on one of the bars.

For example it should for now print "console.log('click received')".

Do you know a simple way to do this?

MuslemRahimi avatar May 25 '23 21:05 MuslemRahimi

This issue is related. Unfortunately I am currently not able to implement something more robust. But I left a comment which should help you in accessing the rest of the ECharts API.

DrStrangeloovee avatar Jun 01 '23 11:06 DrStrangeloovee

implemented in v1.0.0-rc1

bherbruck avatar May 20 '24 21:05 bherbruck

how can I implement a click on a element, I cannot figure out

0x090909 avatar Jun 09 '24 20:06 0x090909

I ended up adding an on:click attribute to determine which bar was clicked:

<Chart {init} {options} on:click={handleBarClick} />
function handleBarClick(params: any) {
  console.log(params.detail.name);
}

hbcondo avatar Jun 12 '24 17:06 hbcondo