Accessible pie chart

author(s): Torstein Hønsi

by oysteinmoseng

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/pattern-fill.js"></script>
<script src="https://code.highcharts.com/themes/high-contrast-light.js"></script>

<div id="chart-wrap">
    <label id="patterns-enabled-label">
      <input type="checkbox" id="patterns-enabled" checked>
      Enable color patterns
    </label>

    <figure class="highcharts-figure">
        <div id="container"></div>
    </figure>
</div>

CSS

#patterns-enabled {
    width: 17px;
    height: 17px;
    vertical-align: middle;
    margin-top: 0;
    cursor: pointer;
}

#patterns-enabled-label {
    cursor: pointer;
}

#container {
    height: 420px;
}

#chart-wrap {
    min-width: 350px;
    max-width: 700px;
    margin: 1em auto;
    font-family: sans-serif;
}

.highcharts-figure,
.highcharts-data-table table {
    margin: 1em auto;
}

.highcharts-data-table table {
    font-family: Verdana, sans-serif;
    border-collapse: collapse;
    border: 1px solid #ebebeb;
    margin: 10px auto;
    text-align: center;
    width: 100%;
    max-width: 500px;
}

.highcharts-data-table caption {
    padding: 1em 0;
    font-size: 1.2em;
    color: #555;
}

.highcharts-data-table th {
    font-weight: 600;
    padding: 0.5em;
}

.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
    padding: 0.5em;
}

.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
    background: #f8f8f8;
}

.highcharts-data-table tr:hover {
    background: #f1f7ff;
}

JavaScript

var clrs = Highcharts.getOptions().colors;
var pieColors = [clrs[2], clrs[0], clrs[3], clrs[1], clrs[4]];

// Get a default pattern, but using the pieColors above.
// The i-argument refers to which default pattern to use
function getPattern(i) {
    return {
        pattern: Highcharts.merge(Highcharts.patterns[i], {
            color: pieColors[i]
        })
    };
}

// Get 5 patterns
var patterns = [0, 1, 2, 3, 4].map(getPattern);

var chart = Highcharts.chart('container', {
    chart: {
        type: 'column'
    },

    title: {
        text: 'Primary desktop/laptop screen readers'
    },

    colors: patterns,


    plotOptions: {
        series: {
            dataLabels: {
                enabled: true,
                connectorColor: '#777',
                format: '{point.y:.1f} %'
            },
            cursor: 'pointer',
            borderWidth: 3
        }
    },
    
    xAxis: {
	    type: 'category'
    },
    
    legend: {
    	enabled: false
    },

    series: [{
	    colorByPoint: true,
        name: 'Screen reader usage',
        data: [{
            name: 'NVDA',
            y: 40.6,
            website: 'https://www.nvaccess.org',
            accessibility: {
                description: 'This is the most used desktop screen reader'
            }
        }, {
            name: 'JAWS',
            y: 40.1,
            website: 'https://www.freedomscientific.com/Products/Blindness/JAWS'
        }, {
            name: 'VoiceOver',
            y: 12.9,
            website: 'http://www.apple.com/accessibility/osx/voiceover'
        }, {
            name: 'ZoomText',
            y: 2,
            website: 'http://www.zoomtext.com/products/zoomtext-magnifierreader'
        }, {
            name: 'Other',
            y: 4.4,
            website: 'http://www.disabled-world.com/assistivedevices/computer/screen-readers.php'
        }]
    }],

    responsive: {
        rules: [{
            condition: {
                maxWidth: 500
           ...