Take a look at this article titled: perf Examples, it has a number of examples that show how you can make flame graphs such as this one:
!flamegraph
The above graph can be generated as an interactive SVG file as well. The graph was generated using the FlameGraph tool. This is separate software from `perf`.
A series of commands similar to this were used to generate that graph:
$ perf record -a -g -F 99 sleep 60
$ perf script | ./stackcollapse-perf.pl > out.perf-folded
$ ./flamegraph.pl out.perf-folded > perf-kernel.svg
The CPU FlameGraphs (above) are covered in more detail in this article, titled: CPU Flame Graphs. For details on FlameGraphs for other resources such as memory check out this page titled: Flame Graphs.