Forum Discussion

mmalhame's avatar
mmalhame
Cloud Apps
09-19-2024
Solved

How to Use the SwitchDimension Add-On

I am trying to create a line chart for which users can select the 'Break by' dimension. The user should be able to select whether to break out the line chart by choosing 1 of 2 different text fields. Each text field has a handful of different values.  

I have enabled the 'SwitchDimension' add-on in the Admin settings. It is running on version 1.0.8.

I have had difficulty finding documentation on how to use this add-on. I think the technical details found here are the right instructions, but I'm not sure. When I follow those instructions, and use the below script in the widget, nothing happens. I'm not sure what I'm doing wrong, can someone help?

prism.registerSwitchDimension({
widget: widget,
maxItemsBeforeSubMenuIsCreated: 5, //optional
dimensions: [
{
panel: 'break by',
affectAllWidgets: true, //optional (true|false)
dims: [
{
"index": 0,
"dim": "[everly_workitemdays_view.applied_rate_class]",
"datatype": "text",
"title": "Applied Rate Class" //optional
//"widgetTitleTemplate": "" //optional
},
{
"index": 0,
"dim": "[everly_workitemdays_view.approved_rate_class]",
"datatype": "text",
"title": "Approved Rate Class" //optional
//"widgetTitleTemplate": "" //optional
}
]
}
]
});

  • Hi mmalhame ,

    I tried the same script in a line chart (just replacing the dimensions with those from my table), and it worked as expected. Here are a few things you might want to double-check:

    1. Field Names: Ensure that the dimension fields you’re using in your script are correct and match exactly with those in your dataset.

    2. Break By Dimension: Make sure you’ve added the “Break By” dimension in the line chart. 

    Also check if there is any error showing in the browser console.

    Here is the script I used:

    prism.registerSwitchDimension({
    	widget: widget,
    	maxItemsBeforeSubMenuIsCreated: 5, //optional
    	dimensions: [
    		{
    			panel: 'break by',
    			affectAllWidgets: true, //optional (true|false)
    			dims: [
    				{
    					"index": 0,
    					"dim": "[Commerce.Age Range]",
    					"datatype": "text",
    					"title": "Applied Rate Class" //optional
    					//"widgetTitleTemplate": "" //optional
    				},
    				{
    					"index": 0,
    					"dim": "[Commerce.Condition]",
    					"datatype": "text",
    					"title": "Approved Rate Class" //optional
    					//"widgetTitleTemplate": "" //optional
    				}
    			]
    		}
    	]
    });

    Result: 

    -Hari

     

2 Replies

  • harikm007's avatar
    harikm007
    Data Warehouse

    Hi mmalhame ,

    I tried the same script in a line chart (just replacing the dimensions with those from my table), and it worked as expected. Here are a few things you might want to double-check:

    1. Field Names: Ensure that the dimension fields you’re using in your script are correct and match exactly with those in your dataset.

    2. Break By Dimension: Make sure you’ve added the “Break By” dimension in the line chart. 

    Also check if there is any error showing in the browser console.

    Here is the script I used:

    prism.registerSwitchDimension({
    	widget: widget,
    	maxItemsBeforeSubMenuIsCreated: 5, //optional
    	dimensions: [
    		{
    			panel: 'break by',
    			affectAllWidgets: true, //optional (true|false)
    			dims: [
    				{
    					"index": 0,
    					"dim": "[Commerce.Age Range]",
    					"datatype": "text",
    					"title": "Applied Rate Class" //optional
    					//"widgetTitleTemplate": "" //optional
    				},
    				{
    					"index": 0,
    					"dim": "[Commerce.Condition]",
    					"datatype": "text",
    					"title": "Approved Rate Class" //optional
    					//"widgetTitleTemplate": "" //optional
    				}
    			]
    		}
    	]
    });

    Result: 

    -Hari

     

    • mmalhame's avatar
      mmalhame
      Cloud Apps

      Thank you, this worked!

      The mistake I made was that I didn't place either field in the 'Break By Dimension.'