如何减少凹窝.js中Y轴记号的数量
How do you reduce the number of Y-axis ticks in dimple.js?
在酒窝.js中,有没有一种方法可以将y轴记号的数量减少一半,这样它只显示每隔一个y记号,而不是所有的y记号?
您可以在绘制后使用一些d3对其进行修改。这里有一种方法,它将删除每n个留下的标签:
// Pass in an axis object and an interval.
var cleanAxis = function (axis, oneInEvery) {
// This should have been called after draw, otherwise do nothing
if (axis.shapes.length > 0) {
// Leave the first label
var del = 0;
// If there is an interval set
if (oneInEvery > 1) {
// Operate on all the axis text
axis.shapes.selectAll("text").each(function (d) {
// Remove all but the nth label
if (del % oneInEvery !== 0) {
this.remove();
// Find the corresponding tick line and remove
axis.shapes.selectAll("line").each(function (d2) {
if (d === d2) {
this.remove();
}
});
}
del += 1;
});
}
}
};
小提琴来了:
http://jsfiddle.net/V3jt5/1/
相关文章:
- 改进 jQuery 以减少重复
- 如何通过ajax增加/减少PHP变量值并重新加载函数
- 设置随机数,然后每5秒随机减少一次,直到达到0(javascript)
- 如何减少在移动网络应用程序上播放声音的延迟
- “createImageData()”和“new ImageData(()”有何不同
- 如何减少if语句的数量
- 如何在这个JavaScript中减少代码重复
- 根据元素高度和宽度的百分比变化增加或减少字体大小
- 使用自定义记号创建可缩放的Y轴
- .在没有蓄能器的情况下减少
- Grunt手表在纠错后运行不减少
- 引导时间选择器在增加或减少小时和分钟的同时获取 NaN
- 函数比javascript中的步进器增加/减少更多
- 如果一个手风琴发出咔嗒声,如何最大限度地减少其他手风琴
- 如何通过分配单个变量来减少此脚本中的链接数
- 如何减少骨干路由器中的重复代码
- 在linux上使用软件包减少grunt的大小.文件路径对Jenkins来说太长
- d3.js yaxis没有正确绘制所有记号
- 减少JSON数据
- 如何减少凹窝.js中Y轴记号的数量