Comments (12)
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.
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.
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.
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.
Hey there, I installed Vue apex charts from npm yesterday. Click events still won't work on pie chart types...
from apexcharts.js.
@FightRay Can you post a codepen of what have you tried, please?
from apexcharts.js.
@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.
@junedchhipa Hey, any updates on this?
from apexcharts.js.
@FightRay The events are firing correctly
I created a codepen to illustrate the config - https://codepen.io/apexcharts/pen/aXGoOb
from apexcharts.js.
@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.
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.
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)
- Apexcharts legend markers not showing HOT 1
- Option to place y-axis labels inside the graph
- Angular samples not present
- Realtime charts without rerendering with smooth animation
- Server rendered charts and attaching eventlistners later once window object is defined
- Bubble Chart Data Point Z-index
- Can't modify stroke width of multi-series sparkline chart
- Candelstick graph with only max and min
- The legend does not appear when I import an svg image into PowerPoint
- Adding custom locales
- Show a color scale legend for treemap charts
- How to display totals per group on a Grouped Stacked Bar Chart HOT 1
- ApexChart Grouped & Stacked Bar Chart with Zoom and Total Data Label Issue HOT 6
- Datetime on x axis is not linera HOT 1
- The possibility to have an array of series in seriesName of y-axis HOT 1
- chart line doesn't match with value when use logarithmic in yaxis option HOT 1
- XAxis text cannot be displayed for e.g.: "InvalidFile", "InvalidFileName", "Invalid", "InvalidMessageLength", ...
- Stack bar miss align text HOT 1
- XAxis Annotations multiline misalignment
- Graphs not loading correctly on mobile
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apexcharts.js.