Forum Discussion
AmiraB
9 years agoFrequent Visitor
Custom Visuals- How to move text when resizing chart
I tried adding text to the Sample Bar Chart code bars.enter()
.append("text")
.classed("label",true) //or "label"
.attr ("y",d => yScale(<num...
- 9 years ago
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" });
AmiraB
9 years agoFrequent Visitor
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"
});- v-chuncz-msft9 years agoCommunity Support
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.