chartjs 王者榮耀能力雷達圖怎麼做

效果圖
數據是隨意填的
這裏寫圖片描述
代碼如下

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        #chart-wrapper {
            position: relative; 
            width: 400px;
            height: 400px;
        }
    </style>
</head>
<body>
    <div id="chart-wrapper">
        <canvas id="canvas"></canvas>
    </div>
    <script src="https://cdn.bootcss.com/Chart.js/2.4.0/Chart.min.js"></script>
    <script>
        //Get the context of the canvas element we want to select
        var ctx = document.getElementById('canvas').getContext('2d');

        var canvas = document.getElementById("canvas");
        var myRadarChart = new Chart(ctx, {
            "type": "radar",
            "data": {
                "labels": [
                    "綜合", 
                    "KDA", 
                    "生存", 
                    "團戰",
                    "發育",
                    "輸出"
                ],
                "datasets": [{
                    "label": "蓋亞",
                    "data": [65, 59, 90, 81, 56, 55],
                    "fill": true,
                    "backgroundColor": "rgba(255, 99, 132, 0.2)",
                    "borderColor": "rgb(255, 99, 132)",
                    "pointBackgroundColor": "rgb(255, 99, 132)",
                    "pointBorderColor": "#fff",
                    "pointHoverBackgroundColor": "#fff",
                    "pointHoverBorderColor": "rgb(255, 99, 132)",
                    "fill": true
                }, {
                    "label": "李白",
                    "data": [28, 48, 40, 19, 96, 27],
                    "fill": true,
                    "backgroundColor": "rgba(54, 162, 235, 0.2)",
                    "borderColor": "rgb(54, 162, 235)",
                    "pointBackgroundColor": "rgb(54, 162, 235)",
                    "pointBorderColor": "#fff",
                    "pointHoverBackgroundColor": "#fff",
                    "pointHoverBorderColor": "rgb(54, 162, 235)",
                    "fill": true
                }]
            },
            options: {
                scale: {
                    ticks: {
                    //最小刻度 最大刻度 刻度的步長(長度)
                        suggestedMin: 0,
                        suggestedMax: 100,
                        stepSize: 10
                    }
                }
            }
        });
    </script>
</body>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章