Change in Life Expectancy

HTML

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

<button id="showLabels" class="autocompare">Show all data label</button>
<button id="hideLabels" class="autocompare">Hide all data labels</button>
<button id="upperLabels" class="autocompare">Show uppper labels only</button>
<button id="lowerLabels" class="autocompare">Show lower labels only</button>

CSS

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

const data = [{
    name: 'Austria',
    low: 70.1,
    high: 81.3
}, {
    name: 'Belgium',
    low: 71.0,
    high: 81.9
},  {
    name: 'Czechia',
    low: 69.6,
    high: 77.4
}, {
    name: 'Estonia',
    low: 70.4,
    high: 76.9
}, {
    name: 'Greece',
    low: 73.8,
    high: 80.3
}, {
    name: 'Hungary',
    low: 69.2,
    high: 74.5
}, {
    name: 'Iceland',
    low: 73.8,
    high: 83.2
}, {
    name: 'Lithuania',
    low: 71.1,
    high: 74.5
}, {
    name: 'Norway',
    low: 74.3,
    high: 83.2
},  {
    name: 'Portugal',
    low: 66.7,
    high: 81.2
}, {
    name: 'Romania',
    low: 68.2,
    high: 72.9
},  {
    name: 'Slovakia',
    low: 69.8,
    high: 74.8
}, {
    name: 'Sweden',
    low: 74.7,
    high: 83.2
}, {
    name: 'Switzerland',
    low: 73.2,
    high: 84.0
}];

let myChart = Highcharts.chart('container', {

    chart: {
        type: 'dumbbell',
        inverted: true
    },

    legend: {
        enabled: false
    },

    subtitle: {
        text: '1970 vs 2021 Source: ' +
            '<a href="https://ec.europa.eu/eurostat/en/web/main/data/database"' +
            'target="_blank">Eurostat</a>'
    },

    title: {
        text: 'Change in Life Expectancy'
    },

    tooltip: {
        shared: true
    },

    xAxis: {
        type: 'category'
    },

    yAxis: {
        title: {
            text: 'Life Expectancy (years)'
        }
    },

    series: [{
        name: 'Life expectancy change',
        data: data,
        dataLabels: [{
        	enabled: true
        },
        {
        	enabled: false
        }]
    }]

});

  

document.getElementById('showLabels').addEventListener('click', () => {
										console.log("button clicked")
                    let updateConfig = {
    					series: [{
        					dataLabels: [{
        								enabled: true
       						 	},
        						{
        								enabled: true
        						}]
    							}]
                  };
                
                   ...