Insights How To Add a Custom Line To the Widget
Add a Custom Line to a Widget
Custom widget scripts can only be created by Professional Services and therefore not supported by Maximizer Customer Service. |
The hardcoded line is only visible on the live dashboards and on widget exports as PNG. The line is not visible on the reports; such as scheduled email delivery or exporting to PDF. |
Custom scripts significantly increase dashboard loading time. |
Normally; you can only pull data from Maximizer to create your Insights widgets. It is possible to add a static reference number to KPIs or formulas; but not a whole data set.
This article explains how to create a custom script with a hardcoded data set represented by the red 'Target' line in the widget below.
This solution doesn't work for rolling dates or other categories that involve changing X-axis labels.
The new static line doesn't respond to any filters.
Step by step How-to
- Create a widget as usual without a target line. In the example above we have a stacked column chart with three Values or data set.
- Format X-axis. You will be referencing X-axis display values in the custom script. In this example; it's 'Dec'; 'Jan'. 'Feb' etc. This solution works only for values that don't change often and doesn't work for rolling dates or other categories that involve changing X-axis labels.
Any changes in the display values; later on; must be manually adjusted in the widget script.
- Now let's create a custom target line. Click on the 'Edit script' on the top right.
- Copy the Script below and make necessary changes to the X-axis labels (in violet) and target values (in pink).
Code |
widget.on('processresult'; function(widget;args){ |
In Insights this script looks like this:
- Click 'SAVE' when you are done.
- Now go back to the widget designer; click 'Apply' changes.
- Important: refresh your browser before giving it a try.
If you are interested in the accumulative targets; please read this article Insights - How to add hardcoded accumulative YTD budget line.