<commit_before>d3plus.apps.tree_map = {}
d3plus.apps.tree_map.data = "nested";
d3plus.apps.tree_map.requirements = ["size"];
d3plus.apps.tree_map.tooltip = "follow"
d3plus.apps.tree_map.shapes = ["square"];

d3plus.apps.tree_map.draw = function(vars) {

  var data = d3.layout.treemap()
    .round(false)
    .size([vars.app_width, vars.app_height])
    .children(function(d) { return d.children; })
    .padding(1)
    .sort(function(a, b) { return a.value - b.value; })
    .value(function(d) { return d3plus.variable.value(vars,d,vars.size.key); })
    .nodes({"name":"root", "children": vars.data.app})
    .filter(function(d) {
      return d.value > 0 && !d.children && d.area;
    })

  if (data.length) {

    var root = data[0]
    while (root.parent) {
      root = root.parent
    }

    data.forEach(function(d){
      d.d3plus.x = d.x+d.dx/2
      d.d3plus.y = d.y+d.dy/2
      d.d3plus.width = d.dx
      d.d3plus.height = d.dy
      d.d3plus.share = d.value/root.value
    })

  }

  return data
<commit_msg>a true fix for tree maps that have negative values<commit_after>d3plus.apps.tree_map = {}
d3plus.apps.tree_map.data = "nested";
d3plus.apps.tree_map.requirements = ["size"];
d3plus.apps.tree_map.tooltip = "follow"
d3plus.apps.tree_map.shapes = ["square"];

d3plus.apps.tree_map.draw = function(vars) {

  var data = d3.layout.treemap()
    .round(false)
    .size([vars.app_width, vars.app_height])
    .children(function(d) { return d.children; })
    .padding(1)
    .sort(function(a, b) { return a.value - b.value; })
    .value(function(d) {
      var val = d3plus.variable.value(vars,d,vars.size.key)
      return val > 0 ? val : 0;
    })
    .nodes({"name":"root", "children": vars.data.app})
    .filter(function(d) {
      return !d.children && d.area > 0;
    })

  if (data.length) {

    var root = data[0]
    while (root.parent) {
      root = root.parent
    }

    data.forEach(function(d){
      d.d3plus.x = d.x+d.dx/2
      d.d3plus.y = d.y+d.dy/2
      d.d3plus.width = d.dx
      d.d3plus.height = d.dy
      d.d3plus.share = d.value/root.value
    })

  }

  return data

{'fraction_non_alphanumeric': 0.17533081285444235, 'fraction_numerical': 0.017958412098298678, 'mean_word_length': 2.6563039723661483, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 6, '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': '194609', 'n_tokens_mistral': 851, 'n_tokens_neox': 834, 'n_words': 134}