jQuery UI Widgets › Forums › Chart › Getting Piece Info from Stacked Chart
Tagged: chart stacked, javascript chart, jquery chart, jqwidgets chart
This topic contains 6 replies, has 3 voices, and was last updated by fresler 6 years, 2 months ago.
-
Author
-
I have a stacked chart with three columns. When a user clicks on one of the pieces in a stack I want to display details for that piece. My code is:
`$(‘#inventory_chart’).on(‘click’, function (event) {
if (event.args) {
data=inventoryData[event.args.elementIndex];
var prodcat=data[“prodcat”];
var family=data[“family”];
showProdCat_exec(prodcat,family);
}
});No matter which piece I click on, the elementIndex is returning 0, 1, or 2 which is the column number. How can I get the index of the actual piece clicked on? Or can I get to the tooltip label? When the tooltip appears, the correct information is shown. If I can get to that, I can make it work.
Hello fresler,
Could you share a codepen or jsfiddle example which demonstrates the reported behavior?
Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.comHeres a jsfiddle for it. The chart code is right out of a stacked chart example but the click behavior is the same.
jsfiddle exampleThanks!
FloydHello Floyd,
Please review the updated example whether it fits your needs.
Let us know if you need further assistance.
Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.comThanks for the code but it’s not quite what I need. For example, in the sample data, if I clicked on Running in the Thursday column, my code needs to know Running on Thursday was clicked on instead of getting back an object with the numbers for the entire column. Is there a way to get that granular?
Thanks!
FloydHello Floyd,
Please, take a look at this Example, if it is what you need.
Best Regards,
MartinjQWidgets Team
https://www.jqwidgets.com/Martin,
That did it! Thanks so much for the help!Take care,
Floyd -
AuthorPosts
You must be logged in to reply to this topic.