Deaths percentage of population within each age group

Up to 31 December of each year, 2011 - 2021

by Federico Ferraris Sánchez

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>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

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

CSS

#container {
    height: 570px; 
}

.highcharts-figure, .highcharts-data-table table {
    min-width: 310px; 
    max-width: 1250px;
    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

Highcharts.chart('container', {
    chart: {
        type: 'line'
    },
    exporting: {
      sourceWidth: 1200,
      sourceHeight: 600,
      allowHTML: true
    },
    title: {
        text: 'Deaths percentage of population within each age group 2011 - 2021'
    },
    subtitle: {
        text: 'Up to 31 December of each year'
    },
    legend: {
        layout: 'horizontal',
        align: 'center',
        verticalAlign: 'bottom',
        borderWidth: 1,
        backgroundColor:
            Highcharts.defaultOptions.legend.backgroundColor || '#FFFFFF'
    },
    xAxis: {
    		title: {
        	text: 'Year'
        },
        categories: [
            2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
        ]
    },
    yAxis: {
        title: {
            text: 'Proportion within the age group'
        },
        tickAmount: 13,
        labels: {
            format: '{value} %'
        }
    },
    tooltip: {
        shared: true
        //,valueSuffix: ' units'
    },
    credits: {
        enabled: false
    },
    plotOptions: {
      series: {
            marker: {
                radius: 2.5
            },
      	groupPadding: 10.2,
        dataLabels: {
          enabled: true,
          style: {
          	fontSize: '11px',
            fontWeight: 'bold'
          },
          formatter: function() {
            var sRet;
						
            switch(this.series.index){
            	case 1:
            	case 3:
            	case 4:
            	case 6:
            	case 7: if (this.x != 2019) { sRet = this.y; } break;
              default:
                sRet = this.y;
                break;
            }

            return sRet;
          },
          allowOverlap: true
        }
      }
    },
    series: [{
        name: 'Percentage for 0-59',
      	color: 'rgba(29, 40, 189, .7)',
        data: [0.16,0.16,0.16,0.16,0.16,0.16,0.15,0.15,0.15,null,null],
        dataLabels: {
          color: 'rgba(29, 40, 189, .7)',
           ...