使用本示例http://nvd3.com/ghpages/stackedArea.html中所示的堆积面积图
尝试将y轴记号标签和工具提示标签格式化为整数而不是浮点数。尝试将以下代码从
chart.yAxis
.axisLabel('Users')
.tickFormat(d3.format(',.2f'));
至
chart.yAxis
.axisLabel('Users')
.tickFormat(d3.format(',.0d'));
精度保持不变(仍将值显示到第100位)。我已经关注了Github Wiki,但没有用https://github.com/mbostock/d3/wiki/Formatting#wiki-d3_format
我们将非常感谢您的任何建议或提示。
发布于 2015-07-13 14:52:41
它可以将标签文本从浮点型格式化为整型。
对于饼图:
chart.pie.valueFormat(d3.format(',.0d'));
对于折线图:
chart.yAxisTickFormat(d3.format(',.0d'));
发布于 2015-02-11 17:29:09
.yAxis
方法上的.tickFormat
方法没有正确更新它。这是我使用的变通方法:
chart.yAxisTickFormat(d3.format(',.0d'));
发布于 2016-01-18 04:09:53
我试过这样做
.axisLabel('%').tickFormat(function(d) { return parseFloat(d).toFixed(1) + "%"; });
这对我很有效。我得到了小数点和百分比的结果。
https://stackoverflow.com/questions/11656788
复制相似问题