How to Have Break By Switchable Dimensions Update Title
I am trying to have the Break By Update the title of the Switchable Dimension rather than dimension.
My script goes as follows.
prism.registerSwitchDimension({
widget: widget,
widgetTitleTemplate: "{{val}} By {{dim}}", // Dynamically updates title with value and dimension
maxItemsBeforeSubMenuIsCreated: 5, // Keeps the menu clean if more dimensions are added
dimensions: [
{
panel: 'break by', // Ensure this matches the panel name in your widget
dims: [
{
"index": 0,
"dim": "[GMV_ORDERS_DASH_UNION.SUPPLIER]",
"datatype": "text",
"title": "Supplier",
"widgetTitleTemplate": "{{val}} By Supplier"
},
{
"index": 0,
"dim": "[GMV_ORDERS_DASH_UNION.MANUFACTURER]",
"datatype": "text",
"title": "Manufacturer",
"widgetTitleTemplate": "{{val}} By Manufacturer"
},
{
"index": 0,
"dim": "[GMV_ORDERS_DASH_UNION.CUSTOMER]",
"datatype": "text",
"title": "Customer",
"widgetTitleTemplate": "{{val}} By Customer"
}
]
}
]
});Rafael Ferreira
Posted 1 year ago·Last reply 1 year ago
6 comments
Jeremy Friedel
·1 year agoHi 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:
Both the global and dim array widgetTitleTemplate are optional, and do not have to be included if not needed.
Rafael Ferreira
OP1 year agoHi JeremyFriedel I am still unsure what you mean by this.
For me to have the dimension update the title of the widget does my formatting have to be:
Where each individual dimension that is changing also needs the WidgetTitleTemplate to have this coded as such:
I am just trying to understand the syntax of this solution.
Rafael Ferreira
OP1 year agoHi JeremyFriedel,
I am a bit confused about what needs to change in my code. Is it the widget title template that needs to change in each of the dims: []?
DRay
·1 year agoHello Astroraf,
I’m following up to see if the solution offered by JeremyFriedel worked for you.
If so, please click the 'Accept as Solution' button on their post. That way other users with the same questions can find the answer. If not, please let us know so that we can continue to help.
Thank you.
Jeremy Friedel
·1 year agoHi Astroraf,
If the only change needed is the title, and not the `dim` parameter, then the config can be setup very similar to the example shared, except the `dim` would be set the same for all options (and all other parameters) but the title would differ for the options, this would modify the title.