bherbruck / svelte-echarts

Apache ECharts wrapper for Svelte
https://bherbruck.github.io/svelte-echarts/
MIT License
91 stars 6 forks source link

Click Event for bar chart #3

Closed MuslemRahimi closed 6 months ago

MuslemRahimi commented 1 year ago

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?

DrStrangeloovee commented 1 year ago

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.

bherbruck commented 6 months ago

implemented in v1.0.0-rc1

0x090909 commented 5 months ago

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

hbcondo commented 5 months ago

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);
}