Title: sunburst plots: 'plotly_click' event_data only available for root and leafs · Issue #1648 · plotly/plotly.R · GitHub
Open Graph Title: sunburst plots: 'plotly_click' event_data only available for root and leafs · Issue #1648 · plotly/plotly.R
X Title: sunburst plots: 'plotly_click' event_data only available for root and leafs · Issue #1648 · plotly/plotly.R
Description: Currently it seems that for sunburst plots the 'plotly_click' event_data is only available after clicking the root and leafs of the plot. I'm wondering whether this behaviour is intentional and inherited by plotly.js or not. Please see t...
Open Graph Description: Currently it seems that for sunburst plots the 'plotly_click' event_data is only available after clicking the root and leafs of the plot. I'm wondering whether this behaviour is intentional and inh...
X Description: Currently it seems that for sunburst plots the 'plotly_click' event_data is only available after clicking the root and leafs of the plot. I'm wondering whether this behaviour is intenti...
Opengraph URL: https://github.com/plotly/plotly.R/issues/1648
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sunburst plots: 'plotly_click' event_data only available for root and leafs","articleBody":"Currently it seems that for sunburst plots the 'plotly_click' event_data is only available after clicking the root and leafs of the plot.\r\n\r\nI'm wondering whether this behaviour is intentional and inherited by plotly.js or not.\r\n\r\nPlease see the following example and a workaround I came up with using `onclick`, which I first posted [here](https://stackoverflow.com/a/58706762/9841389):\r\n\r\n```r\r\nlibrary(plotly)\r\nlibrary(shinyjs)\r\n\r\nDF \u003c- structure(list(labels = c(\"total\", \"A\", \"C\", \"B\", \"F\", \"E\", \"F\", \r\n \"E\", \"D\", \"E\", \"D\", \"D\", \"F\", \"G\", \"H\", \"H\", \"G\", \"H\", \"G\", \"H\", \r\n \"H\", \"G\", \"I\", \"G\", \"I\", \"H\", \"G\", \"I\", \"I\", \"G\", \"G\", \"I\", \"H\", \r\n \"H\", \"I\", \"I\", \"I\", \"H\", \"I\", \"G\"),\r\n values = c(100L, 36L, 29L,\r\n 35L, 12L, 14L, 10L, 14L, 8L, 18L, 5L, 10L, 9L, 6L, 5L, 4L, 3L,\r\n 7L, 4L, 2L, 6L, 3L, 8L, 3L, 2L, 4L, 4L, 4L, 4L, 4L, 3L, 2L, 5L, \r\n 5L, 2L, 2L, 1L, 1L, 1L, 5L),\r\n parents = c(NA, \"total\", \"total\", \"total\", \"total - A\", \"total - C\", \"total - C\", \"total - A\",\r\n \"total - B\", \"total - B\", \"total - C\", \"total - A\", \"total - B\",\r\n \"total - A - F\", \"total - C - E\", \"total - C - F\", \"total - A - E\",\r\n \"total - A - E\", \"total - B - D\", \"total - B - D\", \"total - B - E\",\r\n \"total - C - D\", \"total - B - E\", \"total - A - D\", \"total - B - D\",\r\n \"total - B - F\", \"total - C - F\", \"total - A - E\", \"total - C - E\",\r\n \"total - B - E\", \"total - B - F\", \"total - A - D\", \"total - A - D\",\r\n \"total - A - F\", \"total - B - F\", \"total - C - F\", \"total - C - D\",\r\n \"total - C - D\", \"total - A - F\", \"total - C - E\"),\r\n ids = c(\r\n \"total\", \"total - A\", \"total - C\", \"total - B\", \"total - A - F\", \"total - C - E\", \r\n \"total - C - F\", \"total - A - E\", \"total - B - D\", \"total - B - E\", \"total - C - D\",\r\n \"total - A - D\", \"total - B - F\", \"total - A - F - G\", \"total - C - E - H\",\r\n \"total - C - F - H\", \"total - A - E - G\", \"total - A - E - H\", \"total - B - D - G\",\r\n \"total - B - D - H\", \"total - B - E - H\", \"total - C - D - G\", \"total - B - E - I\",\r\n \"total - A - D - G\", \"total - B - D - I\", \"total - B - F - H\", \"total - C - F - G\",\r\n \"total - A - E - I\", \"total - C - E - I\", \"total - B - E - G\", \"total - B - F - G\",\r\n \"total - A - D - I\", \"total - A - D - H\", \"total - A - F - H\", \"total - B - F - I\",\r\n \"total - C - F - I\", \"total - C - D - I\", \"total - C - D - H\", \"total - A - F - I\",\r\n \"total - C - E - G\"\r\n )), row.names = c(NA,-40L), class = \"data.frame\")\r\n\r\nui \u003c- fluidPage(\r\n useShinyjs(),\r\n plotlyOutput(\"sunburst\"),\r\n htmlOutput(\"hoverDataOut\"),\r\n htmlOutput(\"clickDataOut\")\r\n)\r\n\r\nserver \u003c- function(input, output, session) {\r\n output$sunburst \u003c- renderPlotly({\r\n plot_ly(data = DF, source = \"sunSource\", customdata = ~ids, ids = ~ids, labels= ~labels, parents = ~parents, values= ~values, type='sunburst', branchvalues = 'total')\r\n })\r\n \r\n hoverData \u003c- reactive({\r\n currentEventData \u003c- unlist(event_data(event = \"plotly_hover\", source = \"sunSource\", priority = \"event\"))\r\n })\r\n \r\n clickData \u003c- reactiveVal()\r\n \r\n observe({\r\n clickData(unlist(event_data(event = \"plotly_click\", source = \"sunSource\", priority = \"event\")))\r\n })\r\n \r\n # workaround:\r\n # onclick(id = \"sunburst\", expr = {clickData(hoverData())})\r\n \r\n output$hoverDataOut \u003c- renderText({\r\n paste(\"Hover data:\", paste(names(hoverData()), unlist(hoverData()), sep = \": \", collapse = \" | \"))\r\n })\r\n \r\n output$clickDataOut \u003c- renderText({\r\n paste(\"Click data:\", paste(names(clickData()), unlist(clickData()), sep = \": \", collapse = \" | \"))\r\n })\r\n \r\n}\r\n\r\nshinyApp(ui, server)\r\n```\r\n---\r\n\r\n\r\n","author":{"url":"https://github.com/ismirsehregal","@type":"Person","name":"ismirsehregal"},"datePublished":"2019-11-05T08:05:32Z","url":"https://github.com/plotly/plotly.R/issues/1648"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a7e02a87-ef7c-72a0-b393-e579be3e7a4f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A92A:215B92:D5F892:11DCF8B:6B0101B7 |
| html-safe-nonce | 9a233f833a73166e55180dc06b36a6093241736990aa9a4af7425d13d12d1313 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTJBOjIxNUI5MjpENUY4OTI6MTFEQ0Y4Qjo2QjAxMDFCNyIsInZpc2l0b3JfaWQiOiIzMTEwMjA0NjcwODg3Mzk1NzY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9109a3ea7c1fb769d14e8c6a9d80233cc6cdd735bd1cbd549d9b4e6bcfeae810 |
| hovercard-subject-tag | issue:517608332 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.R/1648/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eecd89600791488ee43798868976b8b3c9ee7efd148cbe9851749c31c2051c80/plotly/plotly.R/issues/1648 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eecd89600791488ee43798868976b8b3c9ee7efd148cbe9851749c31c2051c80/plotly/plotly.R/issues/1648 |
| og:image:alt | Currently it seems that for sunburst plots the 'plotly_click' event_data is only available after clicking the root and leafs of the plot. I'm wondering whether this behaviour is intentional and inh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ismirsehregal |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.R git https://github.com/plotly/plotly.R.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579179 |
| octolytics-dimension-repository_nwo | plotly/plotly.R |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579179 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.R |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width