我正在try 显示按日期层次 struct 的离职率演变(我考虑了月(Mois)和年(Année))

Before trying with Deneb , I tried with Normal line chart , working fine: enter image description here enter image description here

But I don't know in Deneb it's being displayed like this : enter image description here

这是我的土卫四密码:

{
  "data": {"name": "dataset"},
  "transform": [
    {
      "calculate": "format(datum['Turnover Rate']/100, '0.1%')",
      "as": "turnover_rate_percentage"
    },
    {
      "calculate": "datum['Mois'] + ' ' + datum['Année']",
      "as": "MONTH_YEAR"
    }
  ],
  "mark": {
    "type": "area",
    "line": {"color": "#063970"},
    "color": {
      "x1": 1,
      "y1": 1,
      "gradient": "linear",
      "stops": [
        {
          "offset": 0,
          "color": "white"
        },
        {
          "offset": 1,
          "color": "#063970"
        }
      ]
    }
  },
  "encoding": {
    "x": {
      "field": "MONTH_YEAR",
      "type": "ordinal",
      "axis": {"labelPadding": 0},
      "title": "Year + Month"
    },
    "y": {
      "field": "turnover_rate_percentage",
      "type": "quantitative",
      "axis": {"format": "%", "title": "Turnover Rate"}
    }
  }
}

有谁能帮我解决这个问题吗?

这是the PBIX file美元

推荐答案

UPDATE

在字段Well中,单击向下箭头并 Select 日期而不是层次 struct .

enter image description here

按如下方式更新您的规范:

{
  "data": {"name": "dataset", "format": {"parse": {"Date": "date:'%d/%m/%Y'"}}},
  "transform": [
    {
      "calculate": "format(datum['Turnover Rate'], '0.1%')",
      "as": "turnover_rate_percentage"
    }
  ],
  "mark": {
    "type": "area",
    "line": {"color": "#063970"},
    "color": {
      "x1": 1,
      "y1": 1,
      "gradient": "linear",
      "stops": [
        {
          "offset": 0,
          "color": "white"
        },
        {
          "offset": 1,
          "color": "#063970"
        }
      ]
    }
  },
  "encoding": {
    "x": {
      "field": "DATES",
      "type": "temporal",
      "axis": {"labelPadding": 0},
      "title": ""
    },
    "y": {
      "field": "turnover_rate_percentage",
      "type": "quantitative",
      "axis": {"format": "%", "title": "Turnover Rate"}
    }
  }
}

这是最终产品:

enter image description here

这里有几个地方出了问题.主要问题是您在x轴上提供的Month_Year如下所示:

enter image description here

这些只是字符串,您已经指定了这些值是序数,所以VL在该轴上绘制了32,000个单独的序数值,这就是为什么它看起来一团糟.

您还使用了内置的日期层次 struct ,它实际上应该被禁用,这样您就可以创建自己的日期了.

禁用此选项:

enter image description here

您的x轴应该是时态类型,所以它是连续的,但您需要首先清理您的数据,因为其中有几个VL不接受的日期.这里有一些很好的例子:https://vega.github.io/vega-lite/docs/type.html,在文档中搜索"时态".

当您有一个轴时,它可以是离散的/有序的(绘制每个单个标签),也可以是连续的(时间或定量),其中VL决定为您显示多少标签.

Json相关问答推荐

在Go中,当字段可以根据其他字段具有不同的类型时,什么是正确的方法来卸载JSON?

如何在使用GO时检测JSON中不需要的字段?

使用更高级别架构中的字段值在$def内实现约束

解析JSON说函数parse_json不存在?

Python将Pandas转换为嵌套的JSON

Flutter -控制器问题-JSON API

如何用JQ打印JSON文件的路径和键值

JOLT转换以根据条件删除json对象

如何使用jq使用子值对象的键对json对象进行分组

在 json 对象中存储多个键:值对

如何在 Apache NiFi 中使用 JoltTransformJson 删除流文件或具有空字段的整个对象?

带有 API 测试的 Typescript JSON 模式验证

使用 Jolt 使用键中的值创建带有硬编码键和值的 JSON 数组

JSON对象中的JavaScript递归搜索

如何自动修复无效的 JSON 字符串?

如何将 MongoDB 查询转换为 JSON?

如何从 MySQL 中检索 JSON 数据?

使用新的 Net Core 3.0 Json 时忽略属性

使用 JSON.NET 序列化/反序列化对象字典

使用 JavaScriptSerializer() 反序列化 JSON 文件