Hi Experts,
I am developing a FIORI application using XML view and JS controller.
I am trying to set colorPalette based on the value of STATUS.
While Setting color i am getting error in console as Uncaught TypeError: Cannot read property 'getColorPalette' of null
Controller Code :
var filterFirstChart = new sap.ui.model.Filter("COUNTRY", function(oValue) {
return oValue !== null;
});
var oDatasetFirstChart = new sap.viz.ui5.data.FlattenedDataset({
dimensions: [{
name: "COUNTRY",
value: "{COUNTRY}"
}, {
name: "STATUS",
value: {
path: "STATUS",
formatter: function(oVal) {
var arr = oVizFrameFirstChart.getAggregation('plotArea').getColorPalette();
if (oVal === "On Time") {
if (arr.indexOf("#1bb7a0") === -1) {
arr.push("#1bb7a0");
}
}
if (oVal === "Delayed") {
if (arr.indexOf("#f17979") === -1) {
arr.push("#f17979");
}
}
oVizFrameFirstChart.getAggregation('plotArea').setColorPalette(arr);
return oVal;
}
}
}],
measures: [{
name: "COUNT",
value: "{CNT}"
}]
}).bindData("/d/results", null, null, [filterFirstChart]);
oVizFrameFirstChart.setVizProperties({
plotArea: {
showGap: true,
colorPalette: []
},
interaction: {
selectability: {
mode: "single"
}
},
title: {
visible: false,
text: "Global view"
},
legendGroup: {
layout: {
position: "bottom"
}
}
});
oVizFrameFirstChart.setDataset(oDatasetFirstChart);
Can any one help on this .
Thanks,
Sandeep