Sample data from Bitcoin Dominance Chart on Coin Market Cap.

Bitcoin dominance chart

CoinmarketCap has some global charts.You can find them on https://coinmarketcap.com/charts/. I was particularly interested in the dominance chart.

Recently when I was trying to do sampling from the above Graph for an article https://medium.com/@gokulnk/bitcoin-dominance-and-the-emergence-of-others-64a7996272ad it was taking a lot of time and irritating. While using MAC split screen in it was not easy to switch the focus between the split screens (Comment if you know how to do it.). So I set out to write a small script to fetch the data. Though the script took a little longer than I expected, I think I will save a lot of time going forward whenever I want to do sampling. I am putting out the script so that others also can use it.

You can checkout the gist on https://gist.github.com/nkgokul/79b2d01a4128b3716ec725d444ec83ee

Looks like gists are not generating the embed properly for me. So I putting up the code as well.

dominanceChart = Highcharts.charts[2];
coinsForDominance = ['Bitcoin','Ethereum','Bitcoin Cash', 'Ripple', 'Others'];
datesForDominance = ['Jan 25 2017', 'March 10 2017', 'March 26 2017', 'May 18 2017', 'June 14 2017', 'August 03 2017', 'November 12 2017', 'Dec 8 2017', 'Jan 14 2018', 'May 3 2018'];
coinDateDominanceMatrix = [];
coinsForDominanceData = dominanceChart.series.filter(coin => {return coinsForDominance.indexOf(coin.name) != -1});
csvString = "Date, " + coinsForDominance.join();
firstDateTime = coinsForDominanceData[0].xData[0];
date = new Date(1485242220000);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
difference = firstDateTime - date.getTime();

datesForDominance.forEach(function(relevantDate){
csvString+= "n" + relevantDate + ", ";
coinDateDominanceMatrix[relevantDate] = [];
coinsForDominanceData.forEach(function(coin){
timestring = Date.parse(relevantDate)+difference;
coinDominance = coin.yData[coin.xData.indexOf(timestring)];
var dominanceValue = Math.round(coinDominance * 100) / 100;
coinDateDominanceMatrix[relevantDate][coin.name]= dominanceValue;
csvString+=dominanceValue + ", ";
});
});
console.table(coinDateDominanceMatrix);
console.log(csvString);

Just visit the page and copy paste the following code into console to get the relevant data. You can also edit “`coinsForDominance“` and “`datesForDominance“` variables to get the data that you need.

Let me know if it helped you.

read original article here