Error: Undefined data set name: "source_1" in Vega-Lite interactive charts

Viewed 173

I am making an interactive dashboard using Vega-Lite. The end graph has to look like this:

Vega-Lite Dashboard

The code I have so far works perfectly fine for the bar chart and map, but when I draw the histogram it gives following error:

Undefined data set name: "source_1"

This is the code I have so far:

  "$schema": "https://vega.github.io/schema/vega-lite/v5.json"
  
"title": {
    "text": "Exploring Irish",
    "anchor": "middle",
    "fontSize": 20,
    "offset": 20,
    "color": "brown"
  },

"vconcat":[
{ "hconcat": [

{
  "width": 500,
  "height": 700,
  "projection": {
        "type": "conicConformal"
      },

  
  "layer": [
    {
      "data": {
        "url": "https://gist.githubusercontent.com/carsonfarmer/9791524/raw/b27ca0d78d46a84664fe7ef709eed4f7621f7a25/irish-counties-segmentized.topojson",
        "format": {
          "type": "topojson",
          "feature": "counties"
        }
      },
      "transform": [{
    "lookup": "id",
    "from": {
      "data": {"url": "https://raw.githubusercontent.com/colmr/vis_class/master/FakeAttractionDetails.csv"},
      "key": "County",
      "fields": ["Population"]
    }
  }],
      "mark": {
        "type": "geoshape",
        "stroke": "white",
        "fill":"#ccc"
      }
    },
    {
      "data": {
    "url": "https://raw.githubusercontent.com/colmr/vis_class/master/FakeAttractionDetails.csv"
  },


 "mark": "circle",
 "params": [{
    "name": "Attrac",
    "select": {"type": "point", "fields": ["Type"]},
    "bind": "legend"
  }],
  "encoding": {
    "longitude": {
      "field": "Longitude",
      "type": "quantitative"
    },
    "latitude": {
      "field": "Latitude",
      "type": "quantitative"
    },
    "color":{"field":"Type", "type":"nominal",  "scale": {"range": ["#E69F00", "#0072B2", "#CC79A7","#009E73","#56B4E9"]}},
    "size": {"value": 40},
    "opacity": {"condition": {"param": "Attrac", "value": 1},
      "value": 0},
"tooltip": [
      {"field": "Name", "type": "nominal", "title": "Accommodation"},
      {"field": "Type", "type": "nominal", "title": "Property Type"},
      {"field": "Telephone", "type": "nominal", "title": "Contact"}
    ],






      "href": {"field": "Url", "type": "nominal"}

  }
  
  
  }

  ]
 

},


{
    "data": {
    "url": "https://raw.githubusercontent.com/colmr/vis_class/master/FakeAttractionDetails.csv"
  },

  "width": 335,
  "height": 700,
  "mark": "bar",
"params": [{
    "name": "Attrac",
    "select": {"type": "point", "fields": ["Type"]},
    "bind": "legend"
  },

 {  "name": "Attrac",
    "select": {"type": "point", "encodings": ["y"]}
  }



  
  ],

  "encoding": {
        "y": {
        "field": "AddressRegion",
        "type": "nominal",
        "sort": {
          "op": "count",
          "field": "Type",
          "order": "descending"
        },
        "axis":{"title":null, "labelFontSize": 15}
      },
      "x": {
        "field": "Type",
        "type": "nominal",  
        "aggregate":"count",
        
        "axis":{"title":"Total Accommodations", "titleFontSize":15}
         },
      "color":{"field":"Type", "type":"nominal",
      "scale": {"range": ["#E69F00", "#0072B2", "#CC79A7","#009E73","#56B4E9"]}
    },
      "opacity": {"condition": {"param": "Attrac", "value": 1},
      "value": 0.05},
"order": {"aggregate": "count", "field": "Type", "type": "nominal", "sort": "descending"}
   }
 
}

 ]

  

},

{


"data": {"url": "https://raw.githubusercontent.com/colmr/vis_class/master/FakeAttractionDetails.csv"},

  "width": 950,
  "height": 45,  


  "mark": "bar",

"params": [{
    "name": "Attrac",
    "select": {"type": "point", "fields": ["Type"]},
    "bind": "legend"},

 {  "name": "Attrac",
    "select": {"type": "interval", "encodings": ["x"]}
  }],


  "encoding": {
    "x": {
      "field": "Popularity",
      "bin": true,
      "type": "quantitative"
    },
    "y": {"aggregate": "count"},

    "color":{"field":"Type", "type":"nominal",
      "scale": {"range": ["#E69F00", "#0072B2", "#CC79A7","#009E73","#56B4E9"]}},
      
 "opacity": {"condition": {"param": "Attrac", "value": 1},
      "value": 0.02}
      
      }


  }



],

"config": {
    "legend": {
      "orient":"top-left", "labelFontSize":15, "titleFontSize":15
    }, "tick": {"thickness": 1.5, "bandSize": 18}
 }

 }


I tried making the histogram with another csv file and that worked fine. Any idea what is wrong with this dataset or this code?

1 Answers

It looks like there's some issue with specifying the same data URL in multiple places in the chart. If you move the data specification to the top level, it appears to work:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "url": "https://raw.githubusercontent.com/colmr/vis_class/master/FakeAttractionDetails.csv"
  },
  ...

enter image description here

Related