There are websites with historical data of coins. How do they get it?
Do they get the price from 10 exchanges at the same time, then divide by 10?
Every website may have a different way of aggregating this sort of data. I would expect that the exact method used by each website will be determined by their specific needs/applications. There is no absolute "right or wrong way" to get this job done. For example:
To find more info on some actual implementations, I would suggest looking up some websites that display data in the way you're looking for, and see if they provide any info on the algorithms/methods used. I would guess at least a few sites make that info public.