Statistics circles in donut chart - Javascript Chart.js

Javascript examples for Chart.js:Chart Configuration

Description

Statistics circles in donut chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>jQuery Donut Chart</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
      <script type="text/javascript" src="http://www.jqwidgets.com/public/2.4.0/jqxcore.js"></script> 
      <script type="text/javascript" src="http://www.jqwidgets.com/public/2.4.0/jqxdata.js"></script> 
      <script type="text/javascript" src="http://www.jqwidgets.com/public/2.4.0/jqxchart.js"></script> 
      <link rel="stylesheet" type="text/css" href="http://www.jqwidgets.com/public/2.4.0/styles/jqx.base.css"> 
      <script type="text/javascript">
    $(window).load(function(){/*from ww  w .jav  a2 s. c  om*/
var data = [
    {Browser: "Internet Explorer", Share: 33.3},
    {Browser: "Firefox", Share: 26.5},
    {Browser: "Chrome", Share: 25.4},
    {Browser: "Safari", Share:7.0},
    {Browser: "Opera", Share:4.6},
    {Browser: "Other", Share:3.2}
]
// prepare chart data as an array
var source =
{
    datatype: "array",
    datafields: [
        { name: 'Browser' },
        { name: 'Share' }
    ],
    localdata: data
};
var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, loadError: function (xhr, status, error) { console.log('Error loading "' + source.url + '" : ' + error); } });
// prepare jqxChart settings
var settings = {
    title: "Desktop browsers share in Dec 2011",
    description: "(source: wikipedia.org)",
    enableAnimations: true,
    showLegend: false,
    legendPosition: { left: 520, top: 140, width: 100, height: 100 },
    padding: { left: 5, top: 5, right: 5, bottom: 5 },
    titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },
    source: dataAdapter,
    colorScheme: 'scheme02',
    seriesGroups:
        [
            {
                type: 'donut',
                showLabels: true,
                series:
                    [
                        {
                            dataField: 'Share',
                            displayText: 'Browser',
                            labelRadius: 150,
                            initialAngle: 15,
                            radius: 130,
                            innerRadius: 120,
                            centerOffset: 0,
                            formatSettings: { sufix: '%', decimalPlaces: 1 }
                        }
                    ]
            }
        ]
};
// setup the chart
$('#jqxChart').jqxChart(settings);
    });

      </script> 
   </head> 
   <body> 
      <div id="jqxChart" style="width: 680px; height: 400px; position: relative; left: 0px;
    top: 0px;"> 
      </div>  
   </body>
</html>

Related Tutorials