<commit_before>import React, { PropTypes } from 'react';
import classNames from 'classnames';
import { area } from 'd3-shape';

import { eventHandleWrapper } from '../../../utils/events';
import { CommonDefaultProps, CommonPropTypes, PureComponent } from '../../../utils';

class Area extends PureComponent {
  render() {
    const {
      className,
      data,
      scales,
      color,
      strokeWidth,
      dataAccessors: { x: xAccessor, y0: y0Accessor, y1: y1Accessor },
      onClick,
      hoverHandler,
      style,
    } = this.props;

    const path = area()
      .x((datum) => scales.x(datum[xAccessor]))
      .y0((datum) => scales.y(datum[y0Accessor]))
      .y1((datum) => scales.y(datum[y1Accessor]));

    return (
      <path
        className={classNames(className)}
        fill={color}
        stroke={color}
        strokeWidth={`${strokeWidth}px`}
        d={path(data)}
        onClick={eventHandleWrapper(onClick, data, this)}
        onMouseOver={eventHandleWrapper(hoverHandler, data, this)}
        style={style}
      />
    );
  }
}

Area.propTypes = {
  className: CommonPropTypes.className,

  /* array of objects
   e.g. [ {}, {}, {} ]
   */
  data: PropTypes.arrayOf(PropTypes.object).isRequired,

  /* scales from d3Scale */
  scales: PropTypes.shape({
    x: PropTypes.func,
    y: PropTypes.func
  }).isRequired,

  color: PropTypes.string,

  strokeWidth: PropTypes.number,

  dataAccessors: PropTypes.shape({
    x: CommonPropTypes.dataAccessor.isRequired,
    y0: CommonPropTypes.dataAccessor.isRequired,
    y1: CommonPropTypes.dataAccessor.isRequired,
  }).isRequired,

  onClick: PropTypes.func,

  hoverHandler: PropTypes.func,

  style: CommonPropTypes.style,
};

Area.defaultProps = {
  color: 'steelblue',
  strokeWidth: 2.5,
  dataAccessors: { x: 'x', y0: 'y0', y1: 'y1' },
  onClick: CommonDefaultProps.noop,
  hoverHandler: CommonDefaultProps.noop,
};

export default Area;<commit_msg>add mouse events to `Area`<commit_after>import React, { PropTypes } from 'react';
import classNames from 'classnames';
import { area } from 'd3-shape';

import { eventHandleWrapper } from '../../../utils/events';
import { CommonDefaultProps, CommonPropTypes, PureComponent } from '../../../utils';

class Area extends PureComponent {
  render() {
    const {
      className,
      data,
      scales,
      color,
      strokeWidth,
      dataAccessors: { x: xAccessor, y0: y0Accessor, y1: y1Accessor },
      onClick,
      onMouseLeave,
      onMouseMove,
      onMouseOver,
      style,
    } = this.props;

    const path = area()
      .x((datum) => scales.x(datum[xAccessor]))
      .y0((datum) => scales.y(datum[y0Accessor]))
      .y1((datum) => scales.y(datum[y1Accessor]));

    return (
      <path
        className={classNames(className)}
        fill={color}
        stroke={color}
        strokeWidth={`${strokeWidth}px`}
        d={path(data)}
        onClick={eventHandleWrapper(onClick, data, this)}
        onMouseLeave={eventHandleWrapper(onMouseLeave, data, this)}
        onMouseMove={eventHandleWrapper(onMouseMove, data, this)}
        onMouseOver={eventHandleWrapper(onMouseOver, data, this)}
        style={style}
      />
    );
  }
}

Area.propTypes = {
  className: CommonPropTypes.className,

  /* array of objects
   e.g. [ {}, {}, {} ]
   */
  data: PropTypes.arrayOf(PropTypes.object).isRequired,

  /* scales from d3Scale */
  scales: PropTypes.shape({
    x: PropTypes.func,
    y: PropTypes.func
  }).isRequired,

  color: PropTypes.string,

  strokeWidth: PropTypes.number,

  dataAccessors: PropTypes.shape({
    x: CommonPropTypes.dataAccessor.isRequired,
    y0: CommonPropTypes.dataAccessor.isRequired,
    y1: CommonPropTypes.dataAccessor.isRequired,
  }).isRequired,

  onClick: PropTypes.func,
  onMouseLeave: PropTypes.func,
  onMouseMove: PropTypes.func,
  onMouseOver: PropTypes.func,

  style: CommonPropTypes.style,
};

Area.defaultProps = {
  color: 'steelblue',
  strokeWidth: 2.5,
  dataAccessors: { x: 'x', y0: 'y0', y1: 'y1' },
  onClick: CommonDefaultProps.noop,
  onMouseLeave: CommonDefaultProps.noop,
  onMouseMove: CommonDefaultProps.noop,
  onMouseOver: CommonDefaultProps.noop,
};

export default Area;
{'fraction_non_alphanumeric': 0.14085177254342138, 'fraction_numerical': 0.008565310492505354, 'mean_word_length': 3.1706349206349205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '485146', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1347, 'n_words': 269}