I am developing a fleet management system and 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 CAN bus).
If a data value is between 0 and 100, it implies a percentage. So, if I get an integer that is 45, it means that the fuel in the tank is 45%.
However, if the vehicle is moving, there may be inconsistent data due to the physics of the ship. 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 because 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 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 fueling moments which I must show in the chart, and must not smooth.
What kind of algorithm can I use to analyse and represent my chart in convincing way to the user?