Available in the Full Version

Doughnut Chart - Bind to JSON

1990 Population
Top 5 largest countries by population (in millions)

This sample is designed for a larger screen size.

On mobile, try rotating your screen, view full size, or email to another device.

This is a basic example of the doughnut chart bound to JSON data.

Code View

Copy to Clipboard
<!DOCTYPE html>
<html>
<head>
    <title></title>

    <!-- Ignite UI for jQuery Required Combined CSS Files -->
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/infragistics.css" rel="stylesheet" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <!-- Ignite UI for jQuery Required Combined JavaScript Files -->
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.dv.js"></script>

</head>
    <body>
        <div style="text-align: center; width: 100%; font:16px Arial, Helvetica, sans-serif;">1990 Population</div>
        <div style="text-align: center; width: 100%; margin: 10px 0; font:12px Arial, Helvetica, sans-serif;">Top 5 largest countries by population (in millions)</div>

        <!-- Target element for the igDoughnutChart -->
        <div id="chart"></div>

        <script>
            $(function () {

                var data = [
                    { "CountryName": "China", "Pop1990": 1141 },
                    { "CountryName": "India", "Pop1990": 849 },
                    { "CountryName": "United States", "Pop1990": 250 },
                    { "CountryName": "Indonesia", "Pop1990": 178 },
                    { "CountryName": "Brazil", "Pop1990": 150 }
                ];

                $("#chart").igDoughnutChart({
                    width: "100%",
                    height: "550px",
                    series:
                    [{
                        name: "Pop1990",
                        labelMemberPath: "CountryName",
                        valueMemberPath: "Pop1990",
                        dataSource: data,
                        labelsPosition: "bestFit",
                        formatLabel: function (context) {
                            return context.itemLabel + " (" + context.item.Pop1990 + ")";
                        }
                    }]
                });
            });
        </script>

    </body>
</html>