Just though I would respond to this post with updated information. I now have this treemap working and updating from a series of tm1-ui-subnm statements.
This is the original treemap that I used.
https://www.linkedin.com/pulse/custom-treemap-directive-poshak-maheshwari
The new directive has no exposed functions so you can’t rebuild the data with the controller and then refresh the treemap. What I did find was that the new directive had a watcher on the treemap data. I had to modify the watcher but, then I was able to issue the required tm1Ui.cubeExecuteMDX statement and rebuild the data. The tree would then automatically refresh.
Its a long process to explain it all here, so I wont go into all the code but here is a quick overview of the process.
When the page first loads an MDX statement is build based on the selections. This returns an object that contains all the data and dimensions. see below
var mdx1 = 'SELECT { [scenario].[actual],[scenario].[budget]} on 0,';
mdx1 = mdx1 + '{([account_tb].[canvas-mine cash cost accounts])} on 1 ';
mdx1 = mdx1 + 'FROM [trial_balance]';
mdx1 = mdx1 + 'where ([year].['+$scope.selections.finYear+'],[month].['+filterMonth+'],[company].['+$scope.selections.company+'],[lob].[total lob],';
mdx1 = mdx1 + '[measure_tb].[$],[value].[total_value],[identifier].[total identifier],[activity].[total activity],[location].[total location])';
$tm1Ui.cubeExecuteMdx('Wesfarmers_prod', mdx1).then(function(returnedData){
I then issue a $tm1Ui.dimensionElements to get the tree hierarchy. See below
$tm1Ui.dimensionElements('Wesfarmers_prod', 'account_tb', '' , 'Canvas-mine cash cost accounts', '', '', '',true,false).then(function(dimData){
I then use JavaScript to loop through the dimension data and then the returned MDX data to populate a new chart data object. This allow me to build the data with only 2 TM1 calls. The grunt is done in JavaScript and takes less than a second, including the TM1 calls.
Once the data is build I assign it to the treemap data object and the tree map updates.
Image below of the Treemap now working in Canvas.
Brian