javascript - 流程图显示负值,但它没有任何值

标签 javascript jquery flot

我正在使用此数据:

{
    label: 'Payments',
    // data: this.getFlotPaymentData(),
    data: [
      [Moment().subtract(6, 'days').valueOf(), 0],
      [Moment().subtract(5, 'days').valueOf(), 0],
      [Moment().subtract(4, 'days').valueOf(), 0],
      [Moment().subtract(3, 'days').valueOf(), 0],
      [Moment().subtract(2, 'days').valueOf(), 168.50],
      [Moment().subtract(1, 'days').valueOf(), 200.00],
      [Moment().valueOf(), 200.00]
    ],
    last: false
}

由于某种原因,我的图表变为负值。直到两天前我预计它会为零,然后突然跳到 168.50。

我不想将图表的最小值设置为 0,因为我引入了另一个数据集,该数据集会变成负值(费用)。

它正在产生这个:

enter image description here

我正在像这样初始化flot:

// Chart options
var chart = $('#flot-visitors')
var labelColor = chart.css('color')
var options = {
  colors: chart.data('color').split(','),
  series: {
    shadowSize: 0,
    lines: {
      show: true,
      lineWidth: false,
      fill: true
    },
    curvedLines: {
      apply: true,
      active: true,
      monotonicFit: false
    }
  },
  legend: {
    container: $('#flot-visitors-legend')
  },
  xaxis: {
    mode: 'time',
    timeformat: '%d %b',
    font: {color: labelColor}
  },
  yaxis: {
    font: {color: labelColor}
  },
  grid: {
    borderWidth: 0,
    color: labelColor,
    hoverable: true
  }
}
chart.width('100%')

// Create chart
$.plot(chart, data, options)

最佳答案

根据Documentation ,你可以设置

monotonicFit: true
parameter    type effect
------------ ---- -----------------------------------------------------------------
monotonicFit bool true => uses monotone cubic interpolation (preserve monotonicity)

关于javascript - 流程图显示负值,但它没有任何值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41035536/

相关文章:

javascript - 如何制作一个正则表达式,将标签 {{name}} 替换为以这种方式命名的类的属性值

php - 如果当天没有结果,MySQL 查询将得到 0

javascript - 如何设置最大高度并允许使用 jQueryUI Selectmenu 滚动

javascript - 为公共(public)共享保存值状态(添加到 URL)

javascript - AJAX+Rails 点击处理程序未绑定(bind)

javascript - float : Get the x axis offset while drawing markings

javascript - 在所有行上强制使用相同的颜色

javascript - 动态显示列名

javascript - 使用 $.post() 的 jQuery 代码顺序

c# - 在 ASP.NET 中如何使 OnClick 在 OnClientClick 之后执行?