Text On each bar of a stacked bar chart d3.js
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 选择语言 中文(简体) 日语 英语 中文(繁体) 由 翻译 强力驱动 问题: I would like to have some text in each bar of a stacked bar in stacked bar chart provided in d3.js library. Thanks for your help. I have customized the example here link but I have not changed anything else in the javascript code and here is the result 回答1: Here is the important piece of code: state . selectAll ( "rect" ) . data ( function ( d ) { return d . ages ; }) . enter (). append ( "rect" ) . attr ( "width" , x . rangeBand ()) . attr ( "y" , function ( d ) { return y ( d . y1 ); }) . attr ( "height"