I am developing a fuel related project where one of the tasks is to show a chart representing the fuel consumption of the vehicle (based on a data that is coming from the fuel sensor device) on node js.
So, I get the raw fuel data like an integer and decimal values like 135, 134.8 ,134.7 etc
However, if the vehicle is moving, there may be inconsistent data due to the physics of the vehicle and due to bumps ,downhill,uphill and many other factors noise is being generated which i need to smoothen . For example, a data series may be:
76,76,75,74,73,73,71,70 <- this is a good pattern because it shows how the fuel is going down.
76,70,75,76,77,76,74,74,73,72,69,72,73,73,72,71 <- this is not a good pattern bacause due to jumps the fuel in the tank is not consistent and the data I receive is not appropriate to display to the user.
I want to smooth the raw fuel values, but depending on how many values I choose to average at a time, the result is different.
The key problem is that sometimes there are draining and refueling moments which I MUST show in the chart, and must not smooth.
What kind of filter and algorithm can I use in node js or javascript in order to analyse and represent my chart or graph in convincing way to the user?
Anyone who have already implemented it we can discuss
Thank you in Advance
What I have tried:
raw fuel data smoothing using node js