Calculation from Previous Value
Download: previousValue.zip
Introduction
This plugin adds the ability for adding in calculations that reference previous values in the chart. For example, if you have a chart that shows non-continuous data (ie no data on weekends) then you may want your calculation to reference the last day with a value.
Steps
The following steps will walk through the process of implementing this plugin
STEP 1 - ADD THE PLUGIN
Download the attached .zip file, and extract it to the following path "[Sisense installation path]\PrismWeb\Plugins".
If you are using version 7.2 and higher unzip the contents into your C:\Program Files\Sisense\app\plugins\ folder.
STEP 2 - CREATE YOUR CHART
Create a line/area/column/bar chart that has some value as a series. Click on your series' settings menu and look for the Previous Value menu.
STEP 3 - Customize
There are a few functions built-in to the plugin (add, subtract, avg, & percent change), but you can add your own functions to the list. In the main.js file there is an options variable that has the list of available selections. They each follow the same format, with a label property and calculation function. Just add additional objects into this array that follow the same format and they will show up in the dropdown menu.
{
'label': 'Avg',
'calculation': function(point, index, series){
// Save a reference to the original value
point.yOriginal = point.y;
// Get the last point's value
var lastValue = $$get(series, (index-1) + '.yOriginal', 0);
// Add the current value to the previous value
point.y = (lastValue === 0) ? point.y : (lastValue + point.y) / 2;
return null;
}
NOTES
- This plugin is built to support line, area, column, and bar charts
- while this plugin supports exporting to image and pdf, CSV exports are not yet supported
Please sign in to leave a comment.
Comments
0 comments