<commit_before>module.exports.register = function (context) {

  var TheGraph = context.TheGraph;

  TheGraph.config.tooltip = {
    container: {},
    rect: {
      className: "tooltip-bg",
      x: 0,
      y: -7,
      rx: 3,
      ry: 3,
      height: 16
    },
    text: {
      className: "tooltip-label",
      ref: "label"
    }
  };

  TheGraph.factories.tooltip = {
    createTooltipGroup: TheGraph.factories.createGroup,
    createTooltipRect: TheGraph.factories.createRect,
    createTooltipText: TheGraph.factories.createText
  };

  // Port view

  TheGraph.Tooltip = React.createFactory( React.createClass({
    displayName: "TheGraphTooltip",
    render: function() {

      var rectOptions = TheGraph.merge(TheGraph.config.tooltip.rect, {width: this.props.label.length * 6});
      var rect = TheGraph.factories.tooltip.createTooltipRect.call(this, rectOptions);

      var textOptions = TheGraph.merge(TheGraph.config.tooltip.text, { children: this.props.label });
      var text = TheGraph.factories.tooltip.createTooltipText.call(this, textOptions);

      var containerContents = [rect, text];

      var containerOptions = {
        className: "tooltip" + (this.props.visible ? "" : " hidden"),
        transform: "translate("+this.props.x+","+this.props.y+")",
      };
      containerOptions = TheGraph.merge(TheGraph.config.tooltip.container, containerOptions);
      return TheGraph.factories.tooltip.createTooltipGroup.call(this, containerOptions, containerContents);

    }
  }));


};<commit_msg>the-graph-tooltip: Use factories.js<commit_after>var defaultFactories = require('./factories.js');

module.exports.register = function (context) {

  var TheGraph = context.TheGraph;
  var merge = TheGraph.merge;

  var config = {
    container: {},
    rect: {
      className: "tooltip-bg",
      x: 0,
      y: -7,
      rx: 3,
      ry: 3,
      height: 16
    },
    text: {
      className: "tooltip-label",
      ref: "label"
    }
  };


  var factories = {
    createTooltipGroup: defaultFactories.createGroup,
    createTooltipRect: defaultFactories.createRect,
    createTooltipText: defaultFactories.createText
  };

  // Port view
  Tooltip = React.createFactory( React.createClass({
    displayName: "TheGraphTooltip",
    render: function() {

      var rectOptions = merge(config.rect, {width: this.props.label.length * 6});
      var rect = factories.createTooltipRect.call(this, rectOptions);

      var textOptions = merge(config.text, { children: this.props.label });
      var text = factories.createTooltipText.call(this, textOptions);

      var containerContents = [rect, text];

      var containerOptions = {
        className: "tooltip" + (this.props.visible ? "" : " hidden"),
        transform: "translate("+this.props.x+","+this.props.y+")",
      };
      containerOptions = merge(config.container, containerOptions);
      return factories.createTooltipGroup.call(this, containerOptions, containerContents);

    }
  }));


  // TODO: should primarily be exposed as 'TheGraph.tooltip.config'
  TheGraph.config.tooltip = config;
  TheGraph.factories.tooltip = factories;
  TheGraph.Tooltip = Tooltip;
};
{'fraction_non_alphanumeric': 0.13137068692624249, 'fraction_numerical': 0.004431782209559987, 'mean_word_length': 3.1688654353562007, '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': '5371726', 'n_tokens_mistral': 960, 'n_tokens_neox': 936, 'n_words': 183}