Giter Site home page Giter Site logo

Comments (12)

junedchhipa avatar junedchhipa commented on May 1, 2024 1

Thanks for the feedback. I think as it's deeply nested in the chart object, it might be difficult to find.
https://apexcharts.com/docs/options/chart/events/

I will add link to it in the main events page

from apexcharts.js.

FightRay avatar FightRay commented on May 1, 2024 1

Hey @junedchhipa , I am aware of this link and I have already seen it before. What I meant is that I have this object called chartOptions which contains the options for the chart, so I tried placing the events array in there, on the same level as colors and labels. It was not clear that I had to create another object named chart and put it in there.
The way to make the chart options object should be more clear in my opinion, that is all. Thank you and good job with the project.

chartOptions: {
                    chart: {
                        height: 350,
                        type: 'pie',
                        events: {
                            dataPointSelection: function (event, chartContext, config) {
                                console.log("test dps");
                            }
                        }
                    },

                    labels: ['Slice1', 'Slice2', 'Slice3'],
                    colors: ['#fff', '#000', '#00e396']
                },

from apexcharts.js.

junedchhipa avatar junedchhipa commented on May 1, 2024 1

Understood! Yeah, that might be confusing.
Maybe providing a full config example for React/Vue would be a good idea for such nested properties.

from apexcharts.js.

junedchhipa avatar junedchhipa commented on May 1, 2024

You didn't miss anything, I missed the dataPointSelection event for pie/donut charts.
Just pushed the latest fix, it should work now

from apexcharts.js.

FightRay avatar FightRay commented on May 1, 2024

Hey there, I installed Vue apex charts from npm yesterday. Click events still won't work on pie chart types...

from apexcharts.js.

junedchhipa avatar junedchhipa commented on May 1, 2024

@FightRay Can you post a codepen of what have you tried, please?

from apexcharts.js.

FightRay avatar FightRay commented on May 1, 2024

@junedchhipa Yeah, sure thing. Here's what I'm trying to do

I have this in my Vue component's data array
`series: [44, 55, 13],
chartOptions: {

                labels: ['part1', 'part2', 'part3'],
                colors: ['#007bff', '#00b0f0', '#00e396'],
                responsive: [{
                        breakpoint: 480,
                        options: {
                            chart: {
                                width: 200,
                                events: {
                                    click: function (event, chartContext, config) {
                                        console.log("test click");
                                    },
                                    dataPointSelection: function (event, chartContext, config) {
                                        console.log("test dps");
                                    }
                                }
                            },
                            legend: {
                                position: 'top',
                                horizontalAlign: 'center'
                            }
                        }
                    }]
            }`

And in the HTML:

<div id="chart-container"> <chart width="500" height="300" type="pie" :options="chartOptions" :series="series"></chart> </div>

The pie is showing fine, when I select a part of the pie none of the events are firing. I tried moving the events array to chartOptions as well and basically everywhere else, and nothing is working. Sorry for not posting the code in CodePen, I'm not very familiar with setting it up.

I noticed in the DOM that the part of the pie I select gets a new "selected = true" attribute, and when unselecting it or selecting a different part of the pie it sets "selected" to false. So I intercepted it this way

console.log(document.getElementById("apexcharts-pieSlice-0").getAttribute("selected")); console.log(document.getElementById("apexcharts-pieSlice-1").getAttribute("selected")); console.log(document.getElementById("apexcharts-pieSlice-2").getAttribute("selected"));

If I get NULL for an attribute I make it false, or else, I take the attribute's value. But obviously it's not the right way to do it since it's only working after the pie has been rendered and I have no way of knowing when it finished rendering.
Waiting for your reply, thanks.

from apexcharts.js.

FightRay avatar FightRay commented on May 1, 2024

@junedchhipa Hey, any updates on this?

from apexcharts.js.

junedchhipa avatar junedchhipa commented on May 1, 2024

@FightRay The events are firing correctly
I created a codepen to illustrate the config - https://codepen.io/apexcharts/pen/aXGoOb

from apexcharts.js.

FightRay avatar FightRay commented on May 1, 2024

@junedchhipa Thank you, got it working. I wasn't sure as to where to place the events array since there's no documentation for it whatsoever in the website.

from apexcharts.js.

jonathanoeijoeng avatar jonathanoeijoeng commented on May 1, 2024

I know it's old thread but I want to ask about it in vuejs
I have put
chart: { type: "donut", events: { click: function (event, chartContext, config) { console.log(config); }, dataPointSelection: function (event, chartContext, config) { console.log("test dps"); }, }, },
but when I click on chart, nothing happen. This script works well in bar chart
Do I miss something?

from apexcharts.js.

mrksoftware avatar mrksoftware commented on May 1, 2024

What about radar chart? can we use dataPointSelection there?
I tried and nothing happens, and also the documentation seems to suggest it is not supported..

Is it supposed to be done in a different way or can the event be added also there?

from apexcharts.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.