Forum Discussion

5 Replies

Replies have been turned off for this discussion
  • Hi Juandres ,

    If you have 1 dimension in X-axis, 1 dimension in Break by and 2 measures as in the below screenshot, try the below approach. You may need to adjust the script if you have different number of items under each panels.

    Use below widget script:

     

    
    widget.on('processresult', function(w, args) {
    
    	const seriesObj = args.result.series;
    
    	const seriesLength = seriesObj.length
    
    	for(i=0; i< seriesLength; i++) {
    
    		seriesObj.push({
    
    			name: seriesObj[i].name + '(2)',
    			color: seriesObj[i].color,
    			yAxis: 0,
    			mask: seriesObj[i].mask,
    			type: "line",
    			sortData: seriesObj[i].name,
    			
    			data: args.rawResult.values
    				.filter(item => item[1].text === seriesObj[i].name)
    				.map((value, index) => ({
    
    					color:  seriesObj[i].color,
    					y: value[3].data,
    					selectionData: { 0: value[0].text },
    					queryResultIndex: seriesObj[i].data[index].queryResultIndex
    
    				})
    			)
    
    		})
    
    	}
    
    })
    
    
    widget.on("beforequery", function (se, ev) {
    	$.each(ev.widget.metadata.panels[1].items, function(index, value){
    		if(value.disabled == true)
    		{
    			var newJaql = {
    				jaql  : JSON.parse(JSON.stringify(value.jaql))
    			}
    			ev.query.metadata.push(newJaql)
    			lastIndex = ev.query.metadata.length - 1
    			ev.query.metadata[lastIndex].disabled = false	
    		}
    	})
    })
    

     

    Result:

     

    Here it will create additional items in the legend. You can replace '(2)' in the script to a better text that allow you to distinguish between 2 measures.

     

    If you replace the type 'line' with 'column' in the script, you will get the widget as below:

     

     

    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, Thank you so much! 

    Trying the script now and it just gives me a blank Graph? Anything I could be doing wrong 

     

     

  • Hello Juandres ,

    I wanted to follow up to see if the solution offered by Benji_PaldiTeam worked for you

    If so, please click the 'Accept as Solution' button so that other users with the same questions can find the answer faster. If not, please let us know so that we can continue to help.

    Thank you.