gitee 统计

为 gitee 贡献者列表添加扇形统计图

目前為 2022-05-16 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         gitee 统计
// @namespace    https://greasyfork.org/zh-CN/scripts/440111
// @version      0.0.4
// @description  为 gitee 贡献者列表添加扇形统计图
// @author       kj863257
// @include      *://gitee.com/*/contributors*
// @icon         https://gitee.com/assets/favicon.ico
// @grant        none
// @run-at       document-end
// @require      https://cdn.bootcdn.net/ajax/libs/echarts/5.3.0/echarts.min.js
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    $('.git-user-content').prepend('<div id="_charts" style="height:300px;"></div>');
    let arr = Array.from(document.querySelectorAll('.user-list-item')).map(e=>({name:e.querySelector('.username').innerText,value:e.querySelector('.sub-info').innerText.replace('Commits: ','')}))
    let option = {
        title: {
            text: '贡献比例',
            subtext: '',
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left',
        },
        series: [
            {
                name: '提交数量',
                type: 'pie',
                radius: '50%',
                data: arr,
                label:{            //饼图图形上的文本标签
                    normal:{
                        show:true,
                        position:'outside', //标签的位置
                        formatter:'{b} {d}%'
                    }
                },
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    var chartDom = document.getElementById('_charts');
    var myChart = echarts.init(chartDom);
    myChart.setOption(option);
})();