1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-28 04:40:05 +02:00
copilot/legacy/spikes/graphs-fe/c3js/client/c3js.js
Sérgio Ramos 8295bd6882 chore: initial lerna setup
this shall be a progressive process
2017-05-25 10:56:50 +01:00

44 lines
700 B
JavaScript

const C3Graph = require('react-c3js').default;
const ReactRedux = require('react-redux');
const React = require('react');
const {
connect
} = ReactRedux;
const Graph = React.createClass({
render: function() {
const {
data = []
} = this.props;
const cpu = data.map((d) => Math.floor(d.cpu));
const datatime = data.map((d, i) => i);
const formattedData = {
x: 'x',
columns: [
['x'].concat(datatime),
['cpu'].concat(cpu)
]
};
return (
<C3Graph
data={formattedData}
/>
);
}
});
const mapStateToProps = ({
data
}) => {
return {
data
};
};
module.exports = connect(mapStateToProps)(Graph);