<commit_before>Box.Application.addService('cubism-graphs', function(application) {
  'use strict';
  var cubism    = application.getGlobal('cubism');
  var windowSvc = application.getService('window');

  var cubismContext = cubism.context();
  var focusEvents   = {};

  cubismContext.on('focus', function(index) {
    for (var moduleId in focusEvents) {
      focusEvents[moduleId].call(cubismContext, index);
    }
  }, cubismContext);

  // TODO: this may need debouncing, each graph will call this on it's reset
  function resetCubismContext(step, widthInPx) {
    widthInPx = (typeof widthInPx === 'number') ? widthInPx : $(window).width();
    step = (typeof step === 'number') ? step : getStep();

    cubismContext.step(step).size(widthInPx);
    application.broadcast("cubism-context-reset");
  }

  // TODO: move to utils
  function getTimescale() {
    return windowSvc.getHashVariable('timescale') || 10800;
  }

  // TODO: move to utils
  function getStep(timescale, widthInPx) {
    widthInPx = widthInPx || $(window).width();
    timescale = timescale || getTimescale();
    return parseInt(timescale * 1000 / widthInPx);
  }

  // create a context when service initializes
  //FIXME service should not be dependent on the DOM on browser state
  resetCubismContext();
<commit_msg>pass down timescale in case someone wants to configure it manually and not through url<commit_after>Box.Application.addService('cubism-graphs', function(application) {
  'use strict';
  var cubism    = application.getGlobal('cubism');
  var windowSvc = application.getService('window');

  var cubismContext = cubism.context();
  var focusEvents   = {};

  cubismContext.on('focus', function(index) {
    for (var moduleId in focusEvents) {
      focusEvents[moduleId].call(cubismContext, index);
    }
  }, cubismContext);

  // TODO: this may need debouncing, each graph will call this on it's reset
  function resetCubismContext(step, widthInPx, timescale) {
    widthInPx = (typeof widthInPx === 'number') ? widthInPx : $(window).width();
    step = (typeof step === 'number') ? step : getStep(timescale, widthInPx);

    cubismContext.step(step).size(widthInPx);
    application.broadcast("cubism-context-reset");
  }

  // TODO: move to utils
  function getTimescale() {
    return windowSvc.getHashVariable('timescale') || 10800;
  }

  // TODO: move to utils
  function getStep(timescale, widthInPx) {
    widthInPx = widthInPx || $(window).width();
    timescale = timescale || getTimescale();
    return parseInt(timescale * 1000 / widthInPx);
  }

  // create a context when service initializes
  //FIXME service should not be dependent on the DOM on browser state
  resetCubismContext();

{'fraction_non_alphanumeric': 0.12537091988130564, 'fraction_numerical': 0.0066765578635014835, 'mean_word_length': 4.0600375234521575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '681432', 'n_tokens_mistral': 870, 'n_tokens_neox': 822, 'n_words': 216}