<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import d3 from 'd3';

import Axis from './axis';

export default class XYAxis extends React.Component { // eslint-disable-line react/prefer-stateless-function
  render() {
    const xSettings = {
      translate: `translate(0, ${this.props.height - this.props.padding})`,
      scale: this.props.xScale,
      orient: 'bottom',
    };
    // const ySettings = {
    //   translate: `translate(${this.props.padding}, 0)`,
    //   scale: this.props.yScale,
    //   orient: 'left',
    // };
    const line = d3.svg.line()
      .x((d) => d.x)
      .y((d) => d.y)
      .interpolate('monotone');

    // const margin = {top: 5, right: 50, bottom: 20, left: 50};
    // const transform ='translate(' + margin.left + ',' + margin.top + ')';
    const reactionEnergy = this.props.selectedReaction.reactionEnergy;
    const activationEnergy = this.props.selectedReaction.activationEnergy;
    let plotHeight = Math.abs(reactionEnergy);
    let barrierHeight;
    if (activationEnergy == null) {
      barrierHeight = reactionEnergy / 2.0 / plotHeight;
    } else {
      plotHeight = activationEnergy + Math.abs(reactionEnergy);
      barrierHeight = activationEnergy / plotHeight;
    }
    const reactHeight = reactionEnergy / plotHeight;
    const offset = 180 + 100 * Math.max(reactHeight, barrierHeight);
    const data = [
      { x: 0, y: offset },
      { x: 120, y: offset },
      { x: 200, y: offset - (250 * barrierHeight) },
      { x: 280, y: offset - (250 * reactHeight) },
      { x: 400, y: offset - (250 * reactHeight) },
    ];
    if (activationEnergy == null) {
      return (
        <g className="xy-axis">
          <Axis {...xSettings} />
          <path stroke="black" fill="none" strokeWidth={8} className="line shadow" d={line(data)} />
          <line x1={0} x2={500} y1={200} y2={400} />
          <text x={120} y={340} fontFamily="sans-serif" fontSize="14px" fill="red">
            {' '}
Reaction Energy
            {reactionEnergy.toFixed(2)}
            {' '}
eV
            {' '}
          </text>
        </g>
      );
    }
    const labelHeight = offset - (250 * barrierHeight) - 30;
    const labelReact = offset - (250 * reactHeight) + 40;
    return (
      <g className="xy-axis">
        <Axis {...xSettings} />
        <path stroke="black" fill="none" strokeWidth={8} className="line shadow" d={line(data)} />
        <line x1={0} x2={500} y1={200} y2={400} />
        <text x={260} y={labelReact} fontFamily="sans-serif" fontSize="14px" fill="red">
          Reaction Energy
          {' '}
          {reactionEnergy.toFixed(2)}
          {' '}
eV
          {' '}
        </text>
        <text x={120} y={labelHeight} fontFamily="sans-serif" fontSize="14px" fill="red">
          Activation Energy<commit_msg>dont mix operators<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import d3 from 'd3';

import Axis from './axis';

export default class XYAxis extends React.Component { // eslint-disable-line react/prefer-stateless-function
  render() {
    const xSettings = {
      translate: `translate(0, ${this.props.height - this.props.padding})`,
      scale: this.props.xScale,
      orient: 'bottom',
    };
    // const ySettings = {
    //   translate: `translate(${this.props.padding}, 0)`,
    //   scale: this.props.yScale,
    //   orient: 'left',
    // };
    const line = d3.svg.line()
      .x((d) => d.x)
      .y((d) => d.y)
      .interpolate('monotone');

    // const margin = {top: 5, right: 50, bottom: 20, left: 50};
    // const transform ='translate(' + margin.left + ',' + margin.top + ')';
    const reactionEnergy = this.props.selectedReaction.reactionEnergy;
    const activationEnergy = this.props.selectedReaction.activationEnergy;
    let plotHeight = Math.abs(reactionEnergy);
    let barrierHeight;
    if (activationEnergy == null) {
      barrierHeight = reactionEnergy / 2.0 / plotHeight;
    } else {
      plotHeight = activationEnergy + Math.abs(reactionEnergy);
      barrierHeight = activationEnergy / plotHeight;
    }
    const reactHeight = reactionEnergy / plotHeight;
    const offset = 180 + (100 * Math.max(reactHeight, barrierHeight));
    const data = [
      { x: 0, y: offset },
      { x: 120, y: offset },
      { x: 200, y: offset - (250 * barrierHeight) },
      { x: 280, y: offset - (250 * reactHeight) },
      { x: 400, y: offset - (250 * reactHeight) },
    ];
    if (activationEnergy == null) {
      return (
        <g className="xy-axis">
          <Axis {...xSettings} />
          <path stroke="black" fill="none" strokeWidth={8} className="line shadow" d={line(data)} />
          <line x1={0} x2={500} y1={200} y2={400} />
          <text x={120} y={340} fontFamily="sans-serif" fontSize="14px" fill="red">
            {' '}
Reaction Energy
            {reactionEnergy.toFixed(2)}
            {' '}
eV
            {' '}
          </text>
        </g>
      );
    }
    const labelHeight = offset - ((250 * barrierHeight) + 30);
    const labelReact = offset - ((250 * reactHeight) - 40);
    return (
      <g className="xy-axis">
        <Axis {...xSettings} />
        <path stroke="black" fill="none" strokeWidth={8} className="line shadow" d={line(data)} />
        <line x1={0} x2={500} y1={200} y2={400} />
        <text x={260} y={labelReact} fontFamily="sans-serif" fontSize="14px" fill="red">
          Reaction Energy
          {' '}
          {reactionEnergy.toFixed(2)}
          {' '}
eV
          {' '}
        </text>
        <text x={120} y={labelHeight} fontFamily="sans-serif" fontSize="14px" fill="red">
          Activation Energy
{'fraction_non_alphanumeric': 0.1648138344803247, 'fraction_numerical': 0.035997882477501325, 'mean_word_length': 2.396045536249251, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, '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': '6596790', 'n_tokens_mistral': 1956, 'n_tokens_neox': 1778, 'n_words': 421}