cancel
Showing results for 
Search instead for 
Did you mean: 

How to plot data bar in piviot table

b_bouri
8 - Cloud Apps
8 - Cloud Apps

I attempted to create a data bar representing a scale of 100, but the output is incorrect.

There the output: Screenshot from 2024-02-29 12-05-58.png

 

1 ACCEPTED SOLUTION

Benji_PaldiTeam
11 - Data Pipeline
11 - Data Pipeline

Hi @b_bouri ,

The problem arises because the data bar in the pivot is based on finding the lowest and highest numbers from the column, which is typically valid. However, in your case, the lowest number should be 0 and the highest number should be 100. This discrepancy is why the output is incorrect.

To resolve this issue, you can manually specify the lowest and highest numbers using the widget script provided below. Update the variable 'panelItemName' with the name of the panel item where the data bar is displayed:

widget.on('processresult', function(w, args){

	const panelItemName = 'Percent'
	const panelItemIndex = args.query.metadata.findIndex((item) => item.jaql.title === panelItemName)
	
	
	if(panelItemIndex >= 0) {
		args.result.dataBars[panelItemIndex] = ['0', '100']
	}

})

After updating the script, the data bar should display correctly.

Benji_PaldiTeam_0-1709534246226.png

 

Feel free to reach out if you have further questions, we're always happy to help 🙂
[email protected] 
Paldi Solutions, Number #1 Sisense Plugins Developer

 

View solution in original post

2 REPLIES 2

Benji_PaldiTeam
11 - Data Pipeline
11 - Data Pipeline

Hi @b_bouri ,

The problem arises because the data bar in the pivot is based on finding the lowest and highest numbers from the column, which is typically valid. However, in your case, the lowest number should be 0 and the highest number should be 100. This discrepancy is why the output is incorrect.

To resolve this issue, you can manually specify the lowest and highest numbers using the widget script provided below. Update the variable 'panelItemName' with the name of the panel item where the data bar is displayed:

widget.on('processresult', function(w, args){

	const panelItemName = 'Percent'
	const panelItemIndex = args.query.metadata.findIndex((item) => item.jaql.title === panelItemName)
	
	
	if(panelItemIndex >= 0) {
		args.result.dataBars[panelItemIndex] = ['0', '100']
	}

})

After updating the script, the data bar should display correctly.

Benji_PaldiTeam_0-1709534246226.png

 

Feel free to reach out if you have further questions, we're always happy to help 🙂
[email protected] 
Paldi Solutions, Number #1 Sisense Plugins Developer

 

Hi @Benji_PaldiTeam thanks for the information. My issue is resolved