Mendix Time Series Widget Consuming Rest Service always a Vertical Straight Line

0
Hello Everyone, I am trying to create a Live Time Series Graph which consumes a external REST service. The REST service is being consumed in a microflow and I am storing the returned values in an Import Mapping non persistable entity. I am getting a list of values as below.   I am getting a list of JSON Objects in a JSON Array which I am then mapping to WindSeries Entity in a Loop and returning that List out of the microflow. I am then displaying a Time Series Chart with refresh interval as 5 seconds.   Data Mapping for X and Y axis is as follows : X → Date and Time Field Y → Integer field   The Problem is when my Time series chart refreshes after every 5 seconds, It is not retaining the old values on the graph, rather its refreshing the entire graph. The Date Time values from the Rest API are  having a difference of 5 seconds for each row.. Since mendix is refreshing the entire graph and not storing the old values in the previous REST iinvocation, I am always getting a Straight line as below. What I have observed is X axis which is holding Date Time is moving to the next value i.e. + 5 seconds of the previous value and the straight line in Y axis appears on that new Date Time.  But I want a regular Time series graph which moves with respect to time on the x-axis while retaining the plotted values of the previous Rest call.  Can anybody help me or point me where I am wrong. Note: Time series chart is not enclosed in any Data View or List View. Source is a microflow which returns a list of Wind Series values
asked
4 answers
0

Hi Aniketh,

You need to feed your chart the entire list of entries you wish to display, so have your microflow return a list containing all measurements. Your service returns multiple objects right? Just convert (if necessary) and return these objects.

Good luck!

answered
0

Dear Aniketh,

Not sure, what is causing the issue on your chart. Did you try out the how to? There is one on a direct REST  https://docs.mendix.com/howto/front-end/charts-basic-rest But not sure if you need that.

You can also have a look at the mendix development TestProject.mpk found in the release files of the repo It contains many example how to implement the charts

https://github.com/mendixlabs/charts/releases

Cheers, Andries

 

answered
0

Hi Aniketh, the two X values shown in your variables have the exact same date and time, so that (perhaps) explains the single data point on your x axis. If you need old consumed data in the chart you need to have it persisted and use database as datasource. I think the consumed data holds data for multiple windmills at 1 moment in time, if that's the case you can create multiple series for each of the objects returned by each rest call. 

answered
0

Hello Everyone,

Thank you so much for your inputs and solutions. I was able to figure out my problem from your inputs.

I had a Date and Time field on X-axis. But Plot.ly JS by default considers x-axis as Date. Since all my values from REST service were from the same DATE but different time (with a 5 to 30 second difference between each row), I was getting a straight line.

I had to format the Time series chart using Advanced Layout properties saying X-axis format type is ‘time’ instead of the default ‘date’. Now my Time series chart is appearing fine.

As you can see now only Time is being shown in X-axis instead of both date and time.

I had to go through plot.ly JS reference document to find this clue but got it solved in the end.

The problem of refreshing the entire graph is still present and the graph is still not storing values from the previous REST call and new values get plotted on the entire graph. But that is something I can solve by modifying my microflow. I will work on it and post if I can figure it out. 

Cheers and Thanks to all who responded guys.

Aniketh

answered