You are here
PPF Expressions
PPF expressions increase the flexibility of reports by allowing report metrics to be passed to custom JavaScript functions.
How is this done? Simply create a JavaScript function within your PPF, or your HTML page, and create the syntax within your repor to pass metrics to it.
Take the example JavaScript function below:
function testfunc(download,upload) {
console.log(download);
console.log(upload);
}
This function can be called within other widgets. For example, if the syntax below was included in a text widget the results for download and upload speed would be passed to the testfunc JavaScrit function. If that function returned a value that value would appear in the text.
$$exp.testfunc(||speed.dspeed||,||speed.uspeed||)$$
Below is a full example of how this would look if using an expression as part of a text widget.
var ppf_datasets = {
data: {
speeddata: { //name of the data set
plugins: ['speed'],
last: '1',
unit: 'hour',
by: 10
}
}
}
var ppf_widgets = {
example_text: {
ele: [ 'text_ele_id'],
data: 'speeddata',
type: 4,
text: 'The overall result of this test was $$exp.testfunc(||speed.dspeed||,||speed.uspeed||)$$',
thrdep: [[]],
caldep: [[]]
}
}
function testfunc(download,upload) {
console.log(download);
console.log(upload);
}