Last active
March 15, 2017 19:18
-
-
Save erikologic/9256f3c1311185abf37fd8e1bfd85b4b to your computer and use it in GitHub Desktop.
This file contains 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
class DataConverterContainer extends Component { | |
getDatasetfromJsonData(jsonData){ | |
return jsonData[0].scores; | |
}; | |
getLabels(dataset){ | |
return Object.keys(dataset) | |
}; | |
getData(dataset){ | |
// probably need to loop through each label to get values in the proper order | |
return Object.values(dataset) | |
}; | |
chartData = (dataset) => { | |
return { | |
labels: this.getLabels(dataset), | |
datasets: [{ | |
data: this.getData(dataset) | |
}] | |
} | |
}; | |
render() { | |
var dataset = this.getDatasetfromJsonData(this.props.jsonData); | |
let chartData = this.chartData(dataset) | |
return <Graph chartData={chartData} width={800} height={800}/> | |
} | |
}; | |
export default DataConverterContainer | |
// ...IN THE CALLER | |
import DataConverterContainer from './DataConverterContainer'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment