Title: Improve 'relink private keys' steps · Issue #749 · plotly/plotly.js · GitHub
Open Graph Title: Improve 'relink private keys' steps · Issue #749 · plotly/plotly.js
X Title: Improve 'relink private keys' steps · Issue #749 · plotly/plotly.js
Description: Synopsis At the moment, during Plots.supplyDefaults we loop over all keys found in the old trace and layout containers in order to relink all private keys not set during the defaults step in the new trace and layout containers (remember,...
Open Graph Description: Synopsis At the moment, during Plots.supplyDefaults we loop over all keys found in the old trace and layout containers in order to relink all private keys not set during the defaults step in the ne...
X Description: Synopsis At the moment, during Plots.supplyDefaults we loop over all keys found in the old trace and layout containers in order to relink all private keys not set during the defaults step in the ne...
Opengraph URL: https://github.com/plotly/plotly.js/issues/749
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve 'relink private keys' steps","articleBody":"### Synopsis\r\n\r\nAt the moment, during `Plots.supplyDefaults` we loop over all keys found in the _old_ trace and layout containers in order to _relink_ all _private keys_ **not set** during the defaults step in the new trace and layout containers (remember, `fullData` and `fullLayout` start as empty `[]` and `{}` respectively in every `Plots.supplyDefaults` call).\r\n\r\nThese _private keys_ are linked to subplot instances (e.g `fullLayout.scene._scene`), computed values (e.g. `fullLayout.xaxis._m`), graph svg selections (e.g. `fullLayout._infolayer`) etc ...\r\n### In brief\r\n\r\nLooping over all keys is dumb, slow and hard to maintain ; we can do better!\r\n### Observations\r\n\r\nNot relinking private keys in trace objects results in:\r\n- geo trace visibility toggle not functioning (`_module` isn't defined anymore for `visible: false` traces)\r\n- contour restyle not working as `trace._emptypoints` isn't relinked\r\n\r\nNot relinking array container results in:\r\n- annotations not behaving correctly on zoom -\u003e double-click interactions\r\n### Possible solution\r\n\r\nMake the trace and base plot module (and possibly the component module) `clean` method relink the _sticky_ keys that need to be relinked during `Plots.supplyDefaults`. This would make the `clean` methods handle all old container --\u003e new container logic in one go.\r\n\r\nFor example, most base plot modules have a `clean` method that looks like:\r\n\r\n``` js\r\noldSubplotIds.forEach((id) =\u003e {\r\n if(!newFullLayout[id]._subplot \u0026\u0026 !!oldFullLayout[id]._subplot) {\r\n oldFullLayout[id]._subplot.destroy();\r\n return;\r\n }\r\n\r\n // it would be then be easy to relink the active subplot objects here\r\n newFullLayout[id]._subplot = oldFullLayout[id]._subplot;\r\n});\r\n```\r\n\r\nIt might be convenient to put private keys generated in [`makePlotFramework`](https://github.com/plotly/plotly.js/blob/7ae437bbbb81ec1f49fee7145fc796d64e688bc6/src/plot_api/plot_api.js#L2592) under one object in fullLayout (e.g `fullLayout_base._toppaper`) to keep track of private keys more easily. \r\n","author":{"url":"https://github.com/etpinard","@type":"Person","name":"etpinard"},"datePublished":"2016-07-18T19:16:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/749/plotly.js/issues/749"}
| 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:d6639558-2718-ffad-9c0d-9539dd07205b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E11E:CD74F:4A06C57:685E3C7:6A56F70C |
| html-safe-nonce | 6976e6447bd06fefc06bf5100e52a61668a524f87cc67d8fffa5485f0f25f481 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTFFOkNENzRGOjRBMDZDNTc6Njg1RTNDNzo2QTU2RjcwQyIsInZpc2l0b3JfaWQiOiI1MDU3MDgzMDQwODYzODExMzQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6ab6367d697107ba60244ecea42a990247c7f462dd0cbe2abf6d47944a913e02 |
| hovercard-subject-tag | issue:166170875 |
| 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.js/749/issue_layout |
| twitter:image | https://opengraph.githubassets.com/88d4cccb148c7d57090310288db4750ef7cc79a2bdbb8f2c48b1540df1819e21/plotly/plotly.js/issues/749 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/88d4cccb148c7d57090310288db4750ef7cc79a2bdbb8f2c48b1540df1819e21/plotly/plotly.js/issues/749 |
| og:image:alt | Synopsis At the moment, during Plots.supplyDefaults we loop over all keys found in the old trace and layout containers in order to relink all private keys not set during the defaults step in the ne... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | etpinard |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb29e5f807bd95e41196adfbc6d28f9af12d89830d8b684f3e871774ddff2fc |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.js git https://github.com/plotly/plotly.js.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 45646037 |
| octolytics-dimension-repository_nwo | plotly/plotly.js |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 45646037 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.js |
| 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 | b056788a129fb0194b61f2ebb4c43f6a9f4dfd27 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width