Commit 87f04fe4 authored by Laurianne Charrier's avatar Laurianne Charrier
Browse files

Merge branch 'dgoepp/config-modules' of...

Merge branch 'dgoepp/config-modules' of https://gitlab.liris.cnrs.fr/behaviors-ai/the_dashboard into dgoepp/config-modules
parents 6b7b3cf0 89686464
......@@ -86,7 +86,8 @@ class RosLineChart extends Component {
* Extract a field from a ros message and add it to the state, for plotting.
*
* If there are already maxPoints in storage, we remove the oldest data point.
* @param {string} field path to the field to be extracted from incoming messages
* @param {Object} curve has two entries, `field`, path to the field to be extracted from incoming messages
* and `topic` the ROS topic from which we extract the field.
* @param {integer} maxPoints mupper limit on the number of data entries for the plot
* @param {Object} message messages from a ROS topic
*/
......@@ -94,13 +95,14 @@ class RosLineChart extends Component {
this.setState((state) => {
let new_data = this.state.data;
const field = curve.field;
if (!(field in new_data)) {
new_data[field] = []
const data_field = curve.topic+field;
if (!(data_field in new_data)) {
new_data[data_field] = []
}
if (new_data[field].length >= maxPoints) {
new_data[field].shift();
if (new_data[data_field].length >= maxPoints) {
new_data[data_field].shift();
}
new_data[curve.topic+field] = this.state.data[field].concat([{"y": property(field)(message)}])
new_data[data_field] = this.state.data[data_field].concat([{"y": property(field)(message)}])
return {
data: new_data,
}
......
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