Skip to content

A note on package internals

Carson edited this page Aug 1, 2015 · 1 revision

Similar to other graphing libraries such as vega, Plotly graphs are described entirely with JSON objects.

{
  "data": [
    {
      "x": ["Zebras", "Lions"],
      "y": [1, 5],
      "type": "bar"
    }
  ]
}

The R library has two general approaches to creating these JSON objects. One, is the ggplotly() function which essentially extracts ggplot graph components (that can be translated to plotly) and converts them to JSON format. The other approach is another level of abstraction on top of plotly's JSON spec that allows you do declare complex visualizations in a compact way. In both approaches, the R library converts native R data structures, lists and vectors, to this JSON format and makes an authenticated HTTP API call to plotly's servers where the JSON is saved in a user's account. On page load, the JSON is served and fed through plotly's client-side javascript graphing library.

Clone this wiki locally