<commit_before>//require takes over the whole page, thus we need to load main.js with require as well
require([
    "/static/main.js",
]);
require([
    '/static/src/lib/echarts.js',
    // '/static/src/data/summit_cleaned.json'
], function (echarts) {
    var chart = echarts.init(document.getElementById('main'), {renderer:'canvas'});

    // window.onresize = function () {
    //     chart.resize();
    // };

    chart.on('click', function (params) {
        console.log(params, params.data);
    });
    $.ajax({
        url: "/pgt_jsonbody?pgt_name="+pgtName,
        dataType: "json",
        type: 'get',
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            if (404 == XMLHttpRequest.status) {
            alert('Server cannot locate physical graph file ' + pgtName.toString())
            } else {
            alert('status:' + XMLHttpRequest.status + ', status text: ' + XMLHttpRequest.statusText);
            }
        },
        success: function(data){
            var graphData = {'nodeDataArray':[], 'linkDataArray':[]};
            var graphDataParts = {'nodeDataArray':[], 'linkDataArray':[]};
            var newElement = {};
            data.nodeDataArray.forEach(element => {
                newElement = {};
                if (!element.hasOwnProperty("isGroup")){
                    newElement.name = element.key.toString();
                    graphData.nodeDataArray.push(newElement);
                }
                else {
                    newElement.name = element.key.toString();
                    graphDataParts.nodeDataArray.push(newElement);                  
                }
            });

            data.linkDataArray.forEach(element => {
                newElement = {};
                newElement.source = element.from.toString();
                newElement.target = element.to.toString();
                newElement.value = 20;
                graphData.linkDataArray.push(newElement);
            });

            // don't show labels if there are too many nodes. (SETTING?)
            var show_labels = (graphData.nodeDataArray.length > 750) ? false:true;

            console.log(data.nodeDataArray.Category);
            console.log(data.linkDataArray);
            console.log(graphData.nodeDataArray);
            console.log(graphData.linkDataArray);
            chart.setOption({
                tooltip: {
                    trigger: 'item',
                    triggerOn: 'mousemove'
                },<commit_msg>changed labels and label positions<commit_after>//require takes over the whole page, thus we need to load main.js with require as well
require([
    "/static/main.js",
]);
require([
    '/static/src/lib/echarts.js',
    // '/static/src/data/summit_cleaned.json'
], function (echarts) {
    var chart = echarts.init(document.getElementById('main'), {renderer:'canvas'});

    // window.onresize = function () {
    //     chart.resize();
    // };

    chart.on('click', function (params) {
        console.log(params, params.data);
    });
    $.ajax({
        url: "/pgt_jsonbody?pgt_name="+pgtName,
        dataType: "json",
        type: 'get',
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            if (404 == XMLHttpRequest.status) {
            alert('Server cannot locate physical graph file ' + pgtName.toString())
            } else {
            alert('status:' + XMLHttpRequest.status + ', status text: ' + XMLHttpRequest.statusText);
            }
        },
        success: function(data){
            var graphData = {'nodeDataArray':[], 'linkDataArray':[]};
            var graphDataParts = {'nodeDataArray':[], 'linkDataArray':[]};
            var newElement = {};
            let keyIndex = new Map();
            var nodeCatgColors = {'Data':'blue', 'Component': 'red'}
            data.nodeDataArray.forEach(element => {
                newElement = {};
                if (!element.hasOwnProperty("isGroup")){
                    keyIndex.set(element.key, element.text + '-' + element.key.toString());
                    newElement.name = element.text + '-' + element.key.toString();
                    newElement.label = {
                        'rotate': 45,
                        'fontSize': 10,
                        'offset': [-10,0]
                    };
                    newElement.itemStyle = {};
                    newElement.itemStyle.color = nodeCatgColors[element.category];
                    graphData.nodeDataArray.push(newElement);
                }
                else {
                    newElement.name = element.key.toString();
                    graphDataParts.nodeDataArray.push(newElement);                  
                }
            });

            data.linkDataArray.forEach(element => {
                newElement = {};
                newElement.source = keyIndex.get(element.from);
                newElement.target = keyIndex.get(element.to);
                newElement.value = 20;
                graphData.linkDataArray.push(newElement);
            });

            // don't show labels if there are too many nodes. (SETTING?)
            var show_labels = (graphData.nodeDataArray.length > 750) ? false:true;

            console.log(data.nodeDataArray);
            console.log(data.linkDataArray);
            console.log(graphData.nodeDataArray);
            console.log(graphData.linkDataArray);
            console.log(keyIndex)
            chart.setOption({
                tooltip: {
                    trigger: 'item',
                    triggerOn: 'mousemove'
                },
{'fraction_non_alphanumeric': 0.1294243832677869, 'fraction_numerical': 0.0041115480872363245, 'mean_word_length': 1.6757532281205165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '972169', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1422, 'n_words': 268}