如何使图表中的网格线变为静态 [英] How to make the gridlines in the chart static

查看:99
本文介绍了如何使图表中的网格线变为静态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑链接使用字母数字字符标记轴的示例。在这个例子中,网格线是动态的,即网格线根据坐标值增加或减少。如何使这个静态的,即使图表中的坐标值与实例无关?

consider the example in the link Labeling the axis with alphanumeric characters. In this example the gridlines are dynamic that is the number of gridlines increases or decreases according to co-ordinate values. How to make this static i.e. make the chart as it is in the example independent of co-ordinate values ?

注意: - 通过更改最后一个坐标值[17 ,16]整个图表根据坐标值进行压缩或展开。

NOTE :- By changing the last co-ordinate value [17,16] the entire chart is either compressed or expanded depending on co-ordinate value.

推荐答案

最简单的方法是修复域的上限。举个简单的例子,如果你知道x和y的值不会超过30,你可以这样做:

The simplest way to achieve this is to fix the upper range of the domain. As a simple example, if you know your values in x and y will not exceed 30, you can do this:

var x = d3.scale.linear()
    .domain([0,30])
    .range([0, width]);

var y = d3.scale.linear()
    .domain([0,30])
    .range([0, height]);

这篇关于如何使图表中的网格线变为静态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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