I modified an existing simulation to demonstrate how the displacement of particles along a longitudinal wave can be represented in graphical form.
Essentially, one would have to determine for each particle, its displacement from the equilibrium position and its corresponding position along the wave’s direction. On the graph, positive displacement indicates movement in one direction (e.g., to the right), while negative displacement indicates movement in the opposite direction (e.g., to the left).
For the full view, go to https://www.geogebra.org/m/kq3e2qjk