cancel
Showing results for 
Search instead for 
Did you mean: 

Errors Editing Widget Scripts (Functions Not Existing)

turtleData123
9 - Travel Pro
9 - Travel Pro

Hey all,

I'm trying to edit a widget script and add script that will change the color of the column of the largest value for a column chart on Qalibrate, but when I edit the script and run it, most of the functions/methods apparently don't exist - for example, I can run simply var results = widget.queryResult(); within my widget function and I just get 'widget.queryResult() is not a function.' Obviously this is preventing me from implementing any solutions whatsoever and getting my script to run. Any help or advice?

Additionally, sisense is version L2023.11.0.471

Thanks

5 REPLIES 5

DRay
Community Team Member
Community Team Member

Hi @turtleData123,

Can you provide the full widget script you are using? That will help us figure out what is happening.

Thank you.

David Raynor (DRay)

Sure, the function was a simple one:

widget.on('processresult', function(e, v) {
    var results = widget.queryResult();
});

 

turtleData123
9 - Travel Pro
9 - Travel Pro

I was able to find/create a script that worked for what I was trying to do, I used the following code which worked:

widget.on('processresult', function(e, v) {
	var results = v.result.series[0];

	maxItems = Math.max.apply(Math, results.data.map(function(el) {
		return el.y;
	}));

	
	try {
		maxFilterItems = results.data.filter(el => el.y == maxItems);
		console.log(maxFilterItems);
		$(maxFilterItems).each(function(index, value) {
			value.color = 'Orange';
        });
		
	} catch (error) {
		console.error('error: ', error);
	};
	

});

 

This recolors the bar with the highest value on a Column Chart widget. I don't know why those other functions don't work, though, any comment would be great 

DRay
Community Team Member
Community Team Member

Hi @turtleData123,

Do those functions work on other Widgets?

David Raynor (DRay)

Good question - I'm trying it now - results are no, they do not