<commit_before>/**
 * An abstraction layer for the barogram view.
 * @param  {DOMElement} placeholder
 * @constructor
 */
function slBarogram(placeholder) {
  var baro = {};

  // Private attributes

  /**
   * The flot charts instance.
   * @type {Object}
   */
  var flot = null;

  /**
   * The data series that should be drawn as active.
   * @type {Array}
   */
  var active = [];

  /**
   * The data series that should be drawn as passive.
   * @type {Array}
   */
  var passive = [];

  /**
   * The ENL data series.
   * @type {Array}
   */
  var enls = [];

  /**
   * The contest markers.
   * @type {Array}
   */
  var contests = [];

  /**
   * The elevation data series.
   * @type {Array}
   */
  var elevations = [];

  /**
   * The object describing the highlighted time interval in the barogram.
   * @type {?Object}
   */
  var time_highlight = null;

  // Public attributes and methods

  /**
   * Draws the barogram onto the underlying canvas
   */
  baro.draw = function() {
    update();
    flot.setupGrid();
    flot.draw();
  };


  /**
   * Clears the active traces from the barogram
   */
  baro.clearActiveTraces = function() {
    active = [];
  };

  /**
   * Sets the active traces for the barogram
   * @param {Array} data
   */
  baro.setActiveTraces = function(data) {
    active = data;
  };


  /**
   * Clears the passive traces from the barogram
   */
  baro.clearPassiveTraces = function() {
    passive = [];
  };

  /**
   * Sets the passive traces for the barogram
   * @param {Array} data
   */
  baro.setPassiveTraces = function(data) {
    passive = data;
  };


  /**
   * Clears the ENL data
   */
  baro.clearENLData = function() {
    enls = [];
  };

  /**
   * Sets the ENL data
   * @param {Array} data
   */
  baro.setENLData = function(data) {
    enls = data;
  };


  /**
   * Clears the contest markers
   */
  baro.clearContests = function() {
    contests = [];
  };

  /**
   * Sets the contest markers
   * @param {Array} data
   */
  baro.setContests = function(data) {
    contests = data;
  };


  /**
   * Clears the elevation data
   */
  baro.clearElevations = function() {
    elevations = [];
  };

  /**
   * Sets the elevation data
   * @param {Array} data
   */
  baro.setElevations = function(data) {
    elevations = data;
  };


  /**
   * Clears the crosshair from the barogram
   */
  baro.clearTime = function() {
    baro.setTime(null);
  };

  /**
   * Set the crosshair to the given time
   *
   * @param {?number} time If null the crosshair is removed,
   *   if -1 the crosshair is moved to the end of the barogram,
   *   else the crosshair is moved to the given time.
   */
  baro.setTime = function(time) {
    if (time === null)
      flot.clearCrosshair();
    else if (time == -1)
      flot.lockCrosshair({x: 999999999});
    else
      flot.lockCrosshair({x: global_time * 1000});
  };


  /**
   * Clears the time interval limits from the barogram
   */
  baro.clearTimeInterval = function() {
    var opt = flot.getOptions();
    opt.xaxes[0].min = opt.xaxes[0].max = null;
  };

  /**
   * Sets the time interval that should be shown on the barogram
   *
   * @param {number} start The earliest time that should be shown.
   * @param {number} end The latest time that should be shown.
   * @return {Boolean} true if the time interval has changed
   */
  baro.setTimeInterval = function(start, end) {
    var opt = flot.getOptions();
    if (opt.xaxes[0].min != start * 1000 &&
        opt.xaxes[0].max != end * 1000) {
      opt.xaxes[0].min = start * 1000;
      opt.xaxes[0].max = end * 1000;
      return true;
    } else {
      return false;
    }
  };


  /**
   * Clears the highlight of a certain time interval from the barogram
   */
  baro.clearTimeHighlight = function() {
    time_highlight = null;<commit_msg>baro.js: update time scale if min or max has changed<commit_after>/**
 * An abstraction layer for the barogram view.
 * @param  {DOMElement} placeholder
 * @constructor
 */
function slBarogram(placeholder) {
  var baro = {};

  // Private attributes

  /**
   * The flot charts instance.
   * @type {Object}
   */
  var flot = null;

  /**
   * The data series that should be drawn as active.
   * @type {Array}
   */
  var active = [];

  /**
   * The data series that should be drawn as passive.
   * @type {Array}
   */
  var passive = [];

  /**
   * The ENL data series.
   * @type {Array}
   */
  var enls = [];

  /**
   * The contest markers.
   * @type {Array}
   */
  var contests = [];

  /**
   * The elevation data series.
   * @type {Array}
   */
  var elevations = [];

  /**
   * The object describing the highlighted time interval in the barogram.
   * @type {?Object}
   */
  var time_highlight = null;

  // Public attributes and methods

  /**
   * Draws the barogram onto the underlying canvas
   */
  baro.draw = function() {
    update();
    flot.setupGrid();
    flot.draw();
  };


  /**
   * Clears the active traces from the barogram
   */
  baro.clearActiveTraces = function() {
    active = [];
  };

  /**
   * Sets the active traces for the barogram
   * @param {Array} data
   */
  baro.setActiveTraces = function(data) {
    active = data;
  };


  /**
   * Clears the passive traces from the barogram
   */
  baro.clearPassiveTraces = function() {
    passive = [];
  };

  /**
   * Sets the passive traces for the barogram
   * @param {Array} data
   */
  baro.setPassiveTraces = function(data) {
    passive = data;
  };


  /**
   * Clears the ENL data
   */
  baro.clearENLData = function() {
    enls = [];
  };

  /**
   * Sets the ENL data
   * @param {Array} data
   */
  baro.setENLData = function(data) {
    enls = data;
  };


  /**
   * Clears the contest markers
   */
  baro.clearContests = function() {
    contests = [];
  };

  /**
   * Sets the contest markers
   * @param {Array} data
   */
  baro.setContests = function(data) {
    contests = data;
  };


  /**
   * Clears the elevation data
   */
  baro.clearElevations = function() {
    elevations = [];
  };

  /**
   * Sets the elevation data
   * @param {Array} data
   */
  baro.setElevations = function(data) {
    elevations = data;
  };


  /**
   * Clears the crosshair from the barogram
   */
  baro.clearTime = function() {
    baro.setTime(null);
  };

  /**
   * Set the crosshair to the given time
   *
   * @param {?number} time If null the crosshair is removed,
   *   if -1 the crosshair is moved to the end of the barogram,
   *   else the crosshair is moved to the given time.
   */
  baro.setTime = function(time) {
    if (time === null)
      flot.clearCrosshair();
    else if (time == -1)
      flot.lockCrosshair({x: 999999999});
    else
      flot.lockCrosshair({x: global_time * 1000});
  };


  /**
   * Clears the time interval limits from the barogram
   */
  baro.clearTimeInterval = function() {
    var opt = flot.getOptions();
    opt.xaxes[0].min = opt.xaxes[0].max = null;
  };

  /**
   * Sets the time interval that should be shown on the barogram
   *
   * @param {number} start The earliest time that should be shown.
   * @param {number} end The latest time that should be shown.
   * @return {Boolean} true if the time interval has changed
   */
  baro.setTimeInterval = function(start, end) {
    var opt = flot.getOptions();
    if (opt.xaxes[0].min != start * 1000 ||
        opt.xaxes[0].max != end * 1000) {
      opt.xaxes[0].min = start * 1000;
      opt.xaxes[0].max = end * 1000;
      return true;
    } else {
      return false;
    }
  };


  /**
   * Clears the highlight of a certain time interval from the barogram
   */
  baro.clearTimeHighlight = function() {
    time_highlight = null;
{'fraction_non_alphanumeric': 0.1352795516747035, 'fraction_numerical': 0.009644206959468266, 'mean_word_length': 2.2558336868901145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5611013', 'n_tokens_mistral': 2706, 'n_tokens_neox': 2520, 'n_words': 740}