This example show how to use a ol.style.FlowLine to display elevation color along a GPX track.
You have to set the visible option to false to calculate the values on the whole line and not only on the visible part of it.
Look at this example for more information.