import _ from 'lodash' ; see src returns { Array } export function getPieNames ( data ) { const names = [ ] ; _ . forEach ( data , function ( obj ) { const columns = obj . raw ? obj . raw . columns : undefined ; _ . forEach ( getNames ( obj , columns ) , function ( name ) { names . push ( name ) ; } ) ; } ) ; return _ . uniqBy ( names , 'label' ) ; } param data { Object } param columns { Object } returns { Array } function getNames ( data , columns ) { const slices = data . slices ; if ( slices . children ) { const namedObj = returnNames ( slices . children , 0 , columns ) ; return _ ( namedObj ) . sortBy ( function ( obj ) { return obj . index ; } ) . uniqBy ( function ( d ) { return d . label ; } ) . value ( ) ; } return [ ] ; } param array { Array } param index { Number } param columns { Object } returns { Array } function returnNames ( array , index , columns ) { const names = [ ] ; _ . forEach ( array , function ( obj ) { names . push ( { label : obj . name , values : [ obj . rawData ] , index , } ) ; if ( obj . children ) { const plusIndex = index + 1 ; _ . forEach ( returnNames ( obj . children , plusIndex , columns ) , function ( namedObj ) { names . push ( namedObj ) ; } ) ; } } ) ; return names ; }