This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
I tried adding text to the Sample Bar Chart code
bars.enter()
.append("text")
.classed("label",true) //or "label"
.attr ("y",d => yScale(<number>d.value)+1)
.attr ("x",d => xScale(d.category)+xScale.rangeBand()/2)
.attr("text-anchor", "middle")
// .attr("font-size", "10000000.5em")
.attr("fill", "red")
.text(d => <string>d.value)
;
The issue is this text do not move when I resize the chart
Solved! Go to Solution.
This solved the issue .
let text = this.barContainer.selectAll('.bar').data(viewModel.dataPoints);
text.enter()
.append('text')
.classed('bartext', true)
.text(d => <string>d.value2);
text.attr({
y: d => height - 15,
x: d => xScale(d.category) + xScale.rangeBand() / 2,
'text-anchor': "middle",
fill: "red"
});
This solved the issue .
let text = this.barContainer.selectAll('.bar').data(viewModel.dataPoints);
text.enter()
.append('text')
.classed('bartext', true)
.text(d => <string>d.value2);
text.attr({
y: d => height - 15,
x: d => xScale(d.category) + xScale.rangeBand() / 2,
'text-anchor': "middle",
fill: "red"
});
Glad to hear that you've solved this problem and thank you for sharing the solution. This might be beneficial to other community members, you could help mark it as answer.
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |