Skip to content

Leverage react component/editor for interactive code generation #1336

Open
@cpsievert

Description

@cpsievert

Programmatically placing annotations/shapes/images etc is difficult. Ideally we'd have some sort of GUI to assist in generating the relevant code. Plotly cloud does offer a solution, but there are two main issues:

  • Code generation works on the JSON-level, meaning any high-level R code gets lost.
  • The UI is complex -- it tries to do everything plotly.js can do without making common things easy.

https://github.com/plotly/react-chart-editor was recently open-sourced and could provide infrastructure for generating "focused" and locally-rendered GUIs that could help you generate code for these use-cases. For example, something like:

library(plotly)
qplot(1:10) %>%
  ggplotly() %>%
  layout_edit("annotations")

Could pop-up a shiny gadget wrapper around the react editor specifically for adding and/or editing existing annotation(s). It seems likely that we could retain the high-level (input) code and add the relevant code necessary to recreate the manual edits:

qplot(1:10) %>%
  ggplotly() %>%
  add_annotations(
    text = "My label",
    x = 0,
    y = 1,
     ...
  )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions