hrbrmstr / vegalite

R ggplot2 "bindings" for Vega-Lite
http://rud.is/b/2016/02/27/create-vega-lite-specs-widgets-with-the-vegalite-package/
Other
159 stars 21 forks source link

clash of vegalite versions using from_spec() #32

Open espinielli opened 6 years ago

espinielli commented 6 years ago

When I try one of the simple vegalite examples like:

from_spec('{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
          "description": "A simple bar chart with embedded data.",
          "data": {
          "values": [
          {"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
          {"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
          {"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
          ]
          },
          "mark": "bar",
          "encoding": {
          "x": {"field": "a", "type": "ordinal"},
          "y": {"field": "b", "type": "quantitative"}
          }
          }')

I correctly get the relevant plot.

With the following one, the cloropleth example with data files pointing to relevant URLs, nothing is displayed and no error is reported:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.1.json",
  "width": 500,
  "height": 300,
  "data": {
    "url": "https://raw.githubusercontent.com/vega/editor/master/data/us-10m.json",
    "format": {
      "type": "topojson",
      "feature": "counties"
    }
  },
  "transform": [
    {
      "lookup": "id",
      "from": {
        "data": {
          "url": "https://raw.githubusercontent.com/vega/editor/master/data/unemployment.tsv"
        },
        "key": "id",
        "fields": [
          "rate"
        ]
      }
    }
  ],
  "projection": {
    "type": "albersUsa"
  },
  "mark": "geoshape",
  "encoding": {
    "color": {
      "field": "rate",
      "type": "quantitative"
    }
  }
}

The above spec in Vega-lite Editor works flowlessly.

It looks like the issue is with vegalite version in the package with respect to the one defined in the spec, in the web console of the detached plot I get:

 The input spec uses vega-lite v2.1, but the current version of Vega-Lite is 2.0.1.
jdittrich commented 6 years ago

That would be great to be able to run this – vega was much extended and it is currently, as far as I am concerned, not possible to use these extended capabilities from R.