大佬教程收集整理的这篇文章主要介绍了如何修复 hconcat 金字塔图中的渲染文本?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@L_404_0@
我正在尝试创建一个连续金字塔图,但中间的文本似乎无法正确呈现。将标记文本的字段更改为数字不会出现此渲染问题。这是我遵循并修改的示例。 Population Pyramid
{
"$scheR_577_11845@a": "https://vega.github.io/scheR_577_11845@a/vega-lite/v5.Json","spacing": 0,"hconcat": [
{
"transform": [
{ "filter": { "fIEld": "sentiment","equal": "negative" } }
],"enCoding": {
"y": { "fIEld": "type","title": null,"axis": null },"x": {
"fIEld": "sentiment","aggregate": "count","axis": null,"sort": "descending"
}
},"layer": [
{ "mark": "bar","enCoding": { "color": { "fIEld": "chAnnel" } } }
]
},{
"wIDth": 100,"vIEw": { "stroke": null },"mark": { "type": "text","align": "center" },"text": { "fIEld": "type" }
}
},{
"mark": "bar","transform": [
{ "filter": { "fIEld": "sentiment","equal": "positive" } }
],"enCoding": {
"color": { "fIEld": "chAnnel" },"y": { "fIEld": "type","x": { "fIEld": "sentiment","axis": null }
}
}
],"config": { "vIEw": { "stroke": null },"axis": { "grID": false } },"data": {
"values": [
{
"ID": 1,"type": "shops","chAnnel": "line man","sentiment": "negative"
}
]
}
}
由于您尚未在文本图表中进行任何聚合,因此每个文本标记都会绘制多次 - 数据中的每个对应行一次。多个文本标记的堆叠使它看起来好像渲染得很差。
为确保每个文本标记只绘制一次,您需要聚合数据。有几种方法可以做到这一点,但这里最简单的是使用相关数字列的 argmin
或 argmax
:
"encoding": {
"y": {"field": "type","axis": null},"text": {"field": "type","aggregate": {"argmin": "id"}}
}
以上是大佬教程为你收集整理的如何修复 hconcat 金字塔图中的渲染文本?全部内容,希望文章能够帮你解决如何修复 hconcat 金字塔图中的渲染文本?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。