@plim OK got the NVD3 chart to work. I am positing the final code below. I am ending up using 3 tm1-ui-subnm as filters. I have watchers set on this drop downs that then run an MDX statement and rebuild the data object.
All works great. Going to look at refining the chart next.
<div ng-controller="TPLSH01_VolumesCtrl">
<h4>
<span style="float: left; width: 50px; ">
<i ng-if="$root.isLoading" class="fa fa-cog fa-spin" ></i>
<!--<i ng-if="!$root.isLoading" class="fa fa-file-text-o"></i>-->
</span> {{excavator}} Volumes and Unit Rate for {{Finyear}}
</h4>
<div class="row">
<div class="col-md-4">
<tm1-ui-subnm tm1-instance="MinePhysicals"
tm1-dimension="Equipment"
tm1-subset="Excavators_Thiess_inc_shovel"
tm1-default-element="TPL EX61"
ng-model="excavator" >
</tm1-ui-subnm>
</div>
<div class="col-md-4">
<tm1-ui-subnm tm1-instance="MinePhysicals"
tm1-dimension="Date"
tm1-subset="Financial Years"
tm1-default-element="FY17"
ng-model="Finyear" >
</tm1-ui-subnm>
</div>
<div class="col-md-4">
<tm1-ui-subnm tm1-instance="MinePhysicals"
tm1-dimension="Material"
tm1-subset="Summarised"
tm1-default-element="All Material"
ng-model="material" >
</tm1-ui-subnm>
</div>
</div>
<nvd3 options="options" data="data"></nvd3>
</div>
JS Controller
app.controller('TPLSH01_VolumesCtrl', ['$scope','$log', '$tm1Ui', function($scope,$log,$tm1Ui) {
$log.info('TPLSH01_VolumesCtrl is Ready!');
//define variables
$scope.excavator = 'TPL EX61';
$scope.Finyear = 'FY17';
$scope.material = 'All Material';
$scope.options = {
chart: {
type: 'linePlusBarChart',
height: 500,
margin: {
top: 30,
right: 75,
bottom: 50,
left: 75
},
bars: {
forceY: [0]
},
bars2: {
forceY: [0]
},
color: ['#2ca02c', 'darkred'],
x: function(d,i) { return i },
xAxis: {
axisLabel: 'Period',
tickFormat: function(d) {
var dx = $scope.data[0].values[d] && $scope.data[0].values[d].x || 0;
//if (dx > 0) {
//return d3.time.format('%x')(new Date(dx))
return dx
//}
return null;
}
},
x2Axis: {
tickFormat: function(d) {
var dx = $scope.data[0].values[d] && $scope.data[0].values[d].x || 0;
//return d3.time.format('%b-%Y')(new Date(dx))
dx
},
showMaxMin: false
},
y1Axis: {
axisLabel: 'Volume BCM (Kt)',
tickFormat: function(d){
return d3.format('.3n')(d)/1000;
},
axisLabelDistance: 12
},
y2Axis: {
axisLabel: 'Unit Rate',
tickFormat: function(d) {
return '$' + d3.format(',.2f')(d)
}
},
y3Axis: {
tickFormat: function(d){
return d3.format(',f')(d);
}
},
y4Axis: {
tickFormat: function(d) {
return '$' + d3.format('.3n')(d)
}
}
}
};
$scope.data = [
{
"key" : "Volume" ,
"bar": true,
"values" : [ ]
},
{
"key" : "UnitRate" ,
"values" : [ ]
}
].map(function(series) {
series.values = series.values.map(function(d) { return {x: d[0], y: d[1] } });
return series;
});
$scope.buildMDX = function() {
var mdx1 = 'select {DESCENDANTS([Date].['+$scope.Finyear+'],2)} on 0, ';
mdx1 = mdx1 + '{[measure_costing_schedules].[volume_bcm], [measure_costing_schedules].[unit_rate]} on 1';
mdx1 = mdx1 + 'from [Costing_schedules] where ([contract_version].[All],[scenario].[actual],[version].[base],[measure_costing_schedules].[volume_bcm], [shift].[all],[area].[all areas],[pit].[all pits],';
mdx1 = mdx1 + '[equipment].['+$scope.excavator+'],[material].['+$scope.material+'])';
$log.info('MDX statement: '+mdx1);
$tm1Ui.cubeExecuteMdx('MinePhysicals', mdx1).then(function(data){
var nRows = data.Axes[1].Cardinality;
var nColumns = data.Axes[0].Cardinality;
//define the data array to populate
$scope.data
$log.log('rows: ' + nRows + ' Columns: ' + nColumns);
$log.log($scope.retData);
$scope.retData = data;
for (i = 0; i < nColumns; i++) {
//set the x axis for the volumes
//console.log(i)
$scope.data[0].values[i] = new Object;
$scope.data[0].values[i].x = $scope.retData.Axes[0].Tuples[i].Members[0].Attributes.Desc;
//set tthe x axis for the unit rate
$scope.data[1].values[i] = new Object;
$scope.data[1].values[i].x = $scope.retData.Axes[0].Tuples[i].Members[0].Attributes.Desc;
//console.log($scope.data[0].values[i].x);
// set the volumes
$scope.data[0].values[i].y = $scope.retData.Cells[i].Value==null?'0':$scope.retData.Cells[i].Value;
//set the unit rate
$scope.data[1].values[i].y = $scope.retData.Cells[i+nColumns].Value==null?'0':$scope.retData.Cells[i+nColumns].Value;
};
})
}
// watchers
$scope.$watchGroup(['excavator','Finyear','material'], function(newValue, oldValue){
$scope.buildMDX();
});
}]); // end of app controller