<commit_before>import * as utils from 'base/utils';
import Class from 'base/class';

var MCSelectList = Class.extend({

  init: function(context) {
    this.context = context;

  },

  rebuild: function(data) {
    var _this = this.context;

    var listData = _this.mountainPointers
      .concat(_this.groupedPointers)
      .concat(_this.stackedPointers)
      .filter(function(f) {
        return _this.model.entities.isSelected(f);
      })
      .sort(function(a, b) {
        if(b.yMax && a.yMax) return b.yMax - a.yMax;
        return b.sortValue[0] - a.sortValue[0];
      });

    _this.selectList = _this.mountainLabelContainer.selectAll("g")
      .data(utils.unique(listData, function(d) {
        return d.KEY()
      }));

    _this.selectList.exit().remove();
    _this.selectList.enter().append("g")
      .attr("class", "vzb-mc-label")
      .each(function(d, i) {
        d3.select(this).append("circle");
        d3.select(this).append("text").attr("class", "vzb-mc-label-shadow");
        d3.select(this).append("text");
      })
      .on("mousemove", function(d, i) {
        _this.model.entities.highlightEntity(d);
      })
      .on("mouseout", function(d, i) {
        _this.model.entities.clearHighlighted();
      })
      .on("click", function(d, i) {
        _this.model.entities.clearHighlighted();
        _this.model.entities.selectEntity(d);
      });
  },

  redraw: function() {
    var _this = this.context;
    if(!_this.selectList || !_this.someSelected) return;

    var sample = _this.mountainLabelContainer.append("g").attr("class", "vzb-mc-label").append("text").text("0");
    var fontHeight = sample[0][0].getBBox().height;
    d3.select(sample[0][0].parentNode).remove();
    var formatter = _this.model.marker.axis_y.tickFormatter;

    var titleHeight = _this.yTitleEl.select("text").node().getBBox().height || 0;

    var maxFontHeight = (_this.height - titleHeight * 3) / (_this.selectList.data().length + 2);
    if(fontHeight > maxFontHeight) fontHeight = maxFontHeight;

    _this.selectList
      .attr("transform", function(d, i) {
        return "translate(0," + (fontHeight * i + titleHeight * 3) + ")";
      })
      .each(function(d, i) {

        var view = d3.select(this);
        var name = d.key ? _this.translator("region/" + d.key) : _this.values.label[d.KEY()];
        var number = _this.values.axis_y[d.KEY()];

        var string = name + ": " + formatter(number) + (i === 0 ? " people" : "");

        view.select("circle")
          .attr("r", fontHeight / 3)
          .attr("cx", fontHeight * 0.4)
          .attr("cy", fontHeight / 1.5)
          .style("fill", _this.cScale(_this.values.color[d.KEY()]));


        view.selectAll("text")
          .attr("x", fontHeight)
          .attr("y", fontHeight)
          .text(string)
          .style("font-size", fontHeight === maxFontHeight ? fontHeight : null);
      });
  },

});

export default MCSelectList;<commit_msg>Deselecting on mountain label should use small close-cross<commit_after>import * as utils from 'base/utils';
import Class from 'base/class';

var MCSelectList = Class.extend({

  init: function (context) {
    this.context = context;

  },

  rebuild: function (data) {
    var _this = this.context;

    var listData = _this.mountainPointers
      .concat(_this.groupedPointers)
      .concat(_this.stackedPointers)
      .filter(function (f) {
        return _this.model.entities.isSelected(f);
      })
      .sort(function (a, b) {
        if (b.yMax && a.yMax) return b.yMax - a.yMax;
        return b.sortValue[0] - a.sortValue[0];
      });

    _this.selectList = _this.mountainLabelContainer.selectAll("g")
      .data(utils.unique(listData, function (d) {
        return d.KEY()
      }));

    _this.selectList.exit().remove();
    _this.selectList.enter().append("g")
      .attr("class", "vzb-mc-label")
      .each(function (d, i) {
        var label = d3.select(this);
        label.append("circle").attr('class', 'vzb-mc-label-legend');
        label.append("text").attr("class", "vzb-mc-label-shadow vzb-mc-label-text");
        label.append("text").attr("class", "vzb-mc-label-text");
        label.append("circle").attr("class", "vzb-mc-label-x vzb-label-shadow vzb-transparent")
          .on("click", function (d, i) {
            if (utils.isTouchDevice()) return;
            d3.event.stopPropagation();
            _this.model.entities.clearHighlighted();
            _this.model.entities.selectEntity(d);
          })
          .onTap(function (d, i) {
            d3.event.stopPropagation();
            d3.select("#" + d.geo + "-label").remove();
            _this.model.entities.clearHighlighted();
            _this.model.entities.selectEntity(d);
          });
        label.append("text").attr("class", "vzb-mc-label-x vzb-transparent").text("x");
      })
      .on("mousemove", function (d, i) {
        if (utils.isTouchDevice()) return;
        _this.model.entities.highlightEntity(d);
        d3.select(this).selectAll(".vzb-mc-label-x")
          .classed("vzb-transparent", false);
      })
      .on("mouseout", function (d, i) {
        if (utils.isTouchDevice()) return;
        _this.model.entities.clearHighlighted();
        d3.select(this).selectAll(".vzb-mc-label-x")
          .classed("vzb-transparent", true);

      })
      .on("click", function (d, i) {
        if (utils.isTouchDevice()) return;
        _this.model.entities.clearHighlighted();
        _this.model.entities.selectEntity(d);
      });
  },

  redraw: function () {
    var _this = this.context;
    if (!_this.selectList || !_this.someSelected) return;

    var sample = _this.mountainLabelContainer.append("g").attr("class", "vzb-mc-label").append("text").text("0");
    var fontHeight = sample[0][0].getBBox().height;
    d3.select(sample[0][0].parentNode).remove();
    var formatter = _this.model.marker.axis_y.tickFormatter;

    var titleHeight = _this.yTitleEl.select("text").node().getBBox().height || 0;

    var maxFontHeight = (_this.height - titleHeight * 3) / (_this.selectList.data().length + 2);
    if (fontHeight > maxFontHeight) fontHeight = maxFontHeight;

    _this.selectList
      .attr("transform", function (d, i) {
        return "translate(0," + (fontHeight * i + titleHeight * 3) + ")";
      })
      .each(function (d, i) {

        var view = d3.select(this).attr("id", d.geo + '-label');
        var name = d.key ? _this.translator("region/" + d.key) : _this.values.label[d.KEY()];
        var number = _this.values.axis_y[d.KEY()];

        var string = name + ": " + formatter(number) + (i === 0 ? " people" : "");

        var text = view.selectAll("text.vzb-mc-label-text")
          .attr("x", fontHeight)
          .attr("y", fontHeight)
          .text(string)
          .style("font-size", fontHeight === maxFontHeight ? fontHeight : null);

        var contentBBox = text[0][0].getBBox();
        view.select("text.vzb-mc-label-x")
          .attr("x", contentBBox.width + fontHeight * 1.4)
          .attr("y", fontHeight / 3.9);

        view.select("circle.vzb-mc-label-x")
          .attr("r", fontHeight / 2.5)
          .attr("cx", contentBBox.width + fontHeight * 1.4)
          .attr("cy", fontHeight / 4);


        view.select("circle.vzb-mc-label-legend")
          .attr("r", fontHeight / 3)
          .attr("cx", fontHeight * 0.4)
          .attr("cy", fontHeight / 1.5)
          .style("fill", _this.cScale(_this.values.color[d.KEY()]));

        view.onTap(function (d, i) {
          d3.event.stopPropagation();
          _this.model.entities.highlightEntity(d);
          view.selectAll(".vzb-mc-label-x")
            .classed("vzb-transparent", false);
        });
      });
  }
});

export default MCSelectList;
{'fraction_non_alphanumeric': 0.1773067976221246, 'fraction_numerical': 0.007883173946756267, 'mean_word_length': 2.504981884057971, 'pattern_counts': {'":': 2, '<': 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': '4818276', 'n_tokens_mistral': 2602, 'n_tokens_neox': 2553, 'n_words': 419}