Euro indicators 15 July 2024 Next release: 14 August 2024
May 2024 compared with April 2024
Skip to the content
Down by 2.9% in the euro area and by 2.5% in the EU compared with May 2023
Overview
In May 2024, compared with April 2024, seasonally adjusted industrial production decreased by 0.6% in the euro area and by 0.8% in the EU, according to first estimates from Eurostat, the statistical office of the European Union. In April 2024, industrial production remained unchanged in the euro area and grew by 0.5% in the EU.
In May 2024, compared with May 2023, industrial production decreased by 2.9% in the euro area and by 2.5% in the EU.
Monthly comparison by main industrial grouping and by Member State
In the euro area in May 2024, compared with April 2024, industrial production
decreased by 1.0% for intermediate goods,
increased by 0.8% for energy,
decreased by 1.2% for capital goods,
decreased by 1.8% for durable consumer goods,
increased by 1.6% for non-durable consumer goods.
In the EU, industrial production
decreased by 1.0% for intermediate goods,
increased by 0.4% for energy,
decreased by 1.2% for capital goods,
decreased by 2.1% for durable consumer goods,
increased by 0.8% for non-durable consumer goods.
The largest monthly decreases were recorded in Slovenia (-7.3%), Romania (-6.2%) and Denmark (-4.9%). The highest increases were observed in Ireland (+6.7%), Luxembourg (+3.9%) and Estonia (+3.8%).
Annual comparison by main industrial grouping and by Member State
In the euro area in May 2024, compared with May 2023, industrial production
decreased by 3.5% for intermediate goods,
increased by 0.7% for energy,
decreased by 6.5% for capital goods,
decreased by 4.2% for durable consumer goods,
increased by 2.8% for non-durable consumer goods.
In the EU, industrial production
decreased by 3.1% for intermediate goods,
increased by 1.2% for energy,
decreased by 6.3% for capital goods,
decreased by 4.1% for durable consumer goods,
increased by 3.3% for non-durable consumer goods.
The largest annual decreases were recorded in Romania (-6.9%), Germany (-6.6%) and Bulgaria (-6.3%). The highest increases were observed in Denmark (+9.6%), Ireland (+8.7%) and Greece (+6.8%).
Tables
Industrial production % change compared with previous month* | ||||||
---|---|---|---|---|---|---|
Dec-23 | Jan-24 | Feb-24 | Mar-24 | Apr-24 | May-24 | |
Euro area | ||||||
Total industry | 1.5 | -2.2 | 0.0 | 0.5 | 0.0 | -0.6 |
Intermediate goods | -1.4 | 2.2 | 0.4 | -0.3 | -0.3 | -1.0 |
Energy | 0.3 | 1.1 | -3.2 | -0.1 | -0.2 | 0.8 |
Capital goods | 11.4 | -15.4 | 1.9 | 0.9 | 0.7 | -1.2 |
Durable consumer goods | 0.1 | -1.4 | 1.2 | -0.6 | 0.4 | -1.8 |
Non-durable consumer goods | -0.4 | -0.4 | -0.4 | -2.7 | 3.6 | 1.6 |
EU | ||||||
Total industry | 1.3 | -2.0 | 0.2 | 0.0 | 0.5 | -0.8 |
Intermediate goods | -0.8 | 1.4 | 0.8 | -0.3 | -0.3 | -1.0 |
Energy | 0.5 | 0.8 | -3.3 | 0.2 | 0.0 | 0.4 |
Capital goods | 10.3 | -13.7 | 1.7 | 0.6 | 0.5 | -1.2 |
Durable consumer goods | 0.3 | -1.3 | 1.4 | -0.6 | 0.9 | -2.1 |
Non-durable consumer goods | -0.4 | -0.5 | -0.1 | -2.6 | 4.0 | 0.8 |
* Calendar and seasonally adjusted Source dataset: sts_inpr_m |
Industrial production % change compared with previous month* | ||||||
---|---|---|---|---|---|---|
Dec-23 | Jan-24 | Feb-24 | Mar-24 | Apr-24 | May-24 | |
Euro area | 1.5 | -2.2 | 0.0 | 0.5 | 0.0 | -0.6 |
EU | 1.3 | -2.0 | 0.2 | 0.0 | 0.5 | -0.8 |
Belgium | 5.2 | -3.4 | 0.2 | 3.7 | 0.3 | 2.5 |
Bulgaria | 4.0 | -4.1 | 0.2 | -0.4 | 2.8 | -3.4 |
Czechia | 3.0 | -3.1 | 2.1 | -1.7 | 0.6 | -2.2 |
Denmark | -0.5 | -0.9 | 1.2 | -2.5 | 10.5 | -4.9 |
Germany | -2.1 | 1.0 | 0.7 | -0.3 | 0.4 | -2.4 |
Estonia | 5.1 | -8.3 | 2.4 | 1.2 | -1.6 | 3.8 |
Ireland** | 20.1 | -20.0 | -5.0 | 10.7 | -3.3 | 6.7 |
Greece | 0.9 | 3.5 | -1.8 | -1.6 | 7.5 | -3.1 |
Spain | -1.0 | 1.0 | 1.2 | -1.3 | -0.1 | -0.2 |
France | 0.3 | -1.2 | 0.4 | -0.2 | 0.6 | -2.1 |
Croatia | -4.2 | -0.3 | -2.5 | 0.5 | 0.0 | 2.5 |
Italy | 1.2 | -1.5 | 0.0 | -0.5 | -1.0 | 0.5 |
Cyprus | 0.6 | -0.5 | 0.7 | 2.2 | -1.7 | 1.9 |
Latvia | 1.2 | -1.5 | 2.2 | -0.7 | -4.8 | 3.1 |
Lithuania | -2.6 | 3.9 | -2.8 | 4.0 | 3.9 | -1.3 |
Luxembourg | 1.2 | -2.4 | -1.1 | 4.7 | -6.3 | 3.9 |
Hungary | 0.4 | -0.9 | 3.4 | -3.2 | -0.7 | -1.0 |
Malta | 5.5 | -9.2 | 3.1 | 2.4 | 0.6 | 1.3 |
Netherlands | 3.3 | -2.6 | 1.0 | -0.9 | 0.5 | -0.4 |
Austria | 2.2 | -1.9 | -0.2 | 0.3 | 0.5 | -2.1 |
Poland | 0.2 | 0.5 | 0.0 | -5.1 | 6.7 | -2.6 |
Portugal | -1.9 | 3.0 | 0.6 | 2.9 | -2.1 | -3.3 |
Romania | 1.6 | -3.4 | 3.3 | 4.0 | -1.8 | -6.2 |
Slovenia | -8.8 | 8.8 | 3.2 | -6.3 | 10.0 | -7.3 |
Slovakia | 3.3 | -2.4 | 1.3 | -1.5 | 2.4 | -1.4 |
Finland | -3.1 | 3.5 | -0.2 | -4.7 | 0.4 | 1.1 |
Sweden | 1.1 | -0.4 | -0.7 | 0.5 | -2.6 | 1.4 |
Norway | 1.4 | 1.8 | -4.3 | 3.8 | -0.5 | 0.2 |
Switzerland | 2.5 | -1.8 | -0.8 | 2.3 | : | : |
* Calendar and seasonally adjusted **CSO Ireland is carrying out a review of the seasonal adjustment methodology for industrial production. : Data not available Source dataset: sts_inpr_m |
Industrial production % change compared with same month of the previous year* | ||||||
---|---|---|---|---|---|---|
Dec-23 | Jan-24 | Feb-24 | Mar-24 | Apr-24 | May-24 | |
Euro area | ||||||
Total industry | 0.2 | -6.5 | -6.3 | -1.2 | -3.1 | -2.9 |
Intermediate goods | -3.6 | -3.1 | -2.8 | -2.8 | -2.1 | -3.5 |
Energy | -1.9 | 0.7 | -3.4 | -2.1 | -1.9 | 0.7 |
Capital goods | 4.6 | -10.9 | -9.1 | 1.7 | -5.2 | -6.5 |
Durable consumer goods | -3.0 | -7.6 | -4.2 | -7.7 | -3.1 | -4.2 |
Non-durable consumer goods | -5.2 | -3.7 | -5.0 | -7.2 | 0.6 | 2.8 |
EU | ||||||
Total industry | 0.3 | -5.4 | -5.2 | -1.1 | -2.1 | -2.5 |
Intermediate goods | -3.7 | -3.6 | -2.7 | -2.5 | -1.8 | -3.1 |
Energy | -1.0 | 0.9 | -3.3 | -1.6 | -1.3 | 1.2 |
Capital goods | 4.3 | -9.3 | -7.9 | 1.3 | -4.8 | -6.3 |
Durable consumer goods | -4.2 | -7.6 | -4.1 | -6.9 | -2.3 | -4.1 |
Non-durable consumer goods | -2.9 | -1.6 | -3.4 | -5.0 | 2.8 | 3.3 |
* Calendar adjusted Source dataset: sts_inpr_m |
Industrial production % change compared with same month of the previous year* | ||||||
---|---|---|---|---|---|---|
Dec-23 | Jan-24 | Feb-24 | Mar-24 | Apr-24 | May-24 | |
Euro area | 0.2 | -6.5 | -6.3 | -1.2 | -3.1 | -2.9 |
EU | 0.3 | -5.4 | -5.2 | -1.1 | -2.1 | -2.5 |
Belgium | -5.1 | -4.1 | -7.8 | -5.9 | 2.8 | 2.6 |
Bulgaria | -5.4 | -9.2 | -8.0 | -7.7 | -0.3 | -6.3 |
Czechia | -0.3 | -0.3 | 0.7 | -2.9 | -0.4 | -3.2 |
Denmark | 8.6 | 8.4 | 4.6 | 4.0 | 18.4 | 9.6 |
Germany | -4.5 | -5.1 | -6.4 | -5.0 | -3.7 | -6.6 |
Estonia | -3.4 | -10.2 | -5.3 | -5.6 | -4.8 | -1.3 |
Ireland | 36.0 | -32.1 | -35.9 | 38.5 | -15.9 | 8.7 |
Greece | 4.6 | 10.4 | 1.9 | -0.6 | 11.8 | 6.8 |
Spain | -2.0 | 0.4 | 3.7 | -0.3 | 0.3 | 0.2 |
France | 0.7 | 0.9 | -0.6 | 0.6 | 1.2 | -3.2 |
Croatia | -1.0 | -1.4 | -5.2 | -5.0 | -2.0 | -3.3 |
Italy | -1.5 | -3.7 | -3.4 | -3.3 | -3.0 | -3.3 |
Cyprus | 2.6 | 1.9 | 2.2 | 8.1 | 2.9 | 5.0 |
Latvia | -1.3 | -2.6 | 1.1 | 0.5 | -7.8 | -0.9 |
Lithuania | -5.1 | -0.3 | -1.0 | 2.3 | 2.3 | 4.7 |
Luxembourg | -1.6 | -4.2 | -7.9 | -0.9 | -5.5 | -1.1 |
Hungary | -7.4 | -3.6 | 1.8 | -3.1 | -2.5 | -4.9 |
Malta | 8.2 | -4.9 | -3.6 | -0.2 | 3.1 | 1.2 |
Netherlands | -1.3 | -2.5 | -1.1 | -3.8 | -1.9 | -1.6 |
Austria | -1.4 | -4.7 | -6.0 | -4.5 | -3.5 | -6.2 |
Poland | -0.5 | 1.0 | 1.2 | -3.1 | 4.7 | -0.4 |
Portugal | -5.2 | -1.7 | 1.0 | 4.2 | 5.1 | 0.6 |
Romania | 1.0 | -4.1 | -1.7 | 3.7 | 3.7 | -6.9 |
Slovenia | -11.0 | -3.6 | 2.6 | -7.4 | 12.9 | -5.0 |
Slovakia | 4.9 | 3.5 | 0.1 | -6.9 | 6.2 | 0.0 |
Finland | -7.6 | -1.0 | 1.5 | -9.1 | -6.4 | -5.3 |
Sweden | 2.7 | -1.6 | -2.7 | 2.7 | -3.5 | -0.7 |
Norway | 7.7 | 8.3 | 1.7 | 4.6 | 3.5 | 5.9 |
Switzerland | -0.9 | -2.1 | -2.0 | -3.8 | : | : |
* Calendar adjusted : Data not available Source dataset: sts_inpr_m |
Production indices for total industry, calendar and seasonally adjusted (base year 2021) | ||||||
---|---|---|---|---|---|---|
Dec-23 | Jan-24 | Feb-24 | Mar-24 | Apr-24 | May-24 | |
Euro area | 99.5 | 97.3 | 97.3 | 97.8 | 97.8 | 97.2 |
EU | 100.8 | 98.8 | 99.0 | 99.0 | 99.5 | 98.7 |
Belgium | 93.1 | 89.9 | 90.1 | 93.4 | 93.7 | 96.0 |
Bulgaria | 102.8 | 98.6 | 98.8 | 98.4 | 101.2 | 97.8 |
Czechia | 102.8 | 99.6 | 101.7 | 100.0 | 100.6 | 98.4 |
Denmark | 129.0 | 127.8 | 129.3 | 126.1 | 139.3 | 132.5 |
Germany | 93.3 | 94.2 | 94.9 | 94.6 | 95.0 | 92.7 |
Estonia | 92.0 | 84.4 | 86.4 | 87.4 | 86.0 | 89.3 |
Ireland* | 122.9 | 98.3 | 93.4 | 103.4 | 100.0 | 106.7 |
Greece | 106.4 | 110.1 | 108.1 | 106.4 | 114.4 | 110.9 |
Spain | 100.7 | 101.7 | 102.9 | 101.6 | 101.5 | 101.3 |
France | 101.3 | 100.1 | 100.5 | 100.3 | 100.9 | 98.8 |
Croatia | 98.9 | 98.6 | 96.1 | 96.6 | 96.6 | 99.0 |
Italy | 97.4 | 95.9 | 95.9 | 95.4 | 94.4 | 94.9 |
Cyprus | 106.5 | 106.0 | 106.7 | 109.1 | 107.2 | 109.2 |
Latvia | 96.1 | 94.7 | 96.8 | 96.1 | 91.5 | 94.3 |
Lithuania | 98.4 | 102.2 | 99.3 | 103.3 | 107.3 | 105.9 |
Luxembourg | 93.0 | 90.8 | 89.8 | 94.0 | 88.1 | 91.5 |
Hungary | 98.7 | 97.8 | 101.1 | 97.9 | 97.2 | 96.2 |
Malta | 114.9 | 104.3 | 107.5 | 110.1 | 110.8 | 112.2 |
Netherlands | 103.2 | 100.5 | 101.5 | 100.6 | 101.1 | 100.7 |
Austria | 102.6 | 100.7 | 100.5 | 100.8 | 101.3 | 99.2 |
Poland | 110.3 | 110.8 | 110.8 | 105.2 | 112.3 | 109.4 |
Portugal | 97.1 | 100.0 | 100.6 | 103.5 | 101.3 | 98.0 |
Romania | 99.2 | 95.8 | 99.0 | 103.0 | 101.1 | 94.8 |
Slovenia | 89.0 | 96.8 | 99.9 | 93.6 | 103.0 | 95.5 |
Slovakia | 99.1 | 96.7 | 98.0 | 96.5 | 98.8 | 97.4 |
Finland | 97.9 | 101.3 | 101.1 | 96.3 | 96.7 | 97.8 |
Sweden | 103.1 | 102.7 | 102.0 | 102.5 | 99.8 | 101.2 |
Norway | 103.4 | 105.3 | 100.8 | 104.6 | 104.1 | 104.3 |
Switzerland | 108.4 | 106.4 | 105.6 | 108.0 | : | : |
* CSO Ireland is carrying out a review of the seasonal adjustment methodology for industrial production. : Data not available Source dataset: sts_inpr_m |
Production indices for total industry, calendar adjusted (base year 2021) | ||||||
---|---|---|---|---|---|---|
Dec-23 | Jan-24 | Feb-24 | Mar-24 | Apr-24 | May-24 | |
Euro area | 95.1 | 94.2 | 94.6 | 104.4 | 96.5 | 95.9 |
EU | 96.8 | 95.7 | 96.3 | 106.1 | 98.3 | 97.5 |
Belgium | 91.5 | 86.5 | 86.6 | 101.6 | 89.6 | 95.1 |
Bulgaria | 105.4 | 93.7 | 93.6 | 101.5 | 98.5 | 93.2 |
Czechia | 95.3 | 95.8 | 98.1 | 107.9 | 100.0 | 99.8 |
Denmark | 133.8 | 129.3 | 124.8 | 134.0 | 135.8 | 131.7 |
Germany | 89.3 | 88.0 | 92.8 | 103.0 | 93.6 | 90.7 |
Estonia | 88.4 | 80.9 | 81.5 | 93.1 | 86.0 | 93.3 |
Ireland | 116.8 | 105.1 | 71.9 | 91.0 | 98.3 | 89.1 |
Greece | 106.7 | 100.6 | 106.0 | 108.1 | 113.6 | 111.5 |
Spain | 92.3 | 100.2 | 104.9 | 107.6 | 101.7 | 106.5 |
France | 102.7 | 103.3 | 100.4 | 109.0 | 100.5 | 93.7 |
Croatia | 95.1 | 90.2 | 93.0 | 103.2 | 96.6 | 101.5 |
Italy | 86.1 | 90.6 | 98.6 | 105.8 | 93.1 | 101.9 |
Cyprus | 107.0 | 97.4 | 101.0 | 109.6 | 103.7 | 113.8 |
Latvia | 102.1 | 74.5 | 83.5 | 96.8 | 88.9 | 97.1 |
Lithuania | 98.7 | 98.3 | 93.7 | 105.8 | 103.8 | 108.5 |
Luxembourg | 86.0 | 86.5 | 88.9 | 103.9 | 90.1 | 91.0 |
Hungary | 89.5 | 92.7 | 102.3 | 105.5 | 95.5 | 97.3 |
Malta | 101.5 | 99.2 | 101.4 | 114.8 | 108.4 | 115.1 |
Netherlands | 104.1 | 98.0 | 97.8 | 107.6 | 99.4 | 100.4 |
Austria | 102.8 | 91.2 | 96.2 | 110.4 | 100.6 | 97.9 |
Poland | 106.6 | 106.1 | 107.5 | 115.2 | 111.2 | 107.8 |
Portugal | 89.0 | 101.6 | 98.0 | 110.0 | 99.4 | 101.5 |
Romania | 94.5 | 91.3 | 94.9 | 108.7 | 99.2 | 97.8 |
Slovenia | 80.1 | 92.9 | 97.0 | 103.2 | 101.8 | 99.4 |
Slovakia | 87.6 | 96.6 | 100.1 | 100.9 | 99.9 | 102.8 |
Finland | 107.4 | 99.2 | 95.7 | 101.1 | 95.5 | 97.8 |
Sweden | 105.8 | 101.0 | 101.7 | 116.8 | 100.6 | 100.9 |
Norway | 109.9 | 115.9 | 100.4 | 112.2 | 103.5 | 100.9 |
Switzerland | 107.6 | 103.4 | 99.4 | 120.2 | : | : |
: Data not available Source dataset: sts_inpr_m |
Notes for users
Revisions and timetable
Compared with data issued in the News Release of 13 June 2024, the monthly percentage change for April 2024 has been revised from -0.1% to 0.0% in the euro area and remained unchanged at +0.5% in the EU. The annual percentage change has been revised from -3.0% to -3.1% in the euro area and from -2.0% to -2.1% in the EU.
Methods and definitions
The index of industrial production measures the evolution of the volume of production for industry excluding construction, based on data adjusted for calendar and seasonal effects.
Seasonally adjusted euro area and EU series are calculated by aggregating the seasonally adjusted national data.
Total industry covers NACE rev.2 sections B to D. Missing observations from Member States for recent months are estimated for the calculation of the euro area and the EU aggregates.
Starting with reference period January 2024, the base year of the data has been changed to 2021, since 2018 the base year had been 2015. More information on the reasons for and impact of the base year change can be found in the related Statistics Explained article.
Geographical information
The euro area (EA20) includes Belgium, Germany, Estonia, Ireland, Greece, Spain, France, Croatia, Italy, Cyprus, Latvia, Lithuania, Luxembourg, Malta, the Netherlands, Austria, Portugal, Slovenia, Slovakia and Finland.
The European Union (EU27) includes Belgium, Bulgaria, Czechia, Denmark, Germany, Estonia, Ireland, Greece, Spain, France, Croatia, Italy, Cyprus, Latvia, Lithuania, Luxembourg, Hungary, Malta, the Netherlands, Austria, Poland, Portugal, Romania, Slovenia, Slovakia, Finland and Sweden.
For more information
Database section on short-term business statistics
Statistics Explained article on the industrial production index
The weights of the Member States in the EU and euro area aggregates
(see file Base year 2021 weights - Euro indicators releases)Euro indicators dashboard
Release calendar for Euro indicators
European Statistics Code of Practice
Get in touch
Media requests
Eurostat Media Support
Phone: (+352) 4301 33 408
E-mail: eurostat-mediasupport@ec.europa.eu
Further information on data
E-mail: ESTAT-STS-DATA@ec.europa.eu
Share component will be rendered here.
'; /** Retrieve the order from the tooltip option */ var sortOrder = option.tooltip.order; /** Sort the 'params' array based on the 'sortOrder' parameter. */ switch (sortOrder) { /** Sort by series name in ascending order. */ case 'seriesAsc': params = params.sort((a, b) => a.seriesName.localeCompare(b.seriesName)); break; /** Sort by series name in descending order. */ case 'seriesDesc': params = params.sort((a, b) => b.seriesName.localeCompare(a.seriesName)); break; /** Sort by numerical value in ascending order. */ case 'valueAsc': params = params.sort((a, b) => parseFloat(a.value) - parseFloat(b.value)); break; /** Sort by numerical value in descending order. */ case 'valueDesc': params = params.sort((a, b) => parseFloat(b.value) - parseFloat(a.value)); break; /** Reverse the current order. */ case 'reverse': params.reverse(); break; default: break; } /** Iterate over each series in the tooltip parameters */ for (var i = 0; i < params.length; i++) { /** Retrieve the name and value of the current series */ var seriesName = params[i].seriesName; var value = params[i].value; /** Replace every specific apostrphe by simple one. */ seriesName = seriesName.replaceAll("’", "'"); /** Convert the numeric value to its string representation. */ var strValue = String(value); /** Retrieve the axis used as value */ var axis = option.yAxis.type === 'value' ? option.yAxis : option.xAxis; /** Initialize the number of decimal places */ var decimals = option.tooltip.decimals; /** Check if decimals configuration is set to default and the value contains decimal places */ if (!decimals && strValue.indexOf('.') > -1) { /** Calculate the number of decimal places */ decimals = strValue.substring(strValue.indexOf('.'), strValue.length - 1).length; } else { /** If there are no decimal places, format the value with 1 decimal place */ decimals = decimals ? decimals : 1; /** Convert the value to a fixed-point notation string with a specified number of decimal places. */ value = Number(value).toFixed(decimals); } /** Convert -0 value to 0 with the specified or calculated number of decimal places.*/ if (Number(value) == -0) { value = (Number(value) + 0).toFixed(decimals); } /** Extract the unit from within the axis label */ var unit = axis.axisLabel.unit ? axis.axisLabel.unit : ''; /** Format the value using the appropriate number of decimal places */ value = isNaN(value) ? 'N/A' : Number(value).toLocaleString(option.lang ? option.lang : 'en', { minimumFractionDigits: decimals }) + unit; /** Retrieve the color of the current series */ const color = params[i].color; /** * Add the series name and value to the tooltip content * Use a circle icon with the series color */ tooltipContent += '
' + '' + '' + '' + seriesName + '' + '' + '' + value + '' + '
'; } /** Close the tooltip content container */ tooltipContent += '
'; /** Return the formatted tooltip content */ return tooltipContent; }}/* * This content is licensed according to the W3C Software License at * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document * * File: sortable-table.js * * Desc: Adds sorting to a HTML data table that implements ARIA Authoring Practices */'use strict';class SortableTable { constructor(tableNode) { this.tableNode = tableNode; this.columnHeaders = tableNode.querySelectorAll('thead th.sortable'); this.sortColumns = []; for (var i = 0; i < this.columnHeaders.length; i++) { var ch = this.columnHeaders[i]; var buttonNode = ch.querySelector('button'); if (buttonNode) { this.sortColumns.push(i); // buttonNode.setAttribute('data-column-index', i); // buttonNode.addEventListener('click', this.handleClick.bind(this)); ch.setAttribute('data-column-index', i); ch.addEventListener('click', this.handleClick.bind(this)); } } this.optionCheckbox = document.querySelector( 'input[type="checkbox"][value="show-unsorted-icon"]' ); if (this.optionCheckbox) { this.optionCheckbox.addEventListener( 'change', this.handleOptionChange.bind(this) ); if (this.optionCheckbox.checked) { this.tableNode.classList.add('show-unsorted-icon'); } } } setColumnHeaderSort(columnIndex) { if (typeof columnIndex === 'string') { columnIndex = parseInt(columnIndex); } for (var i = 0; i < this.columnHeaders.length; i++) { var ch = this.columnHeaders[i]; var buttonNode = ch.querySelector('button'); if (i === columnIndex) { var value = ch.getAttribute('aria-sort'); if (value === 'ascending') { ch.setAttribute('aria-sort', 'descending'); this.sortColumn( columnIndex, 'descending', ch.classList.contains('num')); } else if (value === 'descending') { ch.removeAttribute('aria-sort'); this.sortColumn( columnIndex, 'initial', true ); } else { ch.setAttribute('aria-sort', 'ascending'); this.sortColumn( columnIndex, 'ascending', ch.classList.contains('num') ); } } else { if (ch.hasAttribute('aria-sort') && buttonNode) { ch.removeAttribute('aria-sort'); } } } } sortColumn(columnIndex, sortValue, isNumber) { function compareValues(a, b) { if (a.value === b.value) return 0; if (sortValue === 'descending') { return isNumber ? b.value - a.value : (a.value > b.value ? -1 : 1); } else { return isNumber ? a.value - b.value : (a.value < b.value ? -1 : 1); } } if (typeof isNumber !== 'boolean') { isNumber = false; } var tbodyNode = this.tableNode.querySelector('tbody'); var rowNodes = []; var dataCells = []; var rowNode = tbodyNode.firstElementChild; var index = 0; while (rowNode) { rowNodes.push(rowNode); var rowCells = rowNode.querySelectorAll('th, td'); var dataCell = rowCells[columnIndex]; var data = {}; data.index = index; if (sortValue !== 'initial') { data.value = dataCell.textContent.toLowerCase().trim(); } else { data.value = rowNode.getAttribute('initial-position').toLowerCase().trim(); } if (isNumber) { data.value = parseFloat(data.value); } dataCells.push(data); rowNode = rowNode.nextElementSibling; index += 1; } dataCells.sort(compareValues); // remove rows while (tbodyNode.firstChild) { tbodyNode.removeChild(tbodyNode.lastChild); } // add sorted rows for (var i = 0; i < dataCells.length; i += 1) { let pos = [dataCells[i].index]; if (sortValue === "initial") { rowNodes[pos].classList.remove("sorted"); } else { rowNodes[pos].classList.add("sorted"); } tbodyNode.appendChild(rowNodes[pos]); } } /* EVENT HANDLERS */ handleClick(event) { var tgt = event.currentTarget; this.setColumnHeaderSort(tgt.getAttribute('data-column-index')); } handleOptionChange(event) { var tgt = event.currentTarget; if (tgt.checked) { this.tableNode.classList.add('show-unsorted-icon'); } else { this.tableNode.classList.remove('show-unsorted-icon'); } }}$(document).ready(function() { load(); });;}());
Subscribe to receive the latest Eurostat Euro indicators releases