admin管理员组

文章数量:1122846

I've got a U.S. choropleth with a lookup transform of the counties to the sunrise time (in UTC minutes).

It works, but it's just a single day. My dataset has a column for every day of the calendar year, and I would like to add this dimension to the visualization.

Here is the spec:

  {"encoding": {
    "color": {
      "field": "1-june",
      "type": "quantitative",
      "scale": {"scheme": "rainbow"}
    }
  },
  "transform": [
    {
      "lookup": "id",
      "from": {
        "data": {
          "url": "http://localhost:7777/_fs/resources/data/sunrise-times.csv"
        },
        "key": "geoid",
        "fields": ["1-june"]
      }
    }
  ],
  "mark": "geoshape",
  "width": 650,
  "background": "transparent",
  "$schema": ".json",
  "projection": {"type": "albersUsa"},
  "height": 400,
  "data": {
    "url": "http://localhost:7777/_fs/resources/data/counties-10m.json",
    "format": {"type": "topojson", "feature": "counties"},
    "name": "counties-geojson"
  }
}

Note that in this case I am just showing 1-june, but once again, I want to incorporate the whole calendar year. It seems like I just need to figure out:

  • How to encode an array of column names into the spec
  • How to interactively choose a column

A slider input could work (a range), if that integer value could be used to index into the column name array.

I tried adding the column name array as an inline dataset, but that didn't seem to be present at runtime. I could make it a parameter as well, but I'm not sure how to reference parameters in an expression.

I'm very open minded as to the best way to implement this.

本文标签: vegalite choropleth with interactively chosen lookup fieldStack Overflow