Skip to content
Related Articles

Related Articles

How to create a Pie Chart using HTML & CSS ?
  • Last Updated : 11 Jun, 2020

Pie Chart is a type of graph that displays data in a circular shape and is generally used to show percentage or proportional data. The percentage represented in the graph by each category is provided near the corresponding slice of one portion of pie chart. These charts are very good for displaying data for two or more categories.

HTML Code: In the following code, the basic design or structure is shown.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
      "width=device-width, initial-scale=1.0">
    <title>Pie Chart</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1>Pie Chart</h1>
    <div class="piechart"></div>
</body>
</html>

chevron_right


CSS Code: In the following section, the design of pie-chart is demonstrated using some CSS properties.

filter_none

edit
close

play_arrow

link
brightness_4
code

<style>
    .piechart {
        margin-top: 300px;
        display: block;
        position: absolute;
        width: 400px;
        height: 400px;
        border-radius: 50%;
        background-image: conic-gradient(
            pink 70deg, 
            lightblue 0 235deg, 
            orange 0);
    }
  
    body,
    .piechart {
        display: flex;
        justify-content: center;
        align-items: center;
    }
</style>

chevron_right


Complete Code:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
  
    <title>Pie Chart</title>
  
    <style>
        .piechart {
            margin-top: 300px;
            display: block;
            position: absolute;
            width: 400px;
            height: 400px;
            border-radius: 50%;
            background-image: conic-gradient(
                pink 70deg, 
                lightblue 0 235deg, 
                orange 0);
        }
  
        body,
        .piechart {
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>
  
<body>
    <h1>Pie Chart</h1>
    <div class="piechart"></div>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :