Highcharts Demo

author(s): Torstein Hønsi

by Santosh Giridhara

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>

<div id="container"></div>

CSS

#container {
	max-width: 660px;
	margin: auto;
	height: 400px;
	margin: 0 auto;
}

JavaScript

var colors = Highcharts.getOptions().colors,
/* ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
    '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a'], */
    categories = [
        'Class Registered',
        'Class Attended'
    ],
    data = [
        {
            y: 60,
            color: colors[0],
            drilldown: {
                name: 'Class Registered',
                categories: [
                    'Yoga',
                    'Meditation',
                    'Zumba',
                    'Bodypump',
                    'TRX'
                ],
                data: [
                	10,
                	15,
                	10,
	               	15,
                 	10
                ]
            }
        },
        {
            y: 40,
            color: colors[9],
            drilldown: {
                name: 'Class Attended',
                categories: ['yoga','zumba'
                ],
                data: [
                20,20
                ]
            }
        }
    ],
    classReportData = [],
    classProgamData = [],
    i,
    j,
    dataLen = data.length,
    drillDataLen,
    brightness;


// Build the data arrays
for (i = 0; i < dataLen; i += 1) {

    // add browser data
    classReportData.push({
        name: categories[i],
        y: data[i].y,
        color: data[i].color
    });

    // add version data
    drillDataLen = data[i].drilldown.data.length;
    for (j = 0; j < drillDataLen; j += 1) {
        brightness = 0.2 - (j / drillDataLen) / 5;
        classProgamData.push({
            name: data[i].drilldown.categories[j],
            y: data[i].drilldown.data[j],
            color: Highcharts.Color(data[i].color).brighten(brightness).get()
        });
    }
}

// Create the chart
Highcharts.chart('container', {
    chart: {
        type: 'pie'
    },
    title: {
        text: ''
    },
    plotOptions: {
        pie: {
            shadow: false,
            center: ['50%', '50%']
        }
   ...