1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-26 20:00:05 +02:00
copilot/legacy/spikes/graphs-fe/c3js/client/c3js.js

44 lines
700 B
JavaScript
Raw Normal View History

2016-11-08 14:46:23 +02:00
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);