the difference between the goal difference from crystal palace 2020 and 21

I would probably do this by filtering each value individually within a layer; here’s an example (open in editor):

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "url": "https://raw.githubusercontent.com/StanWaldron/StanWaldron.github.io/main/final.csv"
  },
  "transform": [{"fold": ["Home_GD", "Away_GD"], "as": ["key", "Goals"]}],
  "encoding": {
    "x": {"field": "Date", "type": "temporal"},
    "y": {"field": "Goals", "type": "quantitative"},
    "color": {"field": "key", "type": "nominal"}
  },
  "layer": [
    {
      "transform": [{"filter": "datum.key == 'Home_GD' && datum.Home_GD != ''"}],
      "mark": "line"
    },
    {
      "transform": [{"filter": "datum.key == 'Away_GD' && datum.Away_GD != ''"}],
      "mark": "line"
    }
  ]
}

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top