如何将列标题底部对齐?

huangapple go评论57阅读模式
英文:

Column facet: how to align header title to the bottom?

问题

我想将我的分面列标题底部对齐。

我得到了以下结果,标题未向下对齐,每个标题与图形底部的距离不同。

如何将这些标题对齐到底部?

谢谢

英文:

I would like to align to the bottom all the header titles of my facet columns.

This is my code

And I get the below result, the titles are not aligned downwards, each one has a different distance from the graphic bottom.

如何将列标题底部对齐?

How to align these titles to the bottom?

Thank you

答案1

得分: 0

这似乎是一个错误。你可以在GitHub上提出吗?这里有一个解决方法。

如何将列标题底部对齐?

{
"data": {"name": "data-eb2eb4918524c908955f7797d7245a00"},
"facet": {
"column": {
"field": "f",
"header": {"labelOrient": "bottom", "labelFontSize": 20, "title": ""}
}
},
"spec": {
"layer": [
{
"mark": {"type": "arc", "outerRadius": 100},
"encoding": {
"color": {
"field": "k",
"legend": {"title": ""},
"sort": {"field": "n"},
"type": "nominal"
},
"theta": {"field": "v", "stack": true, "type": "quantitative"}
}
},
{
"mark": {"type": "text", "fill": "black", "radius": 115},
"encoding": {
"color": {
"field": "k",
"legend": {"title": ""},
"sort": {"field": "n"},
"type": "nominal"
},
"text": {"field": "v", "format": ",.1f", "type": "quantitative"},
"theta": {"field": "v", "stack": true, "type": "quantitative"}
}
}
]
},
"resolve": {"scale": {"theta": "independent"}},
"$schema": "https://vega.github.io/schema/vega-lite/v5.2.0.json",
"datasets": {
"data-eb2eb4918524c908955f7797d7245a00": [
{"n": 1, "f": "非森林", "k": "N", "v": 32.20114689016321},
{"n": 2, "f": "非森林", "k": "E", "v": 22.30554330245552},
{"n": 3, "f": "非森林", "k": "S", "v": 14.350830760182326},
{"n": 4, "f": "非森林", "k": "W", "v": 31.14247904719894},
{"n": 5, "f": "森林", "k": "N", "v": 24.525745257452574},
{"n": 6, "f": "森林", "k": "E", "v": 20.460704607046072},
{"n": 7, "f": "森林", "k": "S", "v": 21.00271002710027},
{"n": 8, "f": "森林", "k": "W", "v": 34.010840108401084},
{"n": 9, "f": "未分类", "k": "N", "v": 29.437706725468576},
{"n": 10, "f": "未分类", "k": "E", "v": 32.08379272326351},
{"n": 11, "f": "未分类", "k": "S", "v": 16.427783902976845},
{"n": 12, "f": "未分类", "k": "W", "v": 22.05071664829107}
]
}
}

英文:

Looks like a bug. Can you raise it on GitHub? Here is a workaround.

如何将列标题底部对齐?

{
  "data": {"name": "data-eb2eb4918524c908955f7797d7245a00"},
  "facet": {
    "column": {
      "field": "f",
      "header": {"labelOrient": "bottom", "labelFontSize": 20, "title": ""}
    }
  },
  "spec": {
    "layer": [
      {
        "mark": {"type": "arc", "outerRadius": 100},
        "encoding": {
          "color": {
            "field": "k",
            "legend": {"title": ""},
            "sort": {"field": "n"},
            "type": "nominal"
          },
          "theta": {"field": "v", "stack": true, "type": "quantitative"}
        }
      },
      {
        "mark": {"type": "text", "fill": "black", "radius": 115},
        "encoding": {
          "color": {
            "field": "k",
            "legend": {"title": ""},
            "sort": {"field": "n"},
            "type": "nominal"
          },
          "text": {"field": "v", "format": ",.1f", "type": "quantitative"},
          "theta": {"field": "v", "stack": true, "type": "quantitative"}
        }
      }
    ]
  },
  "resolve": {"scale": {"theta": "independent"}},
  "$schema": "https://vega.github.io/schema/vega-lite/v5.2.0.json",
  "datasets": {
    "data-eb2eb4918524c908955f7797d7245a00": [
      {"n": 1, "f": "Non Forest", "k": "N", "v": 32.20114689016321},
      {"n": 2, "f": "Non Forest", "k": "E", "v": 22.30554330245552},
      {"n": 3, "f": "Non Forest", "k": "S", "v": 14.350830760182326},
      {"n": 4, "f": "Non Forest", "k": "W", "v": 31.14247904719894},
      {"n": 5, "f": "Forest", "k": "N", "v": 24.525745257452574},
      {"n": 6, "f": "Forest", "k": "E", "v": 20.460704607046072},
      {"n": 7, "f": "Forest", "k": "S", "v": 21.00271002710027},
      {"n": 8, "f": "Forest", "k": "W", "v": 34.010840108401084},
      {"n": 9, "f": "Unclassified", "k": "N", "v": 29.437706725468576},
      {"n": 10, "f": "Unclassified", "k": "E", "v": 32.08379272326351},
      {"n": 11, "f": "Unclassified", "k": "S", "v": 16.427783902976845},
      {"n": 12, "f": "Unclassified", "k": "W", "v": 22.05071664829107}
    ]
  }
}

huangapple
  • 本文由 发表于 2023年2月18日 04:19:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75488910.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定