private static createAlternateStructure()

in src/columnChart/baseColumnChart.ts [489:539]


    private static createAlternateStructure(dataPoint: MekkoDataPoints, descendingDirection: boolean = true): ICategoryValuesCollection[] {
        let series: MekkoChartSeries[] = dataPoint.series;
        let columns: ICategoryValuesCollection[] = [];
        let rowsCount: number = series.length;
        let colsCount: number = max(series.map(s => s.data.length));

        // define all cols
        series.some((value: MekkoChartSeries): boolean => {
            if (value.data.length === colsCount) {
                value.data.forEach(data => {
                    columns[data.categoryIndex] = [];
                });

                return true;
            }
            return false;
        });

        for (let col = 0; col < colsCount; col++) {
            for (let row = 0; row < rowsCount; row++) {
                columns[col] = columns[col] || [];
                if (series[row].data[col] === undefined) {
                    continue;
                }
                if (columns[series[row].data[col].categoryIndex].categoryValue === undefined) {
                    columns[series[row].data[col].categoryIndex].identity = <any>series[row].data[col].identity;
                    columns[series[row].data[col].categoryIndex].categoryValue = series[row].data[col].categoryValue;
                    columns[series[row].data[col].categoryIndex].color = series[row].data[col].color;
                }

                columns[series[row].data[col].categoryIndex][row] = series[row].data[col];
            }
        }

        // copy array with specific fields
        for (let col = 0; col < colsCount; col++) {
            let tmpObject = [];
            tmpObject["identity"] = columns[col].identity;
            tmpObject["categoryValue"] = columns[col].categoryValue;
            tmpObject["color"] = columns[col].color;
            columns[col] = columns[col].sort((a, b) => a[BaseColumnChart.ColumSortField] > b[BaseColumnChart.ColumSortField] ? 1 : -1);
            if (descendingDirection) {
                columns[col] = (columns[col]).reverse();
            }
            columns[col].identity = tmpObject["identity"];
            columns[col].categoryValue = tmpObject["categoryValue"];
            columns[col].color = tmpObject["color"];
        }

        return columns;
    }