<commit_before>//d3.svg.axisSmart

export default function axisSmart() {

  return function d3_axis_smart(_super) {

    var VERTICAL = 'vertical axis';
    var HORIZONTAL = 'horizontal axis';
    var X = 'labels stack side by side';
    var Y = 'labels stack top to bottom';

    var OPTIMISTIC = 'optimistic approximation: labels have different lengths';
    var PESSIMISTIC = 'pessimistic approximation: all labels have the largest length';
    var DEFAULT_LOGBASE = 10;

    function onlyUnique(value, index, self) {
      return self.indexOf(value) === index;
    }

    function axis(g) {
      if(highlightValue != null) {
        axis.highlightValueRun(g);
        return;
      }

      // measure the width and height of one digit
      var widthSampleG = g.append("g").attr("class", "tick widthSampling");
      var widthSampleT = widthSampleG.append('text').text('0');

      options.cssMarginTop = widthSampleT.style("margin-top");
      options.cssMarginBottom = widthSampleT.style("margin-bottom");
      options.cssMarginLeft = widthSampleT.style("margin-left");
      options.cssMarginRight = widthSampleT.style("margin-right");
      options.widthOfOneDigit = widthSampleT[0][0].getBBox().width;
      options.heightOfOneDigit = widthSampleT[0][0].getBBox().height;
      widthSampleG.remove();


      // run label factory - it will store labels in tickValues property of axis
      axis.labelFactory(options);

      //if(axis.orient()=="bottom") console.log("ordered", axis.tickValues())
      // construct the view (d3 constructor is used)
      if(options.transitionDuration > 0) {
        _super(g.transition().duration(options.transitionDuration));
      } else {
       _super(g);
      }
      //if(axis.orient()=="bottom") console.log("received", g.selectAll("text").each(function(d){console.log(d)}))

      var orient = axis.orient() == "top" || axis.orient() == "bottom" ? HORIZONTAL : VERTICAL;
      var dimension = (orient == HORIZONTAL && axis.pivot() || orient == VERTICAL && !axis.pivot()) ? Y : X;

      g.selectAll('.vzb-axis-value')
        .data([null])
        .enter().append('g')
        .attr("class", 'vzb-axis-value')
        .classed("vzb-hidden", true)
        .append("text");

      // patch the label positioning after the view is generated
      g.selectAll("text")
        .each(function(d, i) {
          var view = d3.select(this);

          if(axis.pivot() == null) return;
          view.attr("transform", "rotate(" + (axis.pivot() ? -90 : 0) + ")");
          view.style("text-anchor", dimension == X ? "middle" : "end");

          view.attr("dx", dimension == X ? (orient == VERTICAL ? axis.tickPadding() + axis.tickSize() : 0) : 0);
          view.attr("dy", dimension == X ? (orient == VERTICAL ? -1:1.25) * (axis.tickPadding() + axis.tickSize()) : axis.tickSize());
        })
      
      if(axis.repositionLabels() != null){
          g.selectAll(".tick")
            .each(function(d, i) {
              var view = d3.select(this).select("text");
              var shift = axis.repositionLabels()[i] || {x: 0, y: 0};
              view.attr("dx", +view.attr("dx") + shift.x);
              view.attr("dy", +view.attr("dy") + shift.y);
            })
      }

      if(axis.tickValuesMinor() == null) axis.tickValuesMinor([]);
      // add minor ticks
      var minorTicks = g.selectAll(".tickMinor").data(tickValuesMinor);
      minorTicks.exit().remove();
      minorTicks.enter().append("line")
        .attr("class", "tickMinor");

      var tickLengthOut = axis.tickSizeMinor().outbound;
      var tickLengthIn = axis.tickSizeMinor().inbound;
      var scale = axis.scale();
      minorTicks
        .attr("y1", orient == HORIZONTAL ? (axis.orient() == "top" ? 1 : -1) * tickLengthIn : scale)<commit_msg>Axis tick values shifted when in presentation mode<commit_after>//d3.svg.axisSmart

export default function axisSmart() {

  return function d3_axis_smart(_super) {

    var VERTICAL = 'vertical axis';
    var HORIZONTAL = 'horizontal axis';
    var X = 'labels stack side by side';
    var Y = 'labels stack top to bottom';

    var OPTIMISTIC = 'optimistic approximation: labels have different lengths';
    var PESSIMISTIC = 'pessimistic approximation: all labels have the largest length';
    var DEFAULT_LOGBASE = 10;

    function onlyUnique(value, index, self) {
      return self.indexOf(value) === index;
    }

    function axis(g) {
      if(highlightValue != null) {
        axis.highlightValueRun(g);
        return;
      }

      // measure the width and height of one digit
      var widthSampleG = g.append("g").attr("class", "tick widthSampling");
      var widthSampleT = widthSampleG.append('text').text('0');

      options.cssMarginTop = widthSampleT.style("margin-top");
      options.cssMarginBottom = widthSampleT.style("margin-bottom");
      options.cssMarginLeft = widthSampleT.style("margin-left");
      options.cssMarginRight = widthSampleT.style("margin-right");
      options.widthOfOneDigit = widthSampleT[0][0].getBBox().width;
      options.heightOfOneDigit = widthSampleT[0][0].getBBox().height;
      widthSampleG.remove();


      // run label factory - it will store labels in tickValues property of axis
      axis.labelFactory(options);

      //if(axis.orient()=="bottom") console.log("ordered", axis.tickValues())
      // construct the view (d3 constructor is used)
      if(options.transitionDuration > 0) {
        _super(g.transition().duration(options.transitionDuration));
      } else {
       _super(g);
      }
      //if(axis.orient()=="bottom") console.log("received", g.selectAll("text").each(function(d){console.log(d)}))
      var orient = axis.orient() == "top" || axis.orient() == "bottom" ? HORIZONTAL : VERTICAL;
      var dimension = (orient == HORIZONTAL && axis.pivot() || orient == VERTICAL && !axis.pivot()) ? Y : X;
      var boxSize = g.select('.tick').select('text').node().getBBox();

      g.selectAll('.vzb-axis-value')
        .data([null])
        .enter().append('g')
        .attr("class", 'vzb-axis-value')
        .classed("vzb-hidden", true)
        .append("text")
        .attr("x", dimension == X ? 0 : (-axis.tickPadding() - axis.tickSize()))
        .attr("y", dimension == X ? (orient == VERTICAL ? 0 : boxSize.height/3) : 0);

      // patch the label positioning after the view is generated
      g.selectAll("text")
        .each(function(d, i) {
          var view = d3.select(this);

          if(axis.pivot() == null) return;
          view.attr("transform", "rotate(" + (axis.pivot() ? -90 : 0) + ")");
          view.style("text-anchor", dimension == X ? "middle" : "end");
          view.attr("dx", dimension == X ? (orient == VERTICAL ? axis.tickPadding() + axis.tickSize() : 0) : 0);
          view.attr("dy", dimension == X ? (orient == VERTICAL ? -0.35:0.5) * (boxSize.height) : boxSize.height/4);
        })
      
      if(axis.repositionLabels() != null){
          g.selectAll(".tick")
            .each(function(d, i) {
              var view = d3.select(this).select("text");
              var shift = axis.repositionLabels()[i] || {x: 0, y: 0};
              view.attr("x", +view.attr("x") + shift.x);
              view.attr("y", +view.attr("y") + shift.y);
            })
      }

      if(axis.tickValuesMinor() == null) axis.tickValuesMinor([]);
      // add minor ticks
      var minorTicks = g.selectAll(".tickMinor").data(tickValuesMinor);
      minorTicks.exit().remove();
      minorTicks.enter().append("line")
        .attr("class", "tickMinor");

      var tickLengthOut = axis.tickSizeMinor().outbound;
      var tickLengthIn = axis.tickSizeMinor().inbound;
      var scale = axis.scale();
      minorTicks
        .attr("y1", orient == HORIZONTAL ? (axis.orient() == "top" ? 1 : -1) * tickLengthIn : scale)
{'fraction_non_alphanumeric': 0.1654491862104319, 'fraction_numerical': 0.007689350249903883, 'mean_word_length': 2.741131351869607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1869558', 'n_tokens_mistral': 2446, 'n_tokens_neox': 2381, 'n_words': 520}