Bar chart 使用带文本标签的VegaLite的简单堆叠条形图
我在标记条形图时遇到问题。我想在每个酒吧的右手边贴上所有支持者的标签。并非如图所示的“美国支持者”和“其他国家支持者”的总和 我使用的数据集显示了Kickstarter项目网站上最受欢迎的类别,我还重点介绍了在美国推出的项目,以显示该网站在美国的受欢迎程度与全球相比Bar chart 使用带文本标签的VegaLite的简单堆叠条形图,bar-chart,data-visualization,vega-lite,Bar Chart,Data Visualization,Vega Lite,我在标记条形图时遇到问题。我想在每个酒吧的右手边贴上所有支持者的标签。并非如图所示的“美国支持者”和“其他国家支持者”的总和 我使用的数据集显示了Kickstarter项目网站上最受欢迎的类别,我还重点介绍了在美国推出的项目,以显示该网站在美国的受欢迎程度与全球相比 如果使颜色编码仅应用于条形图图层,则将获得所需的结果。通过清理冗余和无效参数,结果如下:(): 如果将颜色编码仅应用于条形图图层,您将获得所需的结果。通过清理冗余和无效参数,结果如下:(): 是否有办法使文本标签成为条的总数而不是
如果使颜色编码仅应用于条形图图层,则将获得所需的结果。通过清理冗余和无效参数,结果如下:():
如果将颜色编码仅应用于条形图图层,您将获得所需的结果。通过清理冗余和无效参数,结果如下:():
是否有办法使文本标签成为条的总数而不是两个单独的条?是否有办法使文本标签成为条的总数而不是两个单独的条?
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"url": "https://raw.githubusercontent.com/taramcgirl/InfoVisProject/master/graphone.csv",
"format": {
"type": "csv"
}
},
"title": {
"text": "Total Backers per Category",
"anchor": "middle",
"fontSize":24
},
"width":400,
"height":400,
"mark": {
"type": "bar",
"cornerRadiusEnd": 4
},
"encoding": {
"x": {
"axis": {
"title": "Number of Backers",
"labelFontSize":10,
"titleFontSize":15
},
"field" : "Backers",
"type" : "quantitative",
"aggregate": "sum"
},
"y": {
"axis": {
"title": "Category",
"labelFontSize":10,
"titleFontSize":15
},
"field":"Main_Category",
"type" : "nominal",
"sort": "-x"
},
"color": {
"field": "USA or ELSEWHERE",
"type": "nominal",
"scale": {
"domain":["US","Other"],
"range": ["#8101FA", "#00C7A9"]
}
},
"opacity": {
"value" : 0.5
}
},
"layer": [{
"mark": "bar"
}, {
"mark": {
"type": "text",
"align": "left",
"baseline": "bottom",
"stroke":"black",
"dx": 3,
"fontSize": 9,
"fontWeight": "normal",
"stack":"false"
},
"encoding": {
"text": {
"field": "Backers",
"type": "quantitative",
"aggregate": "sum",
"stack": "true"
}
}
}]
}
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"url": "https://raw.githubusercontent.com/taramcgirl/InfoVisProject/master/graph1.csv"
},
"title": {
"text": "Total Backers per Category",
"anchor": "middle",
"fontSize": 24
},
"width": 400,
"height": 400,
"encoding": {
"x": {
"axis": {
"title": "Number of Backers",
"labelFontSize": 10,
"titleFontSize": 15
},
"scale": {"domain": [0, 10000000]},
"field": "Backers",
"type": "quantitative",
"aggregate": "sum"
},
"y": {
"axis": {"title": "Category", "labelFontSize": 10, "titleFontSize": 15},
"field": "Main_Category",
"type": "nominal",
"sort": "-x"
}
},
"layer": [
{
"mark": {"type": "bar", "cornerRadiusEnd": 4},
"encoding": {
"color": {
"field": "USA or ELSEWHERE",
"type": "nominal",
"scale": {"domain": ["US", "Other"], "range": ["#8101FA", "#00C7A9"]}
},
"opacity": {"value": 0.5}
}
},
{
"mark": {
"type": "text",
"align": "left",
"baseline": "middle",
"stroke": "black",
"dx": 3,
"fontSize": 9
},
"encoding": {
"text": {"field": "Backers", "type": "quantitative", "aggregate": "sum"}
}
}
]
}