<commit_before>//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Draws "square" and "circle" shapes using svg:rect
//------------------------------------------------------------------------------
d3plus.shape.area = function(vars,selection,enter,exit) {

  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // D3 area definition
  //----------------------------------------------------------------------------
  var area = d3.svg.area()
    .x(function(d) { return d.d3plus.x; })
    .y0(function(d) { return d.d3plus.y0; })
    .y1(function(d) { return d.d3plus.y; })
    .interpolate(vars.shape.interpolate.value)

  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // "paths" Enter
  //----------------------------------------------------------------------------
  enter.append("path").attr("class","d3plus_data")
    .attr("d",function(d){ return area(d.values) })
    .call(d3plus.shape.style,vars)

  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // "paths" Update
  //----------------------------------------------------------------------------
  selection.selectAll("path.d3plus_data")
    .data(function(d) {

      if (vars.labels.value) {

        var areas = [],
            obj = null,
            obj2 = null,
            label = {
              "w": 0,
              "h": 0,
              "x": 0,
              "y": 0
            }

        function check_area(area) {

          obj.y = d3.max([obj.y,area.y])
          obj.y0 = d3.min([obj.y0,area.y0])
          obj.x0 = area.x

          obj.h = (obj.y0 - obj.y)
          obj.w = (obj.x0 - obj.x)

          var toosmall = obj.h-(vars.style.labels.padding*2) < 10 || obj.w-(vars.style.labels.padding*2) < 10,
              aspect_old = label.w/label.h,
              size_old = label.w*label.h,
              aspect_new = obj.w/obj.h,
              size_new = obj.w*obj.h

          if ((!toosmall && size_old < size_new) || !label.w) {
            label = {
              "w": obj.w-(vars.style.labels.padding*2),
              "h": obj.h-(vars.style.labels.padding*2),
              "x": obj.x+(obj.w/2),
              "y": obj.y+(obj.h/2)
            }
          }
          if (obj.h < 10) {
            obj = d3plus.utils.copy(area)
          }

        }

        d.values.forEach(function(v,i){

          if (!obj) {
            obj = d3plus.utils.copy(v.d3plus)
          }
          else {
            var arr = d3plus.utils.buckets([0,1],vars.style.labels.segments+1)
            arr.shift()
            arr.pop()
            arr.forEach(function(n){

              var test = d3plus.utils.copy(v.d3plus),
                  last = d.values[i-1].d3plus

              test.x = last.x + (test.x-last.x) * n
              test.y = last.y + (test.y-last.y) * n
              test.y0 = last.y0 + (test.y0-last.y0) * n

              check_area(test)

            })
            check_area(d3plus.utils.copy(v.d3plus))
          }
        })

        if (label.w >= 10 && label.h >= 10) {
          d.d3plus_label = label
        }

      }

      return [d];
    })

  if (vars.timing) {
    selection.selectAll("path.d3plus_data")
      .transition().duration(vars.timing)
        .attr("d",function(d){ return area(d.values) })
        .call(d3plus.shape.style,vars)
  }
  else {
    selection.selectAll("path.d3plus_data")
      .attr("d",function(d){ return area(d.values) })
      .call(d3plus.shape.style,vars)
  }

  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // Define mouse event area
  //----------------------------------------------------------------------------
  var mouses = selection.selectAll("path.d3plus_mouse")
    .data(function(d) {return [d];})

  mouses.enter().append("path")
    .attr("class","d3plus_mouse")
    .attr("opacity",0)
    .attr("stroke",1)
    .attr("d",function(d){ return area(d.values) })

  mouses
    .data(function(d) {return [d];})
    .on(d3plus.evt.over,function(d){

      if (!vars.frozen) {

        var mouse = d3.event[vars.continuous_axis]
            positions = d3plus.utils.uniques(d.values,function(x){return x.d3plus[vars.continuous_axis]}),
            closest = d3plus.utils.closest(positions,mouse)

        d.data = d.values[positions.indexOf(closest)]
        d.d3plus = d.values[positions.indexOf(closest)].d3plus

      }

    })
    .on(d3plus.evt.move,function(d){

      if (!vars.frozen) {

        var mouse = d3.event.x,
            positions = d3plus.utils.uniques(d.values,function(x){return x.d3plus.x}),
            closest = d3plus.utils.closest(positions,mouse)

        d.data = d.values[positions.indexOf(closest)]
        d.d3plus = d.values[positions.indexOf(closest)].d3plus

      }

    })
    .on(d3plus.evt.out,function(d){

      if (!vars.frozen) {

        delete d.d3plus

      }

    })

  if (vars.timing) {
    mouses.transition().duration(vars.timing)
      .attr("d",function(d){ return area(d.values) })
  }
  else {
    mouses.attr("d",function(d){ return area(d.values) })
  }

}
<commit_msg>fixed area labels getting padding applied twice<commit_after>//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Draws "square" and "circle" shapes using svg:rect
//------------------------------------------------------------------------------
d3plus.shape.area = function(vars,selection,enter,exit) {

  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // D3 area definition
  //----------------------------------------------------------------------------
  var area = d3.svg.area()
    .x(function(d) { return d.d3plus.x; })
    .y0(function(d) { return d.d3plus.y0; })
    .y1(function(d) { return d.d3plus.y; })
    .interpolate(vars.shape.interpolate.value)

  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // "paths" Enter
  //----------------------------------------------------------------------------
  enter.append("path").attr("class","d3plus_data")
    .attr("d",function(d){ return area(d.values) })
    .call(d3plus.shape.style,vars)

  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // "paths" Update
  //----------------------------------------------------------------------------
  selection.selectAll("path.d3plus_data")
    .data(function(d) {

      if (vars.labels.value) {

        var areas = [],
            obj = null,
            obj2 = null,
            label = {
              "w": 0,
              "h": 0,
              "x": 0,
              "y": 0
            }

        function check_area(area) {

          obj.y = d3.max([obj.y,area.y])
          obj.y0 = d3.min([obj.y0,area.y0])
          obj.x0 = area.x

          obj.h = (obj.y0 - obj.y)
          obj.w = (obj.x0 - obj.x)

          var toosmall = obj.h-(vars.style.labels.padding*2) < 15 || obj.w-(vars.style.labels.padding*2) < 20,
              aspect_old = label.w/label.h,
              size_old = label.w*label.h,
              aspect_new = obj.w/obj.h,
              size_new = obj.w*obj.h

          if ((!toosmall && size_old < size_new) || !label.w) {
            label = {
              "w": obj.w,
              "h": obj.h,
              "x": obj.x+(obj.w/2),
              "y": obj.y+(obj.h/2)
            }
          }
          if (obj.h < 10) {
            obj = d3plus.utils.copy(area)
          }

        }

        d.values.forEach(function(v,i){

          if (!obj) {
            obj = d3plus.utils.copy(v.d3plus)
          }
          else {
            var arr = d3plus.utils.buckets([0,1],vars.style.labels.segments+1)
            arr.shift()
            arr.pop()
            arr.forEach(function(n){

              var test = d3plus.utils.copy(v.d3plus),
                  last = d.values[i-1].d3plus

              test.x = last.x + (test.x-last.x) * n
              test.y = last.y + (test.y-last.y) * n
              test.y0 = last.y0 + (test.y0-last.y0) * n

              check_area(test)

            })
            check_area(d3plus.utils.copy(v.d3plus))
          }
        })

        if (label.w >= 10 && label.h >= 10) {
          d.d3plus_label = label
        }

      }

      return [d];
    })

  if (vars.timing) {
    selection.selectAll("path.d3plus_data")
      .transition().duration(vars.timing)
        .attr("d",function(d){ return area(d.values) })
        .call(d3plus.shape.style,vars)
  }
  else {
    selection.selectAll("path.d3plus_data")
      .attr("d",function(d){ return area(d.values) })
      .call(d3plus.shape.style,vars)
  }

  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // Define mouse event area
  //----------------------------------------------------------------------------
  var mouses = selection.selectAll("path.d3plus_mouse")
    .data(function(d) {return [d];})

  mouses.enter().append("path")
    .attr("class","d3plus_mouse")
    .attr("opacity",0)
    .attr("stroke",1)
    .attr("d",function(d){ return area(d.values) })

  mouses
    .data(function(d) {return [d];})
    .on(d3plus.evt.over,function(d){

      if (!vars.frozen) {

        var mouse = d3.event[vars.continuous_axis]
            positions = d3plus.utils.uniques(d.values,function(x){return x.d3plus[vars.continuous_axis]}),
            closest = d3plus.utils.closest(positions,mouse)

        d.data = d.values[positions.indexOf(closest)]
        d.d3plus = d.values[positions.indexOf(closest)].d3plus

      }

    })
    .on(d3plus.evt.move,function(d){

      if (!vars.frozen) {

        var mouse = d3.event.x,
            positions = d3plus.utils.uniques(d.values,function(x){return x.d3plus.x}),
            closest = d3plus.utils.closest(positions,mouse)

        d.data = d.values[positions.indexOf(closest)]
        d.d3plus = d.values[positions.indexOf(closest)].d3plus

      }

    })
    .on(d3plus.evt.out,function(d){

      if (!vars.frozen) {

        delete d.d3plus

      }

    })

  if (vars.timing) {
    mouses.transition().duration(vars.timing)
      .attr("d",function(d){ return area(d.values) })
  }
  else {
    mouses.attr("d",function(d){ return area(d.values) })
  }

}

{'fraction_non_alphanumeric': 0.29321108076472885, 'fraction_numerical': 0.015996878657822865, 'mean_word_length': 1.5884877556172683, 'pattern_counts': {'":': 16, '<': 11, '<?xml version=': 0, '>': 7, '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': '5130558', 'n_tokens_mistral': 3467, 'n_tokens_neox': 3342, 'n_words': 448}