Forum Discussion
JeremyFriedel
03-14-2025Sisense Employee
Hi Astroraf,
To clarify the template variables shared in the examples to show how those option will differ:
The {{val}} template will return all the values separated by "And".
The {{dim}} parameter differs based on whether it is placed in the global widgetTitleTemplate, or in the dim array.
This differences is:
For the global widgetTitleTemplate:
{{dim}} is replaced with all dimensions separated by "And"
For the dim array:
{{dim}} variable which returns the dimension's title
The complete example from this plugin's Readme file using widgetTemplateTitle may be helpful:
prism.registerSwitchDimension({
widget: widget,
widgetTitleTemplate: "{{val}} By {{dim}}", // When global widget title template is defined, the widget title will be dynamically calculated on widget load. {{dim}} is replaced with all dimensions separated by "And" and {{val}} is replaced with all the values separated by "And".
maxItemsBeforeSubMenuIsCreated: 5, // Optional property that defines the max number of dimensions in context menu (default value is 5). When the limit is exceeded, all dimensions will be placed within a sub menu.
dimensions: [
{
panel: 'categories', // Panel name for dimensions
dims: [
{
"index": 0, // Dimension index, make sure that in your panel you have a dimension with the same index.
"dim": "[country.Country]", // Dimension string (case sensitive)
"datatype": "text", // Datatype
"title": "country", // Caption for menu item
"widgetTitleTemplate": "Revenue By {{dim}}" // Optional property that specifies widget title according to changes. Template must contain {{dim}} variable which specifies the dimension's title (default value is title of dimension).
},
{
"index":0,
"dim":"[brand.Brand]",
"datatype": "text",
"title":"brand",
"widgetTitleTemplate": "Revenue By {{dim}}"
},
{
"index":0,
"dim":"[category.Category]",
"datatype": "text",
"title":"category",
"widgetTitleTemplate": "Revenue By {{dim}}"
}
]
}
]
});
Both the global and dim array widgetTitleTemplate are optional, and do not have to be included if not needed.