{"size": 1011, "ext": "js", "max_stars_repo_path": "src/client/containers/charts/tooltip/KLineTip.js", "max_stars_repo_name": "Paul-Long/react-ssr-core", "max_stars_repo_stars_event_min_datetime": "2018-09-12T07:59:37.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-26T01:30:24.000Z", "max_issues_repo_path": "src/client/containers/charts/tooltip/KLineTip.js", "max_issues_repo_name": "Paul-Long/react-ssr-core", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/client/containers/charts/tooltip/KLineTip.js", "max_forks_repo_name": "Paul-Long/react-ssr-core", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.3243243243, "max_line_length": 103, "alphanum_fraction": 0.5806132542}
import React from 'react';
import classNames from 'classnames';
import Tip from './Tip';
import Item from './Item';
import VolumeTip from './VolumeTip';

class KLineTip extends Tip {
  keys = [['开', 'open'], ['高', 'highest'], ['收', 'close'], ['低', 'lowest']];
  static defaultProps = {
    indicator: 'kLine',
  };

  getCls = () => {
    const {prefixCls} = this.props;
    return classNames(`${prefixCls}-kLine`);
  };

  render() {
    const {tip, tipLast} = this.state;
    const {prefixCls, manager} = this.props;
    const data = tip || tipLast || {};
    const style = {display: 'none'};
    if (tipLast) {
      style.top = tipLast.grid.top - 20;
      style.left = tipLast.grid.left;
      style.display = 'flex';
    }
    return (
      <div className={this.getCls()} style={style}>
        {this.keys.map(([l, k]) => (<Item key={k} prefixCls={prefixCls} label={l} value={data[k]} />))}
        <VolumeTip prefixCls={prefixCls} manager={manager} />
      </div>
    );
  }
}

export default KLineTip;