Light High Efficiency Graph Component
en

Qunee Developer Guide

Data Conversion

After the front end gets the data, firstly it has to be converted to data format supported by Javascript, so as to read data property, such as text data in JSON format. It can be analysed via JSON#parse(…). For the text in XML format, it can be converted to XML object via DOMParse#parseFromString

Conversion to JS object

Continue the above example. Analyze the text to JSON object

function onDataCollected(txt){
    var json = JSON.parse(txt);
    translateToQuneeElements(json);
}

Conversion to Qunee element

Images in Qunee graphic component have corresponding model objects, called Qunee element. User data has to firstly be converted to this element and then demonstrated in Qunee graphic component. Qunee elements have many types, support various presentation styles and expansion ways. Different data can be converted to different types of Qunee elements according to explicit intents. Set corresponding image styles. Special demastration effect can be realized by UI extension.

Convert JSON objects to Qunee elements, and add them to graphic vessel

function translateToQuneeElements(json, graph){
    var map = {};
    if(json.nodes){
        Q.forEach(json.nodes, function(data){
            var node = graph.createNode(data.name, data.x || 0, data.y || 0);
            node.set("data", data);
            map[data.id] = node;
        });
    }
    if(json.edges){
        Q.forEach(json.edges, function(data){
            var from = map[data.from];
            var to = map[data.to];
            if(!from || !to){
                return;
            }
            var edge = graph.createEdge(data.name, from, to);
            edge.set("data", data);
        }, graph);
    }
}