Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I have a small example to share about an important topic hypercube.
Some questions like :
Let's see how we can achieve all these in a simple way using "Backend API",
First make a property for adding dimension & measure OR data in to our Properties.
Note :
Step 1 : Define initial property :
initialProperties: {
qHyperCubeDef: {
qDimensions: [],
qMeasures: [],
qInitialDataFetch: [{
qWidth: 10,
qHeight: 1000
}]
}
},
Step 2 : Understand this properties:
definition: {
type: "items",
component: "accordion",
items: {
dimensions: {
uses: "dimensions",
min: 1
},
measures: {
uses: "measures",
min: 0
},
sorting: {
uses: "sorting"
},
settings: {
uses: "settings"
}
}
},Step 3 : Define dimension & measure
Step 4 : Add layout option :
paint: function($element)
Add layout to the function
paint: function($element, layout)
Console Log layout to get your extension Meta Data / Basic information
paint: function($element, layout) {
console.log(layout);
});Now layout will print out basic information about my extension.
Step 5 : Understand what we get in our layout :
Inside qHyperCube:
Inside qDataPages:
qArea:{qLeft: 0, qTop: 0, qWidth: 7, qHeight: 1000}
qMatrix:(1000) [Array(7), Array(7),…]
Inside qMatrix[0][0]:
Step 6 : Valuable variables
var self = this,
hypercube = layout.qHyperCube,
rowcount = hypercube.qDataPages[0].qMatrix.length,
columncount = hypercube.qDimensionInfo.length + hypercube.qMeasureInfo.length,
column = hypercube.qSize.qcx,
totalrows = hypercube.qSize.qcy,
pageheight = Math.floor(10000 / column),
numberOfPages = Math.ceil(totalrows / pageheight);
console.log(rowcount, layout);
Make a
function which will run based on numberOfPages from calculated variable
function fetchPage(numberOfPages, row) {
var add = 0;
for (var i = 1; i <= (numberOfPages); i++) { // Make request pages
var requestPage = [{
qTop: (row * i) + add,
qLeft: 0,
qWidth: columncount,
qHeight: Math.min(1000, totalrows - rowcount)
}];
if (i == 0) {
add = 1;
}
console.log(requestPage, row); // Pass request page in getData method in Backend API
self.backendApi.getData(requestPage).then(function(dataPages) { // update rowcount
rowcount += dataPages[0].qMatrix.length; // if (rowcount >= hypercube.qSize.qcy) {
// $element.find(".more").hide();
// }
});
}
}