Created
March 15, 2017 19:25
-
-
Save erikologic/c94a8cadedd662623b1c4c36b874712c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDatasetfromJsonData(jsonData){ | |
return jsonData[0].scores; | |
}; | |
function getLabels(dataset) { | |
return Object.keys(dataset) | |
}; | |
function getData(dataset) { | |
return Object.keys(dataset).map(function(key) { | |
return dataset[key]; | |
}); | |
}; | |
function chartData(dataset) { | |
return { | |
labels: getLabels(dataset), | |
datasets: [{ | |
data: getData(dataset) | |
}] | |
} | |
}; | |
module.exports = function(JSONdata) { | |
var dataset = getDatasetfromJsonData(JSONdata); | |
return chartData(dataset) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment