Below is an example of ALL the options available when defining a text widget. Some options are required, the options that are not required don't need to be defined unless something other than default is desired.
var ppf_widgets = {
example_text: { //Name of widget, these must be unique within the ppf_widget definitions
ele: [ 'txt1', 'txt2'], //REQUIRED
data: 'speeddata', //REQUIRED
type: 4, //REQUIRED
datadepend: ['voip','act'],
text: '<p>Custom text here</p>',
depend: [
['endofmonth', 'tuesday'],
['endofweek', 'wednesday']
]
}
}
Key | Value |
ele | Required. The element(s) defined here refer to HTML elements that should be present in the HTML page that pairs with the PPF. So, if the HTML element the table should appear in is
the ele definition would be
|
data | Required. Data refers to the data set name that should be used for the text. For example, if the following data set had been defined
The data value for the text would be...
|
datadepend |
If a widget is dependant on a certain data type then define a data dependency value. The format is an array. Common test types that can be defined are voip, act (which is Quality speed data), route, and capacity. |
type | Required. Text is type 4 and must be defined. When defined it should look like this
|
text | Text can be as little as one word or as much as multiple paragraphs. HTML markup is accepted, too. Below is an example of a basic text definition.
For more complex examples see: |
depend | Click here for dependency information. |
Using data in text widgets is a useful way to add more value to a report. Metrics in text widgets can be defined in two ways.
The first is $$testtype.testmetric$$. For example, $$speed.dspeed$$ would return the average result for Download Speed for the data set defined by the text widget.
text: '<p>The download speed result is $$speed.dspeed$$</p>'
The second is $$dataname.testtype.testmetric$$. For example, $$speeddata.speed.dspeed$$ would return the average result for Download Speed for the data set named speeddata. This allows text widgets to include metrics from various data sets.
text: '<p>The download speed result is $$speeddata.speed.dspeed$$</p>'
PPF variables are useful when the same text is going to appear in numerous section of the report. Assigning this text to a variable will avoid repetition and make changes quicker if required.
The format is $$repvars.varname$$.
The example below will search the defined report variables for the name companycopyright and print the value of this variable to text.
text: '<p>Copyright $$repvars.companycopyright$$</p>'
PPF expressions allow text to change based on metrics or any other report specific criteria. Expressions in techincal terms are JavaScript functions. Take for example the text specified below.
text: '<p>The overall result of this test was a $$exp.speedexp(||speed.dspeed||,||speed.uspeed||,"custom text")$$</p>'
The format is $$exp.expname(parameters to pass)$$.
In the example above, an expression named speedexp is being requested. This expression takes three parameters. The first two are metrics, the third is just custom text.
It's important to note that when defining metrics within an expression the syntax is ||, instead of $$, which is used elsewhere for metrics.
For a more detailed example see the page on PPF expressions.