Any Chart 3D Surface JSON

0
Can anybody assist me with how I can take a set if x,y,z coordinates and convert them into the correct format for Plotly 3D Surface chart?  The documentation specifies the data json structure as follows: [ { "colorscale": "Viridis", "z": [ [ 3, 5, 7, 9 ], [ 21, 13, 8, 5 ] ], "type": "surface" } ] But how do I convert my x, y, z list into this format?  I see with python people using numpy, but how do I achieve this in MendiX? I was able to do the 2d scatterplot, but the 3d surface data is [3, 5, 7, 9] and I don’t get how I should convert to this using Mendix?
asked
1 answers
3

HI Stefan,
I have tried to use Default export mapping for your use case but it doesn't seem to work for your structure.
I have created custom logic to generate the Structure. Find the images and steps for your Reference.

I Have created an entity with three attributes that hold the three values

Steps :

  1. Retrieve the objects and take the head of the list to print the First value.
  2. Now create the Z Value Structure separately and the whole structure separately.
  3. Create a String variable and name it as JsonString and see the Image for reference how I  populated the values.  Example with reference to my Domain model :-  ' "z":[ [ '+$FirstValue/X+','+$FirstValue/Y+','+$FirstValue/Z+']'
  4. Remove the head object from the list to print the remaining values. Inside the loop add a change variable (JsonString) and construct the Remaining values. Example :  $JsonString+',[ '+$IteratorAxisValue/X+','+$IteratorAxisValue/Y+','+$IteratorAxisValue/Z+']'
  5. after the loop add a change variable(JsonString), to add the last bracket. Ex:  $JsonString+'],'
     
  6. Now create Another string variable named JsonValue. Now construct the whole Structure. Example: – 

'
[ {
  "colorscale": "Viridis",'
  +$JsonString+
 ' "type": "surface"
} ]'

 

You can Build similar logic /Structure based on your domain model. 
Hope this helps for your development. All the best!!

answered