cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to get the data from the ide properties to the runtime when creating a widget (extension)?

efernandez1
1-Newbie

How to get the data from the ide properties to the runtime when creating a widget (extension)?

Hi all,

I am trying to create a widget that displays a doughnut chart by using an external library. I have been able to display this doughnut chart using static data but now I am having a problem in getting the data set at the mashup. Getting information from other widgets I declared the properties in the ide.js

And now I want to get the data from the ValueField as an array of numbers and the data from LabelFiedl as an array of words. To do that I know I have to use the updateProperty function

this.updateProperty = function (updatePropertyInfo) {}

From what I understand if for example I want to get the ValueField array of data I should do the following inside the updateProperty function:

this.updateProperty = function (updatePropertyInfo) {

  var widgetProperties = this.properties;

  var valueField = this.getProperty('ValueField');

  if (updatePropertyInfo.TargetProperty === "Data"){

  var dataRows = updatePropertyInfo.ActualDataRows;

         var outputArray = [];

             for (var i = 0; i < dataRows.length; i++) {

                 var valueValue =  dataRows[valueField];

                 outputArray.push({value:valueValue });

             }

             return outputArray;

  };

And then I want to use the outputArray on the this.afterRender function (as that is when the chart is drawn), but it is not working. Any idea on how to effectively do this? Thank you!

I am using Thingworx 3.1 and Chart.js as the imported library (by editing the metadata.xml).

0 REPLIES 0
Top Tags