Open In App

Chart.js Radar Chart

Chart.js Radar Chart is used to present the multivariate data in a spider-web-like format, which allows us to properly analyze and compare more than one quantitative variable in parallel. Using the Radar chart we can properly display the patterns and relationships among the various categories, as each axis links to a specific data dimension.

Syntax

new Chart($("#ID"), {
    type: 'radar'          
    data: { ... },
    options: { ... }
});

Radar Chart Dataset Properties:

There are some of the dataset properties that are mentioned below:



Radar Chart Point Styling:

Radar Chart Line Styling:

CDN link

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js”></script>

<script src=”https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.1.2/chart.umd.js”></script>



Example 1: In the below example, we have implemented simple Radar Chart which represents the data related to GeeksforGeeks Skills. We have used one dataset to represent the information in the Radar Chart.




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0">
    <script src=
    </script>
    <script src=
    </script>
    <title>Radar Chart Example</title>
</head>
 
<body>
    <div>
        <h2 style="color:green">
            GeeksforGeeks
        </h2>
        <h5>Chart JS Radar Chart 1</h5>
        <div>
            <canvas id="radarChart"
                    width="700" height="300">
              </canvas>
        </div>
    </div>
    <script>
        let ctx =
            document.getElementById('radarChart').getContext('2d');
        let myRadarChart = new Chart(ctx, {
            type: 'radar',
            data: {
                labels:
                    ['Coding', 'Problem Solving', 'Algorithms',
                     'Data Structures', 'GeeksforGeeks Knowledge'],
                datasets: [{
                    label: 'GeeksforGeeks Skills',
                    data: [90, 85, 80, 75, 95],
                    backgroundColor: 'rgba(75, 192, 192, 0.2)',
                    borderColor: 'rgba(75, 192, 0, 1)',
                    borderWidth: 2,
                }]
            },
            options: {
                scale: {
                    pointLabels: {
                        fontSize: 14,
                    }
                }
            }
        });
    </script>
</body>
 
</html>

Output:

Example 2: In the below example, we have implemented the Radar Chart with more than 1 dataset. In the chart, we are representing the information about the User skills on the GeeksforGeeks platform. We have considered the two users and we have defined the 2 datasets for these users and represented them in a Radar chart.




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0">
    <script src=
    </script>
    <script src="
    </script>
    <title>Radar Chart Example</title>
</head>
 
<body>
    <div>
        <h2 style="color:green">
            GeeksforGeeks
        </h2>
        <h5>Chart JS Radar Chart 2</h5>
        <div>
            <canvas id="radarChart"
                    width="700" height="300">
              </canvas>
        </div>
    </div>
    <script>
        let ctx =
            document.getElementById('radarChart').getContext('2d');
        let myRadarChart = new Chart(ctx, {
            type: 'radar',
            data: {
                labels:
                    ['Coding', 'Problem Solving',
                     'Algorithms', 'Data Structures',
                     'GeeksforGeeks Knowledge'],
                datasets: [{
                    label: 'User A Skills',
                    data: [90, 85, 80, 75, 95],
                    backgroundColor: 'rgba(75, 192, 192, 0.2)',
                    borderColor: 'rgba(75, 192, 192, 1)',
                    borderWidth: 2,
                },
                {
                    label: 'User B Skills',
                    data: [80, 70, 90, 85, 80],
                    backgroundColor: 'rgba(255, 99, 132, 0.2)',
                    borderColor: 'rgba(255, 99, 132, 1)',
                    borderWidth: 2,
                }]
            },
            options: {
                scale: {
                    pointLabels: {
                        fontSize: 14,
                    }
                }
            }
        });
    </script>
</body>
 
</html>

Output:


Article Tags :