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

Add limit lines to a Time Series Chart

Newbie

Add limit lines to a Time Series Chart

What is the best way to add limit lines to a Time Series Chart?  I have a property of my Thing that is an upper limit and I would like to display that on a Time Series chart along with the time varying data.

Thanks

Loren

Tags (1)
14 REPLIES 14

Add limit lines to a Time Series Chart

Hi Loren,

The easiest (and only) way to add limit lines to a Time Series Chart is to add an additional column to your data containing the limit value for each record. Depending on your current implementation, you may need to create a wrapper Service that adds the additional column or modify your existing Service. In both cases, you'll want to use

DeriveFields()

to add the additional column. The code snippet for

DeriveFields()

is available from the Snippets tab.


DeriveFields()

 takes an expression parameter, which you can use to perform a calculation or simply pass in a numeric constant.


Thanks,

Adam



Re: Add limit lines to a Time Series Chart

Hi Adam,

DeriveFields()​​'s expression parameter accept only a constant value, or a calculation based on existing fields of data. How can I use a variable in expression parameter, for example, a limit given by user ? I tried to give the name of the variable, and I get the error "Script evaluation error : ReferenceError: "myLimit" is not defined."

Thanks,

Quang-Dung

Re: Add limit lines to a Time Series Chart

Derive fields can take 'any expression' like .5*[FieldName] to create a value based on a column of the table.

or even Things[MyCalculator].LimitCalc({Parameter:[FieldName]}) to invoke a service.

Re: Add limit lines to a Time Series Chart

Ok, but it does not take an input parameter of a service which calls DeriveFields, doesn't it ?

Re: Add limit lines to a Time Series Chart

You could do the following.

Assign the Input parameter to a temporary Property.

Have a Service that retrieves that Property

Call that service in the Expression statement of DeriveFields.

Sorry the intent of DeriveFields just never thought of that scenario, most of the times one would assume an iteration through the Table and adding that Field value, but DeriveFields may prove to be more efficient.

Re: Add limit lines to a Time Series Chart

Yes, that's what I've thought about. Could Expression take directly the temporary property, for example expression: "Thing[MyThing].myProperty ?

Having some limit lines would be a nice feature for diffent types of chart, more convenient than adding the same constant to every row of property history, then load every single constant on the chart. I'd like to know if you had already an enhancement request about that.

Re: Add limit lines to a Time Series Chart

Ah good thought, never tried! Shouldn't be hard to try and confirm.

Re: Add limit lines to a Time Series Chart

It works.

Re: Add limit lines to a Time Series Chart

Yes, but the same problem, the name of myThing must be returned by another service. How could I do this without using "me.name" ?

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________