[SOLVED] Trouble Using a Data Resource as a Data Source for UI Builder Visualization.

fredrikange
Tera Contributor

Hi! 

I'm having a hard time figure out how to use a Data resource as a Data source for Data visualization component in UI builder

To simplify my testing i made a Transform data resource that just returns a hard-coded object.

demo_broker:

script:

 

function transform(input) {
    var var_input = input;
    var output = [{
            "metadata": {
                "dataSourceLabel": "Incident",
                "dataSourceType": "table",
                "eventData": {
                    "table": "incident"
                }
            },
            "data": [{
                "value": "67"
            }]
        },
        {
            "metadata": {
                "dataSourceLabel": "Incident",
                "dataSourceType": "table",
                "eventData": {
                    "table": "incident"
                },
                "groupBy": [{
                        "id": "incident_state",
                        "label": "Incident state"
                    },
                    {
                        "id": "priority",
                        "label": "Priority"
                    }
                ]
            },
            "data": [{
                    "incident_state": "In Progress",
                    "priority": "1 - Critical",
                    "value": "11"
                },
                {
                    "incident_state": "Closed",
                    "priority": "1 - Critical",
                    "value": "10"
                },
                {
                    "incident_state": "Closed",
                    "priority": "5 - Planning",
                    "value": "9"
                },
                {
                    "incident_state": "New",
                    "priority": "5 - Planning",
                    "value": "6"
                },
                {
                    "incident_state": "Closed",
                    "priority": "3 - Moderate",
                    "value": "5"
                },
                {
                    "incident_state": "In Progress",
                    "priority": "2 - High",
                    "value": "4"
                },
                {
                    "incident_state": "On Hold",
                    "priority": "1 - Critical",
                    "value": "4"
                },
                {
                    "incident_state": "New",
                    "priority": "3 - Moderate",
                    "value": "3"
                },
                {
                    "incident_state": "In Progress",
                    "priority": "3 - Moderate",
                    "value": "3"
                },
                {
                    "incident_state": "New",
                    "priority": "1 - Critical",
                    "value": "2"
                },
                {
                    "incident_state": "New",
                    "priority": "4 - Low",
                    "value": "2"
                },
                {
                    "incident_state": "In Progress",
                    "priority": "5 - Planning",
                    "value": "2"
                },
                {
                    "incident_state": "Closed",
                    "priority": "4 - Low",
                    "value": "2"
                },
                {
                    "incident_state": "On Hold",
                    "priority": "3 - Moderate",
                    "value": "1"
                },
                {
                    "incident_state": "On Hold",
                    "priority": "4 - Low",
                    "value": "1"
                },
                {
                    "incident_state": "On Hold",
                    "priority": "5 - Planning",
                    "value": "1"
                },
                {
                    "incident_state": "Resolved",
                    "priority": "5 - Planning",
                    "value": "1"
                }
            ]
        }
    ];

    return output;
}

 

 

Output:

fredrikange_0-1720178217399.png

 

How i set up the data source for my component:

fredrikange_1-1720178217421.png

 

There is no visualization:

fredrikange_2-1720178217422.png

 

 

However, if i copy and paste the data into the Use static input field the visualization works as shown below:

fredrikange_3-1720178217423.png

 

 

fredrikange_4-1720178217424.png

 


What are my options here? How can I get the data resource to work directly for visualization? Any help would be appreciated!

1 REPLY 1

fredrikange
Tera Contributor

Issue was that i had to tick define data manually, then while hovering over the input box select the bind data. Should look something like this:

fredrikange_0-1721368443212.png