cancel
Showing results for 
Search instead for 
Did you mean: 

Widget script for specific condition in Column chart

Lisha
8 - Cloud Apps
8 - Cloud Apps

Below is a script that I had added for an indicator widget. If the secondary measure gives a result greater than 1, the widget will show NA.

 

widget.on('render', function (se, ev) {
if(se.queryResult.secondary.data > 1)
{
   se.queryResult.value.text = "N/A";
}

});

 

 

 I want to achieve the same thing but for a column chart. I already have 3 values for the column chart and I added the 4th value which will determine NA scenario. The 4th value should not appear as a bar (it should be hidden), we are only using it in the script. However, I am not able to figure out the script for the same. 

Lisha_0-1662120591625.png

 

1 ACCEPTED SOLUTION

harikm007
13 - Data Warehouse
13 - Data Warehouse

Enable 4th panel and try this script

widget.on('processresult', function(se, ev){

	if(ev.result.series[0].data[3].y > 1)
	{
		ev.result.series = []
		ev.rawResult.values = []
	}
	
	ev.result.xAxis.categories.length = 3
	ev.result.series.length = 3
	ev.result.series[0].data.length = 3
	
})

-Hari

View solution in original post

6 REPLIES 6

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @Lisha ,

Are you trying to display 'No Result' when the condition met? If yes, add widget filter using disabled value panel.

For example: if you need to display 'No Result' when value of disabled panel is 1, then  - Enable the panel, add filter for the value panel and disable the the value panel

harikm007_0-1662377721807.png

Please reply if you are looking for something different

-Hari

 

Hi Hari,

I need to display N/A or 'No Result' when value of disabled panel is >1. 

Also, I don't have the filter option in my column chart since I don't have anything in my categories field (you can check the snapshot I have shared). 

Thanks for your help

 

harikm007
13 - Data Warehouse
13 - Data Warehouse

I think it can be done in ways:

  • Add 'case statement' in Value 1, 2, 3 panels with condition 'NA measure <= 1'. For example:
    case when <Formula of NA Measure> <= 1 
    then <Formula of Value 1>
    else null
    end​

     

  •  Enable the 4th panel in your screenshot and add below script.
    widget.on('processresult', function(se, ev){
    
    	if(ev.result.series[0].data[3].y > 1)
    	{
    		ev.result.series[0].data[0].y = null
    		ev.result.series[0].data[1].y = null
    		ev.result.series[0].data[2].y = null
    		ev.result.series[0].data[3].y = null
    	}
    	
    	ev.result.xAxis.categories.length = 3
    	ev.result.series.length = 3
    	ev.result.series[0].data.length = 3
    })
    ​

-Hari

 

Hi,

The first way that you suggested is exactly what we are doing right now. However, that just displays a blank widget; which is not ideal for the users. Having it explicitly display N/A or 'No Result' is what I want to achieve (which is why I was hoping a widget script would be ideal)

As for the second way, it is also showing similar result as mentioned above.

Lisha_0-1662391373031.png

Thanks

 

harikm007
13 - Data Warehouse
13 - Data Warehouse

Enable 4th panel and try this script

widget.on('processresult', function(se, ev){

	if(ev.result.series[0].data[3].y > 1)
	{
		ev.result.series = []
		ev.rawResult.values = []
	}
	
	ev.result.xAxis.categories.length = 3
	ev.result.series.length = 3
	ev.result.series[0].data.length = 3
	
})

-Hari

Thank you so much, Hari! Much appreciated.