<commit_before>import React, { Component, PropTypes } from "react";

import TooltipPopover from "metabase/components/TooltipPopover.jsx"

import { formatNumber, formatValue } from "metabase/lib/formatting";

export default class ChartTooltip extends Component {
    constructor(props, context) {
        super(props, context);
        this.state = {};
    }

    static propTypes = {
        series: PropTypes.array.isRequired,
        hovered: PropTypes.object,
        pinToMouse: PropTypes.bool
    };
    static defaultProps = {
        pinToMouse: false
    };

    render() {
        const { series, hovered, pinToMouse } = this.props;
        if (!hovered || !hovered.data || (pinToMouse ? !hovered.event : !hovered.element)) {
            return <span className="hidden" />;
        }
        let s = series[hovered.seriesIndex || 0];
        return (
            <TooltipPopover
                target={pinToMouse ? null : hovered.element}
                targetEvent={pinToMouse ? hovered.event : null}
                verticalAttachments={["bottom", "top"]}
            >
                <div className="py1 px2">
                    <div>{formatValue(hovered.data.key, s.data.cols[0], { jsx: true, majorWidth: 0 })}</div>
                    <div>{formatNumber(hovered.data.value)}</div>
                </div><commit_msg>Cleanup chart tooltips<commit_after>import React, { Component, PropTypes } from "react";

import TooltipPopover from "metabase/components/TooltipPopover.jsx"

import { formatValue } from "metabase/lib/formatting";
import { getFriendlyName } from "metabase/visualizations/lib/utils";

export default class ChartTooltip extends Component {
    constructor(props, context) {
        super(props, context);
        this.state = {};
    }

    static propTypes = {
        series: PropTypes.array.isRequired,
        hovered: PropTypes.object,
        pinToMouse: PropTypes.bool
    };
    static defaultProps = {
        pinToMouse: false
    };

    render() {
        const { series, hovered, pinToMouse } = this.props;
        if (!hovered || !hovered.data || (pinToMouse ? !hovered.event : !hovered.element)) {
            return <span className="hidden" />;
        }
        let s = series[hovered.seriesIndex || 0];
        return (
            <TooltipPopover
                target={pinToMouse ? null : hovered.element}
                targetEvent={pinToMouse ? hovered.event : null}
                verticalAttachments={["bottom", "top"]}
            >
                <table className="py1 px2">
                    <tbody>
                        { [["key", 0], ["value", 1]].map(([propName, colIndex]) =>
                            <tr key={propName} className="">
                                <th className="text-light text-right">{getFriendlyName(s.data.cols[colIndex])}:</th>
                                <th className="pl1 text-bold text-left">{formatValue(hovered.data[propName], s.data.cols[colIndex], { jsx: true, majorWidth: 0 })}</th>
                            </tr>
                        )}
                    </tbody>
                </table>
{'fraction_non_alphanumeric': 0.12612612612612611, 'fraction_numerical': 0.003861003861003861, 'mean_word_length': 1.9951830443159924, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '673484', 'n_tokens_mistral': 872, 'n_tokens_neox': 856, 'n_words': 178}