json Vega lite规范尽管在规范中提供了数据,但仍显示空图

wnrlj8wa  于 2023-06-25  发布在  其他
关注(0)|答案(1)|浏览(103)

Vega lite规范显示空图,没有任何数据点,尽管在规范中提供了数据。该链接具有适当的规格和空图表。我需要帮助找出错误所在。我试图将此图表显示为Streamlit应用程序的一部分。我看不到任何JavaScript或Python错误。只是一张空白的图表。

dnph8jn4

dnph8jn41#

您需要在字段名中转义句号。

{
  "description": "Enrollment duration (in months) of all Oncology Trials with different colors.",
  "data": {
    "values": [
      {"Trial": 0, "Enrollment_Duration_(Mos.)": 39.36},
      {"Trial": 1, "Enrollment_Duration_(Mos.)": 19.81},
      {"Trial": 2, "Enrollment_Duration_(Mos.)": 27.6},
      {"Trial": 3, "Enrollment_Duration_(Mos.)": 35.32},
      {"Trial": 4, "Enrollment_Duration_(Mos.)": 17.05},
      {"Trial": 6, "Enrollment_Duration_(Mos.)": 24.31},
      {"Trial": 7, "Enrollment_Duration_(Mos.)": 25.86},
      {"Trial": 8, "Enrollment_Duration_(Mos.)": 35.84},
      {"Trial": 9, "Enrollment_Duration_(Mos.)": 33.94},
      {"Trial": 10, "Enrollment_Duration_(Mos.)": 59.01},
      {"Trial": 11, "Enrollment_Duration_(Mos.)": 13.47},
      {"Trial": 12, "Enrollment_Duration_(Mos.)": 46.16},
      {"Trial": 14, "Enrollment_Duration_(Mos.)": 12.78},
      {"Trial": 16, "Enrollment_Duration_(Mos.)": 12.42},
      {"Trial": 17, "Enrollment_Duration_(Mos.)": 8.42},
      {"Trial": 18, "Enrollment_Duration_(Mos.)": 39.59},
      {"Trial": 19, "Enrollment_Duration_(Mos.)": 38.87},
      {"Trial": 20, "Enrollment_Duration_(Mos.)": 18.76},
      {"Trial": 21, "Enrollment_Duration_(Mos.)": 18.37},
      {"Trial": 23, "Enrollment_Duration_(Mos.)": 27.63},
      {"Trial": 24, "Enrollment_Duration_(Mos.)": 19.38},
      {"Trial": 26, "Enrollment_Duration_(Mos.)": 41.78},
      {"Trial": 27, "Enrollment_Duration_(Mos.)": 22.34},
      {"Trial": 28, "Enrollment_Duration_(Mos.)": 25.02},
      {"Trial": 29, "Enrollment_Duration_(Mos.)": 20.01},
      {"Trial": 31, "Enrollment_Duration_(Mos.)": 4.11},
      {"Trial": 32, "Enrollment_Duration_(Mos.)": 20.21},
      {"Trial": 33, "Enrollment_Duration_(Mos.)": 46},
      {"Trial": 34, "Enrollment_Duration_(Mos.)": 11.89}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {
      "field": "Trial",
      "type": "ordinal",
      "axis": {"title": "Oncology Trials"}
    },
    "y": {
      "field": "Enrollment_Duration_(Mos\\.)",
      "type": "quantitative",
      "axis": {"title": "Enrollment Duration (Months)"}
    },
    "color": {
      "field": "Trial",
      "type": "ordinal",
      "legend": {"title": "Oncology Trials"}
    }
  }
}

相关问题