I have a multiBarHorizontal chart with a single ng-repeat in the dbr (i.e. one series). I want to use a color scheme but the chart is taking on the first color in the array, I’m guessing this is because there is just one series?
And on a similar but separate issue, how can I get a chart to use a single colour in an ng-repeat?
E.g. we have mini charts on an ng-repeat, and in the list is an attribute holding the colour. However, when we put the following (or any combination thereof) the color scheme is not picked up:
Regarding the tm1-color-scheme, in a way that is because it expecting an array object, and not a String.
One of the things that you can try to do though is to re-initialize the directive and pass it with the correct color array on initialization. Below is an example.
The parameter you pass into that will now look like:
And that property is not being watched by the directive. So one way you can go about it is via ng-if and some function that will set the value on/off when updated:
Where on the controller side, you have a function that you will call, whenever you wanted to change the color:
$scope.onColorUpdate = function(){
$scope.showChart = false; // this is to remove the directive from DOM
$scope.selectedColorArray.length = 0;
$scope.selectedColorArray.push($scope.kpi.Colour);
$timeout(function(){
$scope.showChart = true; // this is to re-insert it back, with the new value of our color array
}, 500);
};
There should be a number of ways to go about it with the above as just to give an idea.
The tm1-ui-chart has the tm1-options-override attribute which should help to further customize the graph should you find the correct configuration to pass to it.
Regarding the tm1-color-scheme for a list attribute, I couldn’t get your code to work as posted, it kept returning a TypeError: Cannot read property 'Colour' of undefined error, but I can get the value in the variable to pass to the function using an ng-init:
However, it is then using just the last value it finds in the ng-repeat="kpi in lists.kpi" as there is just one variable name the colour is being pushed into, $scope.selectedColorArray, therefore it just overwrites with each new value.
There are five items in the ng-repeat and I need some way to turn each kpi.Colour into its own unique array.
The onColorUpdate() should be called when you want to change the color and not on the ng-init as that will just run once. Having something like ng-click for example, should help trigger the color change.