Commit 9134d48f authored by Vladimir Kiryakov's avatar Vladimir Kiryakov
Browse files

added time to chart

parent e8f6cfe0
......@@ -5,6 +5,7 @@ import C3Chart from 'react-c3js';
import 'c3/c3.css';
import classNames from "classnames";
import _ from "lodash";
import moment from 'moment';
class Chart extends Component {
......@@ -29,18 +30,34 @@ class Chart extends Component {
render() {
const {className, accelXYZ} = this.props;
const data = {
x: 'time',
rows: [
['x', 'y', 'z'],
['x', 'y', 'z', 'time'],
...accelXYZ
],
type: 'line'
type: 'line',
};
const axis = {
x: {
tick: {
format: (x) => moment(x).format("hh:mm:ss")
}
}
};
const transition = {
duration: 0
};
return (
<div className={classNames('text-muted', className)}>
<label>Accelerometer</label>
<C3Chart key={Math.random()} data={data} size={{
<C3Chart data={data} size={{
height: 240
}}/>
}} transition={transition} axis={axis}/>
</div>
);
}
......
......@@ -27,8 +27,9 @@ export default (state = {
const x = _.get(obj, 'accel.x');
const y = _.get(obj, 'accel.y');
const z = _.get(obj, 'accel.z');
const timestamp = _.get(obj, 'timestamp');
if (x && y && z) {
return [x, y, z];
return [x, y, z, timestamp];
}
}).filter((i) => !_.isNil(i));
......
......@@ -5161,6 +5161,10 @@ mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.1, mkdirp@~0.5.0, mkdi
dependencies:
minimist "0.0.8"
moment@^2.22.0:
version "2.22.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.0.tgz#7921ade01017dd45186e7fee5f424f0b8663a730"
mqtt-packet@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/mqtt-packet/-/mqtt-packet-5.5.0.tgz#7f53244ba49fdecf795e950c14a9432dbf33bc63"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment