Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
function reOrder ( vis, sortOrder, col ) {
// set the new column first in the new sortorder array
var newOrder = [col];
//append all other columns from the current sort order
sortOrder.forEach( function ( val ) {
if ( val !== newOrder[0] ) {
newOrder.push( val );
}
} );
var patches = [{
//path to the sortOrder property
'qPath': '/qHyperCubeDef/qInterColumnSortOrder',
//we want to replace the sort order
'qOp': 'replace',
//make a string with an array in it
'qValue': '[' + newOrder.join( ',' ) + ']'
}];
//vis is the visualization model with the applyPatches method
vis.applyPatches( patches, true );
return newOrder;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment