mirzay
08-23-2022Cloud Apps
Pie Chart, select 1 particular slice and rest are "Others"
Is there a way to select 1 particular slice of a pie chart and move the rest to "Others". By choosing the Select 1 slice option, it picks up the highest value and moves the rest to others. I want to be able to pick another category of the slice.
Hi mirzay ,
Try this:
Set number of slices as 1 and apply below widget script:
widget.on('processresult', function(se, ev) { itemName = 'Unknown' //set category name here if(ev.result.series[0].data.length == 2 && ev.result.series[0].data[0].name != itemName) { maskFn = ev.result.series[0].data[0].mask //get object of itemName itemIndex = ev.result.series[0].data[1].content.map(el => el.name).indexOf(itemName) itemObject = ev.result.series[0].data[1].content[itemIndex] currentitemObject = ev.result.series[0].data[0] //replace first data object with itemName object ev.result.series[0].data[0] = JSON.parse(JSON.stringify(itemObject)) ev.result.series[0].data[0].mask = maskFn //replace itemName object in 'Others' section with default item ev.result.series[0].data[1].content.splice(itemIndex, 1, currentitemObject) sum = 0 $.each(ev.result.series[0].data[1].content, function(index, value){ sum = sum + value.y value.x = index }) //for displaying categories when click on 'Others' slice ev.result.drilldown.series[0].data = ev.result.series[0].data[1].content ev.result.series[0].data[1].y = sum ev.result.series[0].data[1].mathSum = sum } })
-Hari