I have been trying to display the “sum” values of a group transform in the bar chart.
Here is the plot code.
Plot.plot({
marginLeft:125,
marginRight:50,
width: 600,
height: 300,
x: {
grid: true
},
marks: [
Plot.barX(dashboard_data, Plot.groupY({x: "sum"}, {x: "article_count", y: "topic"})),
Plot.text(dashboard_data, Plot.groupY({x: "sum"}, {x: "article_count", y: "topic", text: "article_count", textAnchor: "end", dy: 10})),
Plot.ruleX([0])
]
})
Thanks!
You can add text
to the output of the group transform:
Plot.text(dashboard_data, Plot.groupY({text: "sum", x: "sum"}, {x: "article_count", y: "topic", text: "article_count", textAnchor: "end", dy: 10}))
Thanks - that worked great! I added a filter but do not see the sum text?
Plot.barX(dashboard_data.filter(d => d.time_period === timeselect), Plot.groupY({x: "sum"}, {x: "article_count", y: "topic", fill: "topic", fillOpacity: 1})),
Plot.barX(dashboard_data.filter(d => d.time_period === timeselect), Plot.groupY({text: "sum", x: "sum"}, {x: "article_count", y: "topic", text: "article_count", textAnchor: "start", dx: 10})),
Looks like you need Plot.text instead of Plot.barX in the second line?