Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi there,
I connected and show the data from Thingworx successfully. However, the format of the data is not quite desirable.
For example, the data grabbed by Thingworx is '2230' and the data type is Word, but I want to show it in this way: '22.30 Hz'.
So, I am trying to write a script to perform the modification by using concat() and split() for manipulating the string.
The problem is, whenever I tried to modify the external data from Thingworx, the Vuforia View crashed as shown in figure below. Even I just assign the external data to a variable, the same issue will occur.
For example,
var y = $scope.app.mdl['myThing'].properties['myProperty'];
Is there any method that I can modify the data?
Solved! Go to Solution.
Are you using a filter for this? That's the best way to do it. If you look at the binding between the Thingworx data and the widget displaying it, you'll see a a green Plus that says "Add Filter". Click that, and add the code to transform the raw value into the desired format. For your example, you could use something like this:
return (parseInt(value) / 100) + " Hz"
Here, "value" represents the raw value coming from Thingworx, and the return expression gives the desired string format for the value.
Are you using a filter for this? That's the best way to do it. If you look at the binding between the Thingworx data and the widget displaying it, you'll see a a green Plus that says "Add Filter". Click that, and add the code to transform the raw value into the desired format. For your example, you could use something like this:
return (parseInt(value) / 100) + " Hz"
Here, "value" represents the raw value coming from Thingworx, and the return expression gives the desired string format for the value.
Thank you so much! It saves my day!
By the way, if I want to show different data by using only 1 3D label with the select widget in the 2D interface, would it be possible that I can set a if-condition to show different units in the filter?
For example, for the 3D label, I want to show RPM, output current, temperature by using the select widget, and all of these external data are in different units.
The way bindings work, I don't think it would be practical to put the switching logic into the filter. I think you'd be better off with 3 separate 3D labels, all in the same position, each bound to one of your target data values (with filters to control formatting, where needed), and then use the Select widget to set the selected 3D Label widget to visible and the others to hidden.