Javascript Flot图表显示负值,但不显示';我没有
我正在使用这些数据:Javascript Flot图表显示负值,但不显示';我没有,javascript,jquery,flot,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], [Mo
{
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
}
由于某种原因,我的图表变成了负值。我预计它在2天前为零,然后突然跳到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)
根据,你可以设置
monotonicFit: true
这看起来像是使用贝塞尔曲线算法的问题,而不是数据问题。我不熟悉Flot,但请检查是否可以修改线条平滑算法-我猜
curvedLines
属性。可能设置单调拟合:true
。是的,Rory是对的。我以前见过这个问题。这里有一个链接,指向拥有相同(不相关)库的人的列表:@NinaScholz-这确实解决了负面问题!谢谢请随意发布答案,我会接受的。从第5个曲线到168个值,曲线仍然存在,您(作为用户/开发人员)会期望吗?编辑:设置curvedLines:false
对外观奇怪的曲线数据进行排序。另外,感谢各位的反馈。
parameter type effect
------------ ---- -----------------------------------------------------------------
monotonicFit bool true => uses monotone cubic interpolation (preserve monotonicity)