简体   繁体   English

错误:未定义的数据集名称:Vega-Lite 交互式图表中的“source_1”

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

I am making an interactive dashboard using Vega-Lite.我正在使用 Vega-Lite 制作交互式仪表板。 The end graph has to look like this:最终图表必须如下所示:

Vega-Lite Dashboard Vega-Lite 仪表板

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:到目前为止,我使用的代码对于条形图和 map 来说工作得很好,但是当我绘制直方图时,它会出现以下错误:

Undefined data set name: "source_1"未定义的数据集名称:“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.我尝试用另一个 csv 文件制作直方图并且效果很好。 Any idea what is wrong with this dataset or this code?知道这个数据集或这段代码有什么问题吗?

It looks like there's some issue with specifying the same data URL in multiple places in the chart.在图表的多个位置指定相同的数据 URL 似乎存在一些问题。 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"
  },
  ...

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM