Compare commits
3 Commits
QB-377/err
...
qb-612/mis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eac9fd2a5f | ||
|
|
96f09f9323 | ||
|
|
58d0f542eb |
@@ -43,20 +43,42 @@ class DataTable extends React.PureComponent {
|
|||||||
return injectSeparatorsArray;
|
return injectSeparatorsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
let measurementDataRow = [],
|
const measurementDataRow = [];
|
||||||
index = 0;
|
let index = 0,
|
||||||
|
match;
|
||||||
dimension2.forEach((dim2) => {
|
dimension2.forEach((dim2) => {
|
||||||
measurements.forEach((measure) => {
|
measurements.forEach((measure, mesInd) => {
|
||||||
for (index = 0; index < injectSeparatorsArray.length; index++) {
|
for (index = 0; index < injectSeparatorsArray.length; index++) {
|
||||||
|
match = false;
|
||||||
if (injectSeparatorsArray[index].parents && dimension1[dimIndex].displayValue === injectSeparatorsArray[index].parents.dimension1.header) {
|
if (injectSeparatorsArray[index].parents && dimension1[dimIndex].displayValue === injectSeparatorsArray[index].parents.dimension1.header) {
|
||||||
if (dim2.displayValue === injectSeparatorsArray[index].parents.dimension2.header) {
|
if (dim2.displayValue === injectSeparatorsArray[index].parents.dimension2.header) {
|
||||||
if (measure.name === injectSeparatorsArray[index].parents.measurement.header) {
|
if (measure.name === injectSeparatorsArray[index].parents.measurement.header) {
|
||||||
measurementDataRow.push(injectSeparatorsArray[index]);
|
measurementDataRow.push(injectSeparatorsArray[index]);
|
||||||
|
match = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!match) {
|
||||||
|
measurementDataRow.push({
|
||||||
|
displayValue: '',
|
||||||
|
parents: {
|
||||||
|
dimension1: {
|
||||||
|
elementNumber: dimension1[dimIndex].elementNumber,
|
||||||
|
header: dimension1[dimIndex].displayValue
|
||||||
|
},
|
||||||
|
dimension2: {
|
||||||
|
elementNumber: dim2.elementNumber,
|
||||||
|
header: dim2.displayValue
|
||||||
|
},
|
||||||
|
measurement: {
|
||||||
|
header: measure.name,
|
||||||
|
index: mesInd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return measurementDataRow;
|
return measurementDataRow;
|
||||||
|
|||||||
@@ -127,30 +127,6 @@ function generateDataSet (component, dimensionsInformation, measurementsInformat
|
|||||||
dimension1 = distinctArray(dimension1);
|
dimension1 = distinctArray(dimension1);
|
||||||
dimension2 = distinctArray(dimension2);
|
dimension2 = distinctArray(dimension2);
|
||||||
|
|
||||||
// Make sure all rows are saturated, otherwise data risks being displayed in the wrong column
|
|
||||||
matrix = matrix.map((row, rowIndex) => {
|
|
||||||
if ((hasSecondDimension && row.length == (dimension2.length * measurements.length))
|
|
||||||
|| (!hasSecondDimension && row.length == measurements.length)) {
|
|
||||||
// Row is saturated
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Row is not saturated, so must add empty cells to fill the gaps
|
|
||||||
let newRow = [];
|
|
||||||
if (hasSecondDimension) {
|
|
||||||
// Got a second dimension, so need to add measurements for all values of the second dimension
|
|
||||||
let rowDataIndex = 0;
|
|
||||||
dimension2.forEach(dim => {
|
|
||||||
rowDataIndex = appendMissingCells(
|
|
||||||
row, newRow, rowDataIndex, measurements, rowIndex, dim, dimension1);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
appendMissingCells(row, newRow, 0, measurements, rowIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newRow;
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dimension1: dimension1,
|
dimension1: dimension1,
|
||||||
dimension2: dimension2,
|
dimension2: dimension2,
|
||||||
@@ -159,45 +135,6 @@ function generateDataSet (component, dimensionsInformation, measurementsInformat
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Appends the cells of the source row, as well as those missing, to the destination row, starting
|
|
||||||
* from the given source index. Returns the source index of the next source cell after this has
|
|
||||||
* completed. If there is a second dimension the dim2ElementNumber should be set to the current
|
|
||||||
* index of the dimension2 value being processed.
|
|
||||||
*/
|
|
||||||
function appendMissingCells (
|
|
||||||
sourceRow, destRow, sourceIndex, measurements, matrixIndex, dim2, dim1) {
|
|
||||||
|
|
||||||
let index = sourceIndex;
|
|
||||||
measurements.forEach((measurement, measureIndex) => {
|
|
||||||
if (index < sourceRow.length) {
|
|
||||||
// Source contains the expected cell
|
|
||||||
destRow.push(sourceRow[index]);
|
|
||||||
index++;
|
|
||||||
} else {
|
|
||||||
// Source doesn't contain the expected cell, so add empty
|
|
||||||
destRow.push({
|
|
||||||
displayValue: '',
|
|
||||||
parents: {
|
|
||||||
dimension1: {
|
|
||||||
elementNumber: dim1[matrixIndex].elementNumber,
|
|
||||||
header: dim1[matrixIndex].displayValue
|
|
||||||
},
|
|
||||||
dimension2: {
|
|
||||||
elementNumber: dim2.elementNumber,
|
|
||||||
header: dim2.displayValue
|
|
||||||
},
|
|
||||||
measurement: {
|
|
||||||
header: measurement.name,
|
|
||||||
index: measureIndex
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeTransformed ({ component, dataCube, designList, layout }) {
|
function initializeTransformed ({ component, dataCube, designList, layout }) {
|
||||||
const dimensionsInformation = component.backendApi.getDimensionInfos();
|
const dimensionsInformation = component.backendApi.getDimensionInfos();
|
||||||
const measurementsInformation = component.backendApi.getMeasureInfos();
|
const measurementsInformation = component.backendApi.getMeasureInfos();
|
||||||
|
|||||||
Reference in New Issue
Block a user