How can I change what is displayed on the graph labels?
Greetings, I’m trying to create a line or timeseries chart where X axis shows the time when an object is created and the Y axis shows the relevant data. The entity that feeds Y data has two attributes, one integer type and the other string type. For example: 1 – 4 Hours 2 – 8 Hours 3 – 24 Hours.. and so on The end result I’m trying to achieve is to rank Y axis labels based on the integer attribute, but the info written on Y axis should be the string values of the objects. So on the chart, labels should be seen as 4 Hours, 8 Hours, 24 Hours… from bottom to top and they should be placed as if they had values of 1 – 2 – 3… on the graph’s y axis. The problem I face is that the graphs available in Mendix do not provide this functionality. If I set the Y axis attribute as the integer attribute, I cannot show the strings to the user, but if I set the axis attribute as the string attributes of the objects, then the placement of the labels get mixed up based on which object is committed earlier. For example If I commit an object that has “24 Hours” value before an object with “8 Hours” value, 24 Hours label is placed below the 8 Hours label in the graph’s Y axis. I intended to use anychart because “labelalias” functionality provided in plotly.js solves my problem perfectly. Unfortunately, that function is not supported on Mendix since the plotly.js version used by Mendix is an old version. I also tried using data sorting methods provided by mendix. If I sort the data based on the Y axis values before feeding into the graph, the chart turns into a “vertical” version which moves upwards in Y direction, instead of rightwards in X direction. Any advice would be highly appreciated. Thanks in advance.
I’ve solved the problem using AnyChart widget and creating 2 different traces.
First trace is a scatter plot which is used to configure the graph’s Y axis, The data it contains correspond to each Y axis value and each data point has the same X value. I’ve also minimized the size of each scatter point so that they are not visible. This invisible scatter plot helped me configure the Y axis labels as I desired.
The second plot is the actual plot.
I’ve used a microflow with 4 variables (CalibrationDataXValues, CalibrationDataYValues, ActualDataXValues, ActualDataYValues) and 2 loops (one to fill CalibrationData variables and the other to fill ActualData variables) to fill the Nonpersistent entity required to configure the anychart layout and datasets.