question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ApexCharts events not working with vue3

See original GitHub issue

I’ve been trying to fire an event whenever someone clicks somewhere on the chart but I’ve been unable to do it with a vue3 project setup. My charts are showing fine but firing events does not work.

I’ve used the following code:

<apexchart type="rangeBar" width="500px" :options="chartOptions" :series="series"></apexchart>

setup() {
    const series = [
            {
              name: 'Sunny',
              data: [
                {
                  x: 'Weather',
                  y: [
                    new Date('2019-03-05').getTime(),
                    new Date('2019-03-08').getTime()
                  ]
                },
              ]
            },
            {
              name: 'Rainy',
              data: [
                {
                  x: 'Weather',
                  y: [
                    new Date('2019-03-02').getTime(),
                    new Date('2019-03-05').getTime()
                  ]
                },
              ]
            }
          ];

  const chartOptions = {
            chart: {
              height: 800,
              width: 800,
              type: 'rangeBar',
              events: {
                    click(event, chartContext, config) {
                        alert(event, chartContext, config);
                    }
                },  
              
            },
            plotOptions: {
              bar: {
                horizontal: true
              }
            },
            
            fill: {
              type: 'gradient',
              gradient: {
                shade: 'light',
                type: 'vertical',
                shadeIntensity: 0.25,
                gradientToColors: undefined,
                inverseColors: true,
                opacityFrom: 1,
                opacityTo: 1,
                stops: [50, 0, 100, 100]
              }
            },
            xaxis: {
              type: 'datetime'
            },
            title: {
              text: "Scene Viewer",
              align: "center",
              style: {
                fontSize: "15px"
              }
            },
            legend: {
              position: 'top'
            }
          };

        const options = {
        chart: {
          id: 'vuechart-example',
          events: {
                    click(event, chartContext, config) {
                        alert(event, chartContext, config);
                        console.log("wqewqeqeqweq")
                        alert("qwewqeqeqe")
                    }
                },  
        },
        xaxis: {
          categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998]
        }
      }
  }

Is anyone else having issues with events? Am I missing a piece of configuration? Any help would be greatly appreciated.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:9
  • Comments:8

github_iconTop GitHub Comments

10reactions
sam585456525commented, Jul 16, 2021

@ajkaeser image image

Here are all emits https://github.com/apexcharts/vue3-apexcharts/blob/main/src/vue3-apexcharts.js image

It is a wrapper to original ApexCharts events ! image

3reactions
ijcnvvcommented, Dec 30, 2021

there is no actual info about events in docs, but you should subscribe on events on component like <apex-chart :options="options" :series="series" @markerClick="handleClick" />

Read more comments on GitHub >

github_iconTop Results From Across the Web

Click event not working with ApexCharts (Vue3) - Stack Overflow
Apart from the events, my chart shows and works just fine. vue.js · vuejs3 · apexcharts · Share.
Read more >
ApexCharts events not working with vue3 - Vue Forum
I've been trying to fire an event whenever someone clicks somewhere on the chart but I've been unable to do it with a...
Read more >
How To Use Events on vue3-apexcharts - Jangwook Kim
If you are stuck to use events on vue3-apexcharts, this article is useful to you. ... [TroubleShooting] How to rollback a dropped stash?...
Read more >
[Solved]-Click event not working with ApexCharts (Vue3)-Vue.js
Coding example for the question Click event not working with ApexCharts (Vue3)-Vue.js.
Read more >
A Vue Chart wrapper for ApexCharts.js
import VueApexCharts from "vue3-apexcharts"; const app = createApp(App); app.use(VueApexCharts); // The app.use(VueApexCharts) will make <apexchart> component ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found