<commit_before>var _ = require("lodash");
var React = require("react");
var Numeral = require("numeral");
var Table = require("react-bootstrap/lib/Table");

var Coverage = require("./coverage.jsx");

var formatNumber = function (number) {
    return Numeral(number).format("0.0000");
};

var Tooltip = React.createClass({

    render: function () {
        var x = this.props.x;
        var y = this.props.y;

        var tooltipStyle = {
            left: (x - 10) + "px",
            top: (y - window.pageYOffset - 10) + "px",
            zIndex: 10000
        };

        var data = this.props.barGroupData;

        var definitionRow;
        var header = data.name || null;
        var coverage;

        if (_.has(data, 'accession')) {
            header = data.accession;
            coverage = <Coverage data={data.align} />;
            definitionRow = [
                (
                    <tr key='definition'>
                        <th>Definition</th>
                        <td>{data.definition}</td>
                    </tr>
                )
            ];
        }

        var table = (
            <Table condensed bordered>
                <tbody>
                    {definitionRow}
                    <tr key='bestHit'>
                        <th>Best-hit</th>
                        <td>{formatNumber(data.best)}</td>
                    </tr>
                    <tr key='coverage'>
                        <th>Coverage</th>
                        <td>{formatNumber(data.coverage)}</td>
                    </tr>
                    <tr key='weight'>
                        <th>Weight</th>
                        <td>{formatNumber(data.pi)}</td>
                    </tr>
                </tbody>
            </Table>
        );

        return (
            <div className='tooltip' style={tooltipStyle}>
                <div className='tooltip-header'>
                    {header}
                </div>
                <div className='tooltip-body'>
                    {table}
                    {coverage}
                </div>
            </div>
        );
    }

});

module.exports = Tooltip;<commit_msg>Move redundant functionality to base Tooltip component<commit_after>var _ = require('lodash');
var React = require('react');
var Numeral = require('numeral');
var Table = require('react-bootstrap/lib/Table');

var Tooltip = require('virtool/js/components/Base/Tooltip.jsx');
var Coverage = require('./coverage.jsx');

var formatNumber = function (number) {
    return Numeral(number).format('0.0000');
};

var PathoscopeTooltip = React.createClass({

    render: function () {
        var data = this.props.barGroupData;

        var definitionRow;
        var header = data.name || null;
        var coverage;

        if (_.has(data, 'accession')) {
            header = data.accession;
            coverage = <Coverage data={data.align} />;
            definitionRow = [
                (
                    <tr key='definition'>
                        <th>Definition</th>
                        <td>{data.definition}</td>
                    </tr>
                )
            ];
        }

        var table = (
            <Table condensed bordered>
                <tbody>
                    {definitionRow}
                    <tr key='bestHit'>
                        <th>Best-hit</th>
                        <td>{formatNumber(data.best)}</td>
                    </tr>
                    <tr key='coverage'>
                        <th>Coverage</th>
                        <td>{formatNumber(data.coverage)}</td>
                    </tr>
                    <tr key='weight'>
                        <th>Weight</th>
                        <td>{formatNumber(data.pi)}</td>
                    </tr>
                </tbody>
            </Table>
        );

        return (
            <Tooltip x={this.props.x} y={this.props.y} header={header}>
                {table}
                {coverage}
            </Tooltip>
        );
    }

});

module.exports = PathoscopeTooltip;
{'fraction_non_alphanumeric': 0.13216403162055335, 'fraction_numerical': 0.004693675889328063, 'mean_word_length': 1.1687198714515266, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, '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': '7062361', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1028, 'n_words': 201}