You are right, derivative
is causing your problem. This is the underlying code:
eachSeries.data = _.map(pairs, function(point, i) {
if (i === 0 || pairs[i - 1][1] == null || point[1] == null) {
return [point[0], null];
}
return [point[0], point[1] - pairs[i - 1][1]];
});
It will output the difference to the data point before the current data point, but won't skip null values.
Could you try applying fit
before derivative
? Then it should fill in the missing values before calculating the derivative, which should give you the derivative of the existing values. In this case fit(none)
should be the right choice because it basically just gets rid of the null data points in between.
.es(index=bindjson*,timefield='@timestamp', metric=max:qtypes.A).fit(none).derivative().label("A").lines(fill=2,width=1).color(#03f4fc),