Forum Discussion

turtleData123's avatar
turtleData123
Cloud Apps
04-26-2024

Errors Editing Widget Scripts (Functions Not Existing)

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

  • 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 

  • Hi turtleData123,

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

    Thank you.

    • turtleData123's avatar
      turtleData123
      Cloud Apps

      Sure, the function was a simple one:

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