Last active
October 22, 2016 10:08
-
-
Save erikwett/40e00983b7abcc5adb692d9ddcb42296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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