cancel
Showing results for 
Search instead for 
Did you mean: 

Line chart - Custom sort break by values

zohebakber
9 - Travel Pro
9 - Travel Pro

Hi Team,

Can anyone help me share the script to custom sort the break by values in the line chart.

I tried the same approach for the line chart as for pivot rows:
https://community.sisense.com/t5/knowledge/pivot2-table-row-custom-sort/ta-p/9096#:~:text=In%20a%20c...

However, this approach is not working.

Please share your thoughts.

Thanks

cc: @harikm007 @Ido_QBeeQ @Oleg 

2 REPLIES 2

zohebakber
9 - Travel Pro
9 - Travel Pro

Any suggestions here?

rapidbisupport
11 - Data Pipeline
11 - Data Pipeline

Hi @zohebakber ,

You can use the widget snippet below to change the order of the lines / legend in the break by:

 

let order = ['Greece', 'Alaska']

widget.on('processresult', (w, args) => {
  const unlistedItems = args.result.series.filter((i) => { return !order.includes(i.name) })
  order = [...order, ...unlistedItems]
  args.result.series.sort((a, b) => { 
	  return order.indexOf(b.name) - order.indexOf(a.name) 
  })
})

 

 What we are doing here is:

  • defining an order for the items we're interested in,
  • putting any items we didn't declare at the end of the order list and then,
  • ordering the lines based on our new order list.

Let me know if this works for you.

Thanks,

Daniel

RAPID BI

[email protected]

RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons