<commit_before>import { scan } from 'd3-array';
import { axisBottom } from 'd3-axis';
import { dispatch } from 'd3-dispatch';
import { drag } from 'd3-drag';
import { easeQuadOut } from 'd3-ease';
import { scaleLinear, scaleTime } from 'd3-scale';
import { event, select } from 'd3-selection';

var UPDATE_DURATION = 200;

function slider() {
  var value = 0;
  var defaultValue = 0;
  var domain = [0, 10];
  var width = 100;
  var displayValue = true;
  var handle = 'M-5.5,-5.5v10l6,5.5l6,-5.5v-10z';
  var step = null;
  var tickValues = null;
  var marks = null;
  var tickFormat = null;
  var ticks = null;
  var displayFormat = null;

  var listeners = dispatch('onchange', 'start', 'end', 'drag');

  var selection = null;
  var scale = null;
  var identityClamped = null;

  var handleSelection = null;
  var textSelection = null;

  function slider(context) {
    selection = context.selection ? context.selection() : context;

    scale = domain[0] instanceof Date ? scaleTime() : scaleLinear();

    scale = scale
      .domain(domain)
      .range([0, width])
      .clamp(true);

    identityClamped = scaleLinear()
      .range(scale.range())
      .domain(scale.range())
      .clamp(true);

    // Ensure value is valid
    value = scaleLinear()
      .range(domain)
      .domain(domain)
      .clamp(true)(value);

    tickFormat = tickFormat || scale.tickFormat();
    displayFormat = displayFormat || scale.tickFormat();

    var axis = selection.selectAll('.axis').data([null]);

    axis
      .enter()
      .append('g')
      .attr('transform', 'translate(0,7)')
      .attr('class', 'axis');

    var slider = selection.selectAll('.slider').data([null]);

    var sliderEnter = slider
      .enter()
      .append('g')
      .attr('class', 'slider')
      .attr('cursor', 'ew-resize')
      .attr('transform', 'translate(0,0)')
      .call(
        drag()
          .on('start', dragstarted)
          .on('drag', dragged)
          .on('end', dragended)
      );

    sliderEnter
      .append('line')
      .attr('class', 'track')
      .attr('x1', 0)
      .attr('y1', 0)
      .attr('y2', 0)
      .attr('stroke', '#bbb')
      .attr('stroke-width', 6)
      .attr('stroke-linecap', 'round');

    sliderEnter
      .append('line')
      .attr('class', 'track-inset')
      .attr('x1', 0)
      .attr('y1', 0)
      .attr('y2', 0)
      .attr('stroke', '#eee')
      .attr('stroke-width', 4)
      .attr('stroke-linecap', 'round');

    sliderEnter
      .append('line')
      .attr('class', 'track-overlay')
      .attr('x1', 0)
      .attr('y1', 0)
      .attr('y2', 0)
      .attr('stroke', 'transparent')
      .attr('stroke-width', 40)
      .attr('stroke-linecap', 'round')
      .merge(slider.select('.track-overlay'));

    var handleEnter = sliderEnter
      .append('g')
      .attr('class', 'parameter-value')
      .attr('transform', 'translate(' + scale(value) + ',0)')
      .attr('font-family', 'sans-serif')
      .attr('text-anchor', 'middle');

    handleEnter
      .append('path')
      .attr('d', handle)
      .attr('fill', 'white')
      .attr('stroke', '#777');

    if (displayValue) {
      handleEnter
        .append('text')
        .attr('font-size', 10)
        .attr('y', 27)
        .attr('dy', '.71em')
        .text(tickFormat(value));
    }

    context.select('.track').attr('x2', scale.range()[1]);
    context.select('.track-inset').attr('x2', scale.range()[1]);
    context.select('.track-overlay').attr('x2', scale.range()[1]);

    context.select('.axis').call(
      axisBottom(scale)
        .tickFormat(tickFormat)
        .ticks(ticks)
        .tickValues(tickValues)
    );

    // https://bl.ocks.org/mbostock/4323929
    selection
      .select('.axis')
      .select('.domain')
      .remove();

    context.select('.axis').attr('transform', 'translate(0,7)');

    context
      .selectAll('.axis text')
      .attr('fill', '#aaa')
      .attr('y', 20)
      .attr('dy', '.71em')
      .attr('text-anchor', 'middle');

    context.selectAll('.axis line').attr('stroke', '#aaa');

    context
      .select('.parameter-value')
      .attr('transform', 'translate(' + scale(value) + ',0)');

    fadeTickText();

    function dragstarted() {
      select(this).classed('active', true);
      var pos = identityClamped(event.x);
      var newValue = alignedValue(scale.invert(pos));

      updateHandle(newValue);
      listeners.call('start', slider, newValue);
      updateValue(newValue);
    }

    function dragged() {
      var pos = identityClamped(event.x);
      var newValue = alignedValue(scale.invert(pos));

      updateHandle(newValue);
      listeners.call('drag', slider, newValue);
      updateValue(newValue);
    }

    function dragended() {
      select(this).classed('active', false);
      var pos = identityClamped(event.x);
      var newValue = alignedValue(scale.invert(pos));

      updateHandle(newValue);<commit_msg>Forgot to notify when dragging<commit_after>import { scan } from 'd3-array';
import { axisBottom } from 'd3-axis';
import { dispatch } from 'd3-dispatch';
import { drag } from 'd3-drag';
import { easeQuadOut } from 'd3-ease';
import { scaleLinear, scaleTime } from 'd3-scale';
import { event, select } from 'd3-selection';

var UPDATE_DURATION = 200;

function slider() {
  var value = 0;
  var defaultValue = 0;
  var domain = [0, 10];
  var width = 100;
  var displayValue = true;
  var handle = 'M-5.5,-5.5v10l6,5.5l6,-5.5v-10z';
  var step = null;
  var tickValues = null;
  var marks = null;
  var tickFormat = null;
  var ticks = null;
  var displayFormat = null;

  var listeners = dispatch('onchange', 'start', 'end', 'drag');

  var selection = null;
  var scale = null;
  var identityClamped = null;

  var handleSelection = null;
  var textSelection = null;

  function slider(context) {
    selection = context.selection ? context.selection() : context;

    scale = domain[0] instanceof Date ? scaleTime() : scaleLinear();

    scale = scale
      .domain(domain)
      .range([0, width])
      .clamp(true);

    identityClamped = scaleLinear()
      .range(scale.range())
      .domain(scale.range())
      .clamp(true);

    // Ensure value is valid
    value = scaleLinear()
      .range(domain)
      .domain(domain)
      .clamp(true)(value);

    tickFormat = tickFormat || scale.tickFormat();
    displayFormat = displayFormat || scale.tickFormat();

    var axis = selection.selectAll('.axis').data([null]);

    axis
      .enter()
      .append('g')
      .attr('transform', 'translate(0,7)')
      .attr('class', 'axis');

    var slider = selection.selectAll('.slider').data([null]);

    var sliderEnter = slider
      .enter()
      .append('g')
      .attr('class', 'slider')
      .attr('cursor', 'ew-resize')
      .attr('transform', 'translate(0,0)')
      .call(
        drag()
          .on('start', dragstarted)
          .on('drag', dragged)
          .on('end', dragended)
      );

    sliderEnter
      .append('line')
      .attr('class', 'track')
      .attr('x1', 0)
      .attr('y1', 0)
      .attr('y2', 0)
      .attr('stroke', '#bbb')
      .attr('stroke-width', 6)
      .attr('stroke-linecap', 'round');

    sliderEnter
      .append('line')
      .attr('class', 'track-inset')
      .attr('x1', 0)
      .attr('y1', 0)
      .attr('y2', 0)
      .attr('stroke', '#eee')
      .attr('stroke-width', 4)
      .attr('stroke-linecap', 'round');

    sliderEnter
      .append('line')
      .attr('class', 'track-overlay')
      .attr('x1', 0)
      .attr('y1', 0)
      .attr('y2', 0)
      .attr('stroke', 'transparent')
      .attr('stroke-width', 40)
      .attr('stroke-linecap', 'round')
      .merge(slider.select('.track-overlay'));

    var handleEnter = sliderEnter
      .append('g')
      .attr('class', 'parameter-value')
      .attr('transform', 'translate(' + scale(value) + ',0)')
      .attr('font-family', 'sans-serif')
      .attr('text-anchor', 'middle');

    handleEnter
      .append('path')
      .attr('d', handle)
      .attr('fill', 'white')
      .attr('stroke', '#777');

    if (displayValue) {
      handleEnter
        .append('text')
        .attr('font-size', 10)
        .attr('y', 27)
        .attr('dy', '.71em')
        .text(tickFormat(value));
    }

    context.select('.track').attr('x2', scale.range()[1]);
    context.select('.track-inset').attr('x2', scale.range()[1]);
    context.select('.track-overlay').attr('x2', scale.range()[1]);

    context.select('.axis').call(
      axisBottom(scale)
        .tickFormat(tickFormat)
        .ticks(ticks)
        .tickValues(tickValues)
    );

    // https://bl.ocks.org/mbostock/4323929
    selection
      .select('.axis')
      .select('.domain')
      .remove();

    context.select('.axis').attr('transform', 'translate(0,7)');

    context
      .selectAll('.axis text')
      .attr('fill', '#aaa')
      .attr('y', 20)
      .attr('dy', '.71em')
      .attr('text-anchor', 'middle');

    context.selectAll('.axis line').attr('stroke', '#aaa');

    context
      .select('.parameter-value')
      .attr('transform', 'translate(' + scale(value) + ',0)');

    fadeTickText();

    function dragstarted() {
      select(this).classed('active', true);
      var pos = identityClamped(event.x);
      var newValue = alignedValue(scale.invert(pos));

      updateHandle(newValue);
      listeners.call('start', slider, newValue);
      updateValue(newValue, true);
    }

    function dragged() {
      var pos = identityClamped(event.x);
      var newValue = alignedValue(scale.invert(pos));

      updateHandle(newValue);
      listeners.call('drag', slider, newValue);
      updateValue(newValue, true);
    }

    function dragended() {
      select(this).classed('active', false);
      var pos = identityClamped(event.x);
      var newValue = alignedValue(scale.invert(pos));

      updateHandle(newValue);
{'fraction_non_alphanumeric': 0.18596171376481313, 'fraction_numerical': 0.018231540565177756, 'mean_word_length': 2.5970856102003643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3459392', 'n_tokens_mistral': 3334, 'n_tokens_neox': 3151, 'n_words': 651}