1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 22:20:06 +02:00
copilot/spikes/graphs-fe/c3js/client/c3js.js
2016-11-08 14:12:16 +00: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);