{"size": 968, "ext": "js", "max_stars_repo_path": "client-presentation/src/components/reports/chart-data.service.js", "max_stars_repo_name": "michalczukm/mobile-web-do", "max_stars_repo_stars_event_min_datetime": "2018-02-27T19:59:58.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-11T06:17:44.000Z", "max_issues_repo_path": "client-presentation/src/components/reports/chart-data.service.js", "max_issues_repo_name": "michalczukm/mobile-web-do", "max_issues_repo_issues_event_min_datetime": "2018-09-06T09:26:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-02T02:22:40.000Z", "max_forks_repo_path": "client-presentation/src/components/reports/chart-data.service.js", "max_forks_repo_name": "michalczukm/mobile-web-do", "max_forks_repo_forks_event_min_datetime": "2018-09-05T20:04:53.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-05T20:04:53.000Z"}
{"max_stars_count": 2, "max_issues_count": 39, "max_forks_count": 1, "avg_line_length": 27.6571428571, "max_line_length": 99, "alphanum_fraction": 0.5733471074}
import colorsSet from '../reports/colors-set';
import { supportStatus } from '../../features/support-status';

const mapStatisticsToChartData = statistics => {
    return {
        labels: statistics.map(stat => stat.family),
        datasets: [
            {
                backgroundColor: colorsSet.getColorsSet(),
                data: statistics.map(stat => stat.quantity),
            },
        ],
    };
};

const mapStatusesToChartData = statuses => {
    const refs = [supportStatus.STANDARD, supportStatus.VENDOR_SPECIFIC, supportStatus.NO_SUPPORT];
    const data = refs.map(ref => statuses.filter(status => status === ref).length);

    return {
        labels: ['Standard', 'Vendor specific', 'No support'],
        datasets: [
            {
                backgroundColor: ['#97D100', '#E8AB19', '#E85E39'],
                data: data,
            },
        ],
    };
};

export default {
    mapStatisticsToChartData,
    mapStatusesToChartData,
};
