Skip to content

Instantly share code, notes, and snippets.

@erikwett
Last active October 22, 2016 10:08
Show Gist options
  • Save erikwett/40e00983b7abcc5adb692d9ddcb42296 to your computer and use it in GitHub Desktop.
Save erikwett/40e00983b7abcc5adb692d9ddcb42296 to your computer and use it in GitHub Desktop.
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