Axis tick labelling

我的未来我决定 提交于 2019-12-30 09:30:09

问题


The x axis of my line graph represents money. Is there any way to append a € symbol to the beginning of each tick?

At the moment they are just values 2000000, 250000, 300000....

I would like them to display €2000000, €250000, €300000....

I tried adding the € to my .CSV file but it caused an error when I tried to call the data to make my axis.


回答1:


Use the tickFormat function:

https://github.com/mbostock/d3/wiki/Quantitative-Scales#wiki-linear_tickFormat

For example:

axis.tickFormat( function(d) { return "€" + d } );

Also consider using d3.format to group your numbers by with commas/periods, etc.



来源:https://stackoverflow.com/questions/15009500/axis-tick-labelling

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!