AtCoderHeuristicContestBarChart

横軸を順位、縦軸を総スコアとする棒グラフを、順位表上部に出力

目前為 2023-10-13 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AtCoderHeuristicContestBarChart
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  横軸を順位、縦軸を総スコアとする棒グラフを、順位表上部に出力
// @author       pitP
// @license      MIT
// @match        https://atcoder.jp/contests/ahc*/standings*
// @require      https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js
// ==/UserScript==

(function () {
    'use strict';
    $('#vue-standings').prepend(`
    <div>
    <canvas id='BarChart'></canvas>
    </div>
    `);

    vueStandings.$watch('standings', function (newVal, oldVal) {
        if (!newVal) {
            return;
        }
        var data;
        var task = newVal.TaskInfo;
        if (vueStandings.filtered) {
            data = vueStandings.filteredStandings;
        }
        else {
            data = newVal.StandingsData;
        }


        const target_user = data.filter(item => item.TotalResult.Count > 0);
        const rank = Array.from({ length: target_user.length }, (_, i) => i + 1);
        const score = target_user.map(item => item.TotalResult.Score / 100);

        var ctx = document.getElementById("BarChart");
        var BarChart = new Chart(ctx, {
            type: 'bar',
            data: {
                labels: rank,
                datasets: [
                    {
                        label: 'TotalScore',
                        data: score,
                        backgroundColor: "rgba(0, 255, 0, 1)",
                    }
                ]
            },
        });
    }, { deep: true, immediate: true })
})();