曲线图显示负值,但没有任何值

网民

我正在使用以下数据:

{
    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,因为我引入了另一个数据集,该数据集变成负值(费用)。

它产生的是:

在此处输入图片说明

我正在像这样初始化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)
妮娜·斯科茨(Nina Scholz)

根据文档,您可以设置

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章