Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axis tick labelling

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.

like image 638
Daft Avatar asked Feb 21 '13 18:02

Daft


1 Answers

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.

like image 198
Andrew Mao Avatar answered Oct 18 '22 02:10

Andrew Mao