JSFiddle - React, Tailwind, and code Playground

by rbangay

HTML

<div id='result'></div>

JavaScript

//var columns = [];
function kendoColumnVM() {
    this.field;
    this.title;
    this.columns = [];
}

var xCol = null;
var yCols = [];
var columns = [];
var tempData = {};
var data = [];

function setYColumns(obj) {
    if (obj != null ) {
        if (obj.Axis == 1) {
            var col = new kendoColumnVM();
            col.field = '["' + obj.GroupName.replace(/\s/g, "") + '"]';
            col.title = obj.GroupName;
            col.columns = null;
            yCols.push(col);
            var objY = {
                title: col.title,
                field: obj.GroupName.replace(/\s/g, ""),
                grpType: obj.GrpType,
                grpValues: obj.GrpSetValues,
                child: null
            };
        }
    
        if (obj.ChildDelineations.length > 0) {
            setYColumns(obj.ChildDelineations[0]);
        }
    }
}

function setLeafColumns(obj, name, column) {
    $.each(obj, function (i, v) {
        var dispName = (v.ColumnName == null) ? v.FieldName : v.ColumnName;
        var col = new kendoColumnVM();
        col.field = '["' + (name + ":" + dispName).replace(/\s/g, "") + '"]';
        col.title = dispName;
        col.columns = null;
        column.columns.push(col);
    });
    
    if (obj == null || obj.length <= 0) {
        if (column != null)
            column.columns = null;
    }
}

function setXColumns(obj, dispObjs, level, name, column) {
    if (obj != null) {
        if (obj.Axis == 0) {
            level++;
            if (xCol == null) {
                xCol = new kendoColumnVM();
                xCol.title = obj.GroupName;
                column = xCol;
            }
    
            if (name == null) {
                name = obj.GroupName;
            }
    
            var limit = (obj.GrpType == 0) ? obj.Values.length : obj.GrpSetValues.length;
            var i = 0;
            for(i = 0; i < limit; i++) {
                var title = (obj.GrpType == 0) ? obj.Values[i] : obj.GrpSetValues[i].Name;
        ...