简体   繁体   English

NVD3 Line Plus Bar with Focus Chart仅显示首个和最后一个条的一半宽度

[英]NVD3 Line Plus Bar With Focus Chart only displaying half width of first and last bar

This is what it looks like: 看起来是这样的:

This is what I want it to look like: 这是我想要的样子:

(Created by adding dummy data in the beginning and end, and manually deleting svg paths...) (通过在开头和结尾添加虚拟数据,然后手动删除svg路径来创建...)

.forceX() only works for the small focus chart (the bottom one), but not with the main chart. .forceX()仅适用于小型焦点图(底部的焦点图),不适用于主图表。 I've been trying to fix it in the source code to no avail. 我一直试图将其在源代码中修复为无济于事。

Add elements to before and after for each series. 在每个系列之前和之后添加元素。 For x, use the number before and after the first and last number. 对于x,请使用第一个和最后一个数字之前和之后的数字。 For y, use NaN. 对于y,请使用NaN。 This will create an extra space before and after the bars. 这将在条形之前和之后创建一个额外的空间。

For the community here is the workaround, adding 1 day in my case as I deal with days (in second in my case), and using NaN as value so that it is not draw on the chart ;) Don't hesitate to ask for more informations :o) 对于社区而言,这是一种解决方法,在我的工作日中增加1天(在我的情况中为第二天),并使用NaN作为值,这样它就不会出现在图表上了;)请随时提出要求更多信息:o)

  barChart.unshift([minTimestamp - 86400, NaN]);
  lineChart.unshift([minTimestamp - 86400, NaN]);

  barChart.push([maxTimestamp + 86400, NaN]);
  lineChart.push([maxTimestamp + 86400, NaN]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM