- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要使用d3.scaleTime()在任何随机日期之间获取恒定的刻度值间隔并在轴上绘制。
但是
timeScale.nice(intervalValue);
//or
axisXScale.tickValues(timeScale.ticks(10));
没有帮助,我总是得到随机数量的刻度值。
根据 D3 文档
# continuous.ticks([count])
Returns approximately count representative values from the scale’s domain. If count is not specified, it defaults to 10.
The returned tick values are uniformly spaced, have human-readable values (such as multiples of powers of 10), and are guaranteed to be within the extent of the domain.
Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data.
The specified count is only a hint; the scale may return more or fewer values depending on the domain.
有什么方法可以得到一个常数而不是近似值
最佳答案
我认为你需要做这样的事情:
.ticks(d3.timeMonth.every(1))
欲了解更多详情,请访问http://www.d3noob.org/2016/08/changing-number-of-ticks-on-axis-in.html .
希望这有帮助!
关于javascript - 在 d3.scaleTime() 中获取恒定的刻度间隔值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42838389/
我正在尝试设置一个时间刻度,其中包含 2 个相隔 40 天的日期。我的数据是: [ { "date": "Wed Jul 06 2016 16:44:14 GMT-0400",
使用 d3 我有一个 xAxis 定义为 var xScale = d3.scaleTime() .domain([fromDate, toDate]) .range([0, width]);
我希望 d3 js 图表具有基于某些时间戳的不同背景矩形。 var orangeBack = svg .append("rect") .attr("x", margin.left + 0)
我正在尝试使用 d3.js 显示一个使用 json 对象(字符串)的图形,该对象是从 aspx 网页代码背后的服务器中提取的。过去几天我一直在进行故障排除,但遇到了困难。 我得到: d3.v5.min
DEMO 我需要使用d3.scaleTime()在任何随机日期之间获取恒定的刻度值间隔并在轴上绘制。 但是 timeScale.nice(intervalValue); //or axisXScale
我正在 d3 v4 中实现一步后插值图。时间保存为格式为“hh:mm:ss.ss”的字符串。我通过将时间字符串转换为秒来向 timeScale 传递一系列整数。尽管如此,我收到“错误:属性 d:预期数
我有一个日期列表,我试图让容器代表一周中的每一天,以便绘制直方图。结果有点像我想要的,但是最后一个 bin 有 x0=x1,因此总是空的。为什么 bin 数组有 8 个元素,而我想要 7 个? 我试图
我正在使用 D3、Javascript、HTML 和函数 d3.scaleTime() 我在 d3 中使用scaleTime()函数输入日期的方式有什么问题? 我目前正在尝试使用 d3.scaleTi
我这里有一个代码笔 - https://codepen.io/anon/pen/xpaYYw?editors=0010 这是一个简单的测试图,但日期会像这样格式化。 我在 x 轴上有日期,在 y 轴上
我正在尝试使用带有 d3.scaleTime() 刻度的 d3.js 绘制条形图。我尝试搜索,但没有在 d3 v4 中找到更好的示例。所以决定构建一个,但我认为我为 monthScale 指定的 do
我正在尝试创建一个简单的条形图,其中 x 轴采用日期格式。我已经这样定义了我的 x, var minDate = new Date(data[0][0]); var maxDate = new Dat
我正在 angular2 组件中实现以下 block (一个简单的折线图): https://bl.ocks.org/d3noob/6f082f0e3b820b6bf68b78f2f7786084 我
我是一名优秀的程序员,十分优秀!