Skip to main content
1-Visitor
Jan 30, 2014 10:10 PM UTC
Question

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

14 replies

5-Regular Member
Jan 31, 2014 12:44 AM UTC

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



Translate
1-Visitor
Nov 11, 2015 1:46 PM UTC

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

Translate
1-Visitor
Nov 11, 2015 1:51 PM UTC

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.

Translate
1-Visitor
Apr 19, 2017 11:17 AM UTC

Can someone actually help me to use a property to put an upper limit on time series? Please guide me on how to use DeriveFields to use a parameter and how to further use it?

Translate
1-Visitor
Apr 19, 2017 12:11 PM UTC

If your Thing is "MyThing" and the property "UpperLimit" is the limit for the Time Series Chart, you can use the code below to add the column limit to your data before return to the chart:

var data = ...;

var params = {

  types: "NUMBER" /* STRING */,

  t: data /* INFOTABLE */,

  columns: "limit" /* STRING */,

  expressions: 'Things["MyThing"].UpperLimit' /* STRING */

};

var result = Resources["InfoTableFunctions"].DeriveFields(params);

Translate