轴刻度标签 [英] Axis tick labelling

查看:113
本文介绍了轴刻度标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的折线图的x轴代表金钱。有什么方法可以在每个tick的开头附加一个€符号吗?

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

此时,它们只是值2000000,250000,300000 ....

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

我想让他们显示€2000000,€250000,€300000 ....

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

推荐答案

使用

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

例如:

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

同时考虑使用 d3.format 以逗号/句点等对数字进行分组。

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

这篇关于轴刻度标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆