d3.js& nvd3.js - 如何设置y轴范围 [英] d3.js & nvd3.js -- How to set y-axis range

查看:354
本文介绍了d3.js& nvd3.js - 如何设置y轴范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将图表的y轴范围设置为1-100。



请参阅API文档,并找到一个可能的解决方案axis.tickValues如此处所示
https://github.com/mbostock/ d3 / wiki / SVG-Axes#wiki-tickValues



但是,使用该选项不起作用。在上面链接的axis.tickSize下的文档页面上进一步阅读,发现了以下行


结束标记由相关比例的domain extent
并且是生成的路径域的一部分,而不是记号线




我可以在哪里指定范围?



附加 .forceY([0,100])

code>到图表的实例化强制轴进入数组中指定的范围。



从这里的例子http://nvd3.org/livecode/#codemirrorNav



附加 .forceY([0,100])到图表变量。


I'm trying to set the y-axis range of the chart from 1-100.

Consulted the API documentation and found a possible solution with axis.tickValues as seen here https://github.com/mbostock/d3/wiki/SVG-Axes#wiki-tickValues

However, using the option does not work. Reading further down on the documentation page linked above under axis.tickSize, the following line was spotted

The end ticks are determined by the associated scale's domain extent, and are part of the generated path domain rather than a tick line

So I take it setting the min and max of the range can't be done through the Axis option.

Any ideas on where I can specify the range?

解决方案

Found a solution.

Appending .forceY([0,100]) to the instantiation of the chart forces the axis to take on the range specified in the array.

From the example here http://nvd3.org/livecode/#codemirrorNav

Appending .forceY([0,100]) to the chart variable works.

这篇关于d3.js& nvd3.js - 如何设置y轴范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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