<commit_before>define([
 'jquery',
 'd3',
 'underscore',
 'handlebars',
 'mps',
 'text!widgets/templates/indicators/line/linechart-tooltip.handlebars'
], function($, d3, _, Handlebars, mps, tooltipTpl){

var LineChart = function(options) {
  this.svg;
  this.options = options;
  this.parent = options.parent;
  this.data = options.data;
  this.indicators = options.indicators;
  this.unit = options.unit
  this.unitname = options.unitname;
  this.rangeX = options.rangeX;
  this.rangeY = options.rangeY;
  this.lock = options.lock;
  this.templateTooltip = Handlebars.compile(tooltipTpl);

  this.sizing = options.sizing;
  this.innerPadding = options.innerPadding;
  this.namespace = new Date().valueOf().toString();

  this.color = ['#5B80A0','#bebcc2','#E98300'];

  this.parentWidth = $(this.options.el).outerWidth();
  this.parentHeight = $(this.options.el).outerHeight();
  this.width = this.parentWidth - this.sizing.left - this.sizing.right,
  this.height = this.parentHeight - this.sizing.top - this.sizing.bottom;
  if (!!this.parentWidth && !!this.parentHeight) {
    this._createEl();
    this._createDefs();
    this._createScales();
  }

  this.setListeners();
  // $(window).resize(_.debounce(this.resize.bind(this), 100))
  $(window).on('resize.namespace'+this.namespace, _.debounce(this.resize.bind(this), 100));
};

LineChart.prototype.offResize = function() {
  $(window).off('resize.namespace'+this.namespace);
};

LineChart.prototype.resize = function() {
  this.offResize();
  $(this.options.el).find('svg').remove();
  this.destroy();
  new LineChart(this.options).render();
};

LineChart.prototype._createEl = function() {
  this.svg = d3.select(this.options.el)
    .append("svg")
      .attr('class', 'lineChart')
      .attr("width", this.parentWidth)
      .attr("height", this.parentHeight);
};

LineChart.prototype._createScales = function() {
  var self = this;
  this.xKey = this.options.keys.x;
  this.yKey = this.options.keys.y;

  this.x = d3.time.scale().range([this.options.innerPadding.left, this.width - this.options.innerPadding.right]);
  this.x.domain(this.rangeX);

  // this.y = d3.scale.linear().range([this.height,this.options.innerPadding.top]);
  this.y = d3.scale.linear().range([this.height - this.options.innerPadding.bottom,this.options.innerPadding.top]);
  this.y.domain(this.rangeY);

  this.line = d3.svg.line()
    .interpolate('linear')
    .x(function(d) { return self.x(d[self.xKey]); })
    .y(function(d) { return self.y(d[self.yKey]); });



};

LineChart.prototype._createDefs = function() {
  this.svg.append("defs").append("clipPath")
    .attr("id", "clip")
  .append("rect")
    .attr("width", this.width)
    .attr("height", this.height);
};


LineChart.prototype._drawAxes = function() {
  var self = this;
  var tickSizeX = ($(window).width() > 1025) ? 1 : 2;
  var tickFormatY = (this.unit != 'percentage') ? "s" : ".2f";
  this.xAxis = d3.svg.axis()
                 .scale(self.x)<commit_msg>Fix float axis<commit_after>define([
 'jquery',
 'd3',
 'underscore',
 'handlebars',
 'mps',
 'text!widgets/templates/indicators/line/linechart-tooltip.handlebars'
], function($, d3, _, Handlebars, mps, tooltipTpl){

var LineChart = function(options) {
  this.svg;
  this.options = options;
  this.parent = options.parent;
  this.data = options.data;
  this.indicators = options.indicators;
  this.unit = options.unit
  this.unitname = options.unitname;
  this.rangeX = options.rangeX;
  this.rangeY = options.rangeY;
  this.lock = options.lock;
  this.templateTooltip = Handlebars.compile(tooltipTpl);

  this.sizing = options.sizing;
  this.innerPadding = options.innerPadding;
  this.namespace = new Date().valueOf().toString();

  this.color = ['#5B80A0','#bebcc2','#E98300'];

  this.parentWidth = $(this.options.el).outerWidth();
  this.parentHeight = $(this.options.el).outerHeight();
  this.width = this.parentWidth - this.sizing.left - this.sizing.right,
  this.height = this.parentHeight - this.sizing.top - this.sizing.bottom;
  if (!!this.parentWidth && !!this.parentHeight) {
    this._createEl();
    this._createDefs();
    this._createScales();
  }

  this.setListeners();
  // $(window).resize(_.debounce(this.resize.bind(this), 100))
  $(window).on('resize.namespace'+this.namespace, _.debounce(this.resize.bind(this), 100));
};

LineChart.prototype.offResize = function() {
  $(window).off('resize.namespace'+this.namespace);
};

LineChart.prototype.resize = function() {
  this.offResize();
  $(this.options.el).find('svg').remove();
  this.destroy();
  new LineChart(this.options).render();
};

LineChart.prototype._createEl = function() {
  this.svg = d3.select(this.options.el)
    .append("svg")
      .attr('class', 'lineChart')
      .attr("width", this.parentWidth)
      .attr("height", this.parentHeight);
};

LineChart.prototype._createScales = function() {
  var self = this;
  this.xKey = this.options.keys.x;
  this.yKey = this.options.keys.y;

  this.x = d3.time.scale().range([this.options.innerPadding.left, this.width - this.options.innerPadding.right]);
  this.x.domain(this.rangeX);

  // this.y = d3.scale.linear().range([this.height,this.options.innerPadding.top]);
  this.y = d3.scale.linear().range([this.height - this.options.innerPadding.bottom,this.options.innerPadding.top]);
  this.y.domain(this.rangeY);

  this.line = d3.svg.line()
    .interpolate('linear')
    .x(function(d) { return self.x(d[self.xKey]); })
    .y(function(d) { return self.y(d[self.yKey]); });



};

LineChart.prototype._createDefs = function() {
  this.svg.append("defs").append("clipPath")
    .attr("id", "clip")
  .append("rect")
    .attr("width", this.width)
    .attr("height", this.height);
};


LineChart.prototype._drawAxes = function() {
  var self = this;
  var tickSizeX = ($(window).width() > 1025) ? 1 : 2;
  var tickFormatY = (this.unit != 'percentage') ? ".2s" : ".2f";
  this.xAxis = d3.svg.axis()
                 .scale(self.x)
{'fraction_non_alphanumeric': 0.18847902981303688, 'fraction_numerical': 0.010611419909044972, 'mean_word_length': 3.9815436241610738, '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': '139711', 'n_tokens_mistral': 2116, 'n_tokens_neox': 2062, 'n_words': 299}