Display Live time series chart

0
Hi, I am new to Mendix, I want to display ‘live’/streaming time series values in a graph (Line Chart) where x-axis is DateTime and Y-axis is numbers. The graph will get data every 1-2 seconds from external server using MicroFlow with REST API. The thing is that the TimeSeries component displays always empty graph that starts from May-2000 although I am passing data of this year.. Here is an example of what is back from the server: {"time_stamp": 1692.224, "actual_robot_voltage": 719.0, "safety_mode": 726, "tool_temperature": 765.0, "runtime_state": 723, "actual_main_voltage": 764.7601509094238, "tool_mode": 974, "_time": "2019-09-26T16:26:48.615Z", "actual_momentum": 719.0, "robot_mode": 722} ** Note: I am using _time as my x-axis and ‘safety_mode’ as my y-axis
asked
5 answers
0

Hi Ahmed,

I think you are on the right track! You should be able to use the TimeSeries widget using a microflow datasource, in which you retrieve data from an external server and set a refresh of the chart on every 1 or 2 seconds.

Make sure the datasource-microflow returns a list of all the datapoints, and you set both the x-axis value and sort value:

If that's OK, can you show the result of that microflow (for example a screenshot of the Variables-window when breaking on the datasource-microflow)?

Kind regards,

Johan

answered
0

The app displays list of robot’s information…

Robot Entity are defined in Mendix: Name, entity-id and property-set-name. (Last two, values are copied-paste from MindSphere)

There is an HTTP server running that fetching data from MindSphere time series service. (The internal implementation does the login to MindSphere)

 

Robot Overview, displays Robot Persistent Entity

I added Time Series Chart

 

 

Note: Entity NativeModule.TimeSummary is not persistent

 

Here is the Microflow for fetching data from the HTTP server

Example of returned data from the server while debugging:

 

Example of data printed in the server log:

{'time_stamp': 100, 'actual_robot_voltage': 0.0, 'safety_mode': 4, 'tool_temperature': 46.0, 'runtime_state': 4, 'actual_main_voltage': 45.76015090942383, 'tool_mode': 255, '_time': '2019-09-26T16:28:28.28Z', 'actual_momentum': 0.0, 'robot_mode': 3}

 

And here how the chart looks like!!!

Note: the x-axis starts from May 2000 to Jan 2001 and I can’t change it!! Although _time (x-axis) from the server are 2019…

 

answered
0

Hi Ahmed,

Thank you for the detailed explanation; you really are so close!

I was able to reconstruct the Mar, May 2000 x-axis: when the returned list of datapoints is empty. Can you check which variable you return in the UR_IOT_Latest_GET datasource microflow? And using a breakpoint: wat the values are?

How do you get your list? Creating one like below? Or retrieving over association? Keep in mind: following an association from persistent to non-persistent will return an empty list.

 

Kind Regards,

Johan Flikweert

 

answered
0

You are right w.r.t. the List is empty...I fixed it now and added: ‘Add to list...’ and the debugger now show the list has one element.

However, the graph still does not show anything since I am sending every time list of one element.

I am now trying to figure out how to keep the data coming from the server in some Transient List so I send list + new item to the chart.

Any help?

thanks again

answered
0

I would suggest you put the widget in a non-persistent container like this:

Associate the container with the datapoint entity, such that you can return a list of datapoints by retrieving over association in your datasource microflow:

 

 

 

To also remove “old” datapoints, you should make some custom logic to delete these from the list.

Good luck!

answered