<commit_before>(function(ns){

  ns.loadSettings = function(){
    ns.type_col = $("#menuColors select").val() || 'type';
    ns.type_size = $("#menuSize select").val() || 'size';
  };

  ns.updateSize = function(){
    ns.loadSettings();
    if (ns.sigma) sigma.plugins.animate(ns.sigma,
      { size: ns.type_size },
      { duration: 250 }
    );
  };

  ns.colors = {
    type: {
      Citoyen: "rgb(255,235,102)",
      Institution: "rgb(5,225,255)",
      "Organisation à but non lucratif": "rgb(137,255,107)",
      "Organisation à but lucratif": "rgb(255,36,55)"
    },
    proposition: {
      Article: "rgb(185,165,228)",
      Amendement: "rgb(45,238,186)"
    },
    community: {
      
    }
  };

  ns.updateColor = function(){
    ns.loadSettings();
    ns.drawLegend();
    if (ns.sigma) sigma.plugins.animate(ns.sigma,
      { color: 'color_' + ns.type_col },
      { duration: 250 }
    );
  };

  ns.legend = undefined;
  ns.drawLegend = function(){
    if (ns.legend) ns.legend.kill();
    var keys = Object.keys(ns.colors[ns.type_col]),
        n = keys.length,
        y = 0;
    $("#legendColors").css({
      'height': 35*n + "px",
      'bottom': 35*(5-n) + "px"
    });
    ns.legend = new sigma({
      container: 'legendColors',
      settings: {
        enableHovering: false,
        mouseEnabled: false,
        labelThreshold: 1
      }
    });
    keys.forEach(function(type){
      ns.legend.graph.addNode({
        id: type,
        label: " " + type.replace(/^(\S+)/, '$1s'),
        x: 0,
        y: y++,
        size: 1,
        color: ns.colors[ns.type_col][type]
      });
    });
    ns.legend.camera.ratio = 1.6 - 0.1*n;
    ns.legend.refresh();
  }

  ns.sigma = undefined;
  ns.loadGraph = function(filename){
    ns.contrGraph = (filename.indexOf("users") === -1);
    ns.loadSettings();
    console.log("Downloading data...");
    $.getJSON('data/'+filename).then(function(data){
      console.log("Building network...");
      if (ns.sigma) ns.sigma.kill();
      ns.sigma = new sigma({
        container: 'graph',
        settings: {
          labelThreshold: (ns.contrGraph ? 6 : 4),
          enableHovering: ns.contrGraph,
          singleHover: true,
          minNodeSize: (ns.contrGraph ? 3 : 1),
          maxNodeSize: (ns.contrGraph ? 8 : 10),
          edgeColor: "default",
          borderSize: 1,
          defaultEdgeColor: "#F8F8F8",
          maxEdgeSize: 0.05
        }
      });
      data["nodes"].forEach(function(n){
        var cat = n.attributes[ns.type_col] || n[ns.type_col];
        ns.sigma.graph.addNode({
          id: n.id,
          label: (ns.contrGraph ? n.attributes.authorName : n.label),
          popup: (ns.contrGraph ? n.label : (n.label || "Citoyen " + n.id)),
          contributions: n.attributes.total_contributions,
          votes: n.attributes.total_votes,
          pro: n.attributes.votes_pro,
          unsure: n.attributes.votes_unsure,
          against: n.attributes.votes_against,
          x: n.x*10,
          y: -n.y*10,
          size: n.attributes[ns.contrGraph ? 'votes_pro' : 'total_contributions'],
          color_type: ns.colors['type'][n.attributes.type],
          color_proposition: ns.colors['proposition'][n.attributes.proposition],
          color: ns.colors[ns.type_col][n.attributes[ns.type_col] || n[ns.type_col]]
        });
      });
      data["edges"].forEach(function(e){
        ns.sigma.graph.addEdge({
          "id": e.id,
          "source": e.source,
          "target": e.target<commit_msg>fine adjust size + labels<commit_after>(function(ns){

  ns.loadSettings = function(){
    ns.type_col = $("#menuColors select").val() || 'type';
    ns.type_size = $("#menuSize select").val() || 'size';
  };

  ns.updateSize = function(){
    ns.loadSettings();
    if (ns.sigma) sigma.plugins.animate(ns.sigma,
      { size: ns.type_size },
      { duration: 250 }
    );
  };

  ns.colors = {
    type: {
      Citoyen: "rgb(255,235,102)",
      Institution: "rgb(5,225,255)",
      "Organisation à but non lucratif": "rgb(137,255,107)",
      "Organisation à but lucratif": "rgb(255,36,55)"
    },
    proposition: {
      Article: "rgb(185,165,228)",
      Amendement: "rgb(45,238,186)"
    },
    community: {
      
    }
  };

  ns.updateColor = function(){
    ns.loadSettings();
    ns.drawLegend();
    if (ns.sigma) sigma.plugins.animate(ns.sigma,
      { color: 'color_' + ns.type_col },
      { duration: 250 }
    );
  };

  ns.legend = undefined;
  ns.drawLegend = function(){
    if (ns.legend) ns.legend.kill();
    var keys = Object.keys(ns.colors[ns.type_col]),
        n = keys.length,
        y = 0;
    $("#legendColors").css({
      'height': 35*n + "px",
      'bottom': 35*(5-n) + "px"
    });
    ns.legend = new sigma({
      container: 'legendColors',
      settings: {
        enableHovering: false,
        mouseEnabled: false,
        labelThreshold: 1
      }
    });
    keys.forEach(function(type){
      ns.legend.graph.addNode({
        id: type,
        label: " " + type.replace(/^(\S+)/, '$1s'),
        x: 0,
        y: y++,
        size: 1,
        color: ns.colors[ns.type_col][type]
      });
    });
    ns.legend.camera.ratio = 1.6 - 0.1*n;
    ns.legend.refresh();
  }

  ns.sigma = undefined;
  ns.loadGraph = function(filename){
    ns.contrGraph = (filename.indexOf("users") === -1);
    ns.loadSettings();
    console.log("Downloading data...");
    $.getJSON('data/'+filename).then(function(data){
      console.log("Building network...");
      if (ns.sigma) ns.sigma.kill();
      ns.sigma = new sigma({
        container: 'graph',
        settings: {
          labelThreshold: (ns.contrGraph ? 6 : 5),
          enableHovering: ns.contrGraph,
          singleHover: true,
          minNodeSize: (ns.contrGraph ? 2 : 1),
          maxNodeSize: 8,
          edgeColor: "default",
          borderSize: 1,
          defaultEdgeColor: "#F8F8F8",
          maxEdgeSize: 0.05
        }
      });
      data["nodes"].forEach(function(n){
        var cat = n.attributes[ns.type_col] || n[ns.type_col];
        ns.sigma.graph.addNode({
          id: n.id,
          label: (ns.contrGraph ? n.attributes.authorName : n.label),
          popup: (ns.contrGraph ? n.label : (n.label || "Citoyen " + n.id)),
          contributions: n.attributes.total_contributions,
          votes: n.attributes.total_votes,
          pro: n.attributes.votes_pro,
          unsure: n.attributes.votes_unsure,
          against: n.attributes.votes_against,
          x: n.x*10,
          y: -n.y*10,
          size: n.attributes[ns.contrGraph ? 'votes_pro' : 'total_contributions'],
          color_type: ns.colors['type'][n.attributes.type],
          color_proposition: ns.colors['proposition'][n.attributes.proposition],
          color: ns.colors[ns.type_col][n.attributes[ns.type_col] || n[ns.type_col]]
        });
      });
      data["edges"].forEach(function(e){
        ns.sigma.graph.addEdge({
          "id": e.id,
          "source": e.source,
          "target": e.target
{'fraction_non_alphanumeric': 0.17266391693926894, 'fraction_numerical': 0.024747546579433937, 'mean_word_length': 2.1647164716471647, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5857351', 'n_tokens_mistral': 2506, 'n_tokens_neox': 2356, 'n_words': 410}