Skip to content

EU current account surplus €57.3 bn

[]

Printing can have negative environmental impacts due to paper waste. We encourage you to explore eco-friendly alternatives. Bookmarking this page in your browser allows you to access it anytime.

This publication can also be converted to PDF, if you have a PDF printer installed on your computer. PDF printers function as virtual printers, enabling you to create digital copies of web pages and access the content offline.

{ const buttonPrintPage = document.getElementById(‘estat-print-page-modal-toggle’); const cookieSkipModal = ‘skipModalBeforePrinting’; if (configuration.displayInPageHeader) { const headerElement = document.querySelector(‘.ecl-page-header .ecl-page-header__meta’) || document.querySelector(‘.ecl-page-header .ecl-page-header__title-container ‘) if (headerElement) { headerElement.prepend(buttonPrintPage); headerElement.classList.add(‘ecl-u-width-100’) } } buttonPrintPage.addEventListener(‘click’, () => { const skipModal = readCookie(cookieSkipModal); if (skipModal == ‘true’) { window.print(); } else { const eclModalElement = document.getElementById(‘estat-print-page-modal’); const eclModal = ECL.components.get(eclModalElement); eclModal.openModal(); } }); document.getElementById(‘print-submit’).addEventListener(‘click’, () => { const skipModal = document.getElementById(‘checkbox-skip-modal’).checked if (skipModal) { writeCookieWithMaxAgeValue(cookieSkipModal, ‘true’, 15768000); } else { deleteCookie(cookieSkipModal); } window.print(); }); });;}());]]>

€16.7 bn surplus for trade in services

Overview

In the third quarter of 2025, the EU seasonally adjusted current account of the balance of payments recorded a surplus of €57.3 billion (+1.2% of GDP), compared with a surplus of €80.5 billion (+1.7% of GDP) in the second quarter of 2025 and a surplus of €96.1 billion (+2.1% of GDP) in the third quarter of 2024, according to estimates released by Eurostat, the statistical office of the European Union.

EU current and capital accounts

In the third quarter of 2025 compared with the second quarter of 2025, based on seasonally adjusted data

  • the surplus of the goods account increased (+€95.7 bn compared to +€86.3 bn),

  • the surplus of the services account decreased (+€16.7 bn compared to +€37.4 bn),

  • the deficit of the primary income account increased (-€23.9 bn compared to -€14.4 bn) and

  • the deficit of the secondary income account increased (-€31.1 bn compared to -€28.9 bn).

In addition, during the same period, the deficit of the capital account decreased (-€2.2 bn compared to -€19.7 bn).

Current account balance

   

EU current and capital accounts
– calendar and seasonally adjusted (bn euro) –

Current account

 Goods

Services

Primary income

Secondary income

Current account as
% of GDP

Capital account

1409.8

647.6

379.5

338.3

44.4

31.2%

15.5

1313.7

565.8

341.4

335.5

71.0

29.0%

17.7

96.1

81.9

38.1

2.8

-26.6

2.1%

-2.3

1416.9

648.6

387.4

336.2

44.8

30.9%

19.1

1321.4

563.1

341.7

343.7

73.0

28.9%

18.5

95.5

85.5

45.7

-7.5

-28.2

2.1%

0.6

1489.3

698.4

404.8

342.2

44.0

32.2%

21.3

1374.3

584.2

359.0

359.5

71.5

29.7%

18.8

115.0

114.2

45.7

-17.3

-27.6

2.5%

2.4

1423.2

657.4

391.2

331.1

43.6

30.5%

7.5

1342.8

571.1

353.8

345.4

72.5

28.7%

27.2

80.5

86.3

37.4

-14.4

-28.9

1.7%

-19.7

1398.3

661.9

378.2

316.0

42.3

29.6%

15.5

1341.0

566.2

361.5

339.9

73.4

28.4%

17.7

57.3

95.7

16.7

-23.9

-31.1

1.2%

-2.2

Euro area current account
– calendar and seasonally adjusted (bn euro) –

2024

2025

Q3

Q4

Q1

Q2

Q3

88.2

73.7

75.3

83.7

45.8

84.6

78.7

110.7

87.0

94.9

37.0

47.2

30.4

38.5

26.3

8.9

-0.2

-23.7

5.1

-25.6

-42.3

-52.1

-42.0

-46.9

-49.7

2.3%

1.9%

1.9%

2.1%

1.2%

EU main partners

In the third quarter of 2025, based on non-seasonally adjusted data, the EU recorded current account surpluses with the United Kingdom (+€75.7bn), Canada (+€12.0 bn), offshore financial centres (+€11.5 bn), the USA (+€9.2 bn), Brazil (+€8.4 bn), Hong Kong (+€7.4 bn), Switzerland (+€4.6 bn), Japan (+€4.3 bn) and Russia (+€4.2 bn). Deficits were registered with China (-€58.3 bn) and India (-€0.3 bn).

EU financial account

Based on non-seasonally adjusted data, in the third quarter of 2025

As a result, the EU was a net direct investor to the rest of the world with net outflows of €11.1 bn.

At the same time,

  • portfolio investment recorded a net outflow of €76.1 bn, and

  • other investment recorded a net inflow of €37.3 bn.

EU financial account
– neither calendar nor seasonally adjusted (bn euro) –

2024

2025

Q3

Q4

Q1

Q2

Q3

225.1

75.3

122.7

36.0

59.4

433.3

29.1

764.0

278.1

332.9

208.2

-46.2

641.2

242.1

273.4

51.9

-12.8

92.6

-3.0

11.1

4.6

41.6

141.3

-40.3

33.7

-47.3

54.4

48.7

-37.3

22.5

-31.6

80.8

-34.0

5.3

76.1

179.2

215.2

153.3

190.9

266.6

210.8

134.4

187.3

185.5

190.5

211.2

-17.6

59.5

28.0

-37.3

255.9

-252.6

464.8

121.9

23.0

44.7

-235.0

405.2

93.9

60.4

-5.7

12.3

0.4

-7.5

-11.2

-0.8

12.6

4.2

13.1

20.8

Current account of Member States (including intra-EU flows)

As concerns the total (intra-EU plus extra-EU) current account balances of the EU Member States, based on available non-seasonally adjusted data, sixteen Member States recorded surpluses and eleven recorded deficits in the third quarter of 2025. The highest surpluses were observed in Germany (+€41.0 bn), the Netherlands (+€19.7 bn), Spain (+€15.4 bn), Denmark (+€14.8 bn), Italy (+€14.4 bn), Ireland (+€13.9 bn) and Sweden (+€8.4 bn). The largest deficits were recorded for Romania (-€8.3 bn), France (-€4.8 bn), Poland (-€4.2 bn) and Belgium (-€3.8 bn).

Tables

EU current account, breakdown by main partner countries
– neither calendar nor seasonally adjusted (bn euro) –

Partner

Period

Credit

Debit

Balance

Q3 2024

1406.9

1284.5

122.4

Q3 2025

1401.6

1301.9

99.7

Q3 2024

239.1

169.9

69.2

Q3 2025

241.0

165.4

75.7

Q3 2024

321.4

296.4

25.0

Q3 2025

320.2

311.0

9.2

Q3 2024

115.4

94.1

21.3

Q3 2025

110.4

105.8

4.6

Q3 2024

90.2

139.7

-49.5

Q3 2025

79.8

138.1

-58.3

Q3 2024

14.1

14.0

0.1

Q3 2025

14.5

10.3

4.2

Q3 2024

35.5

30.1

5.4

Q3 2025

35.3

31.1

4.3

Q3 2024

29.8

16.1

13.7

Q3 2025

28.3

16.3

12.0

Q3 2024

20.6

12.8

7.8

Q3 2025

20.8

13.4

7.4

Q3 2024

23.2

23.9

-0.7

Q3 2025

23.9

24.2

-0.3

Q3 2024

24.9

15.5

9.4

Q3 2025

23.8

15.4

8.4

Q3 2024

92.1

81.5

10.6

Q3 2025

87.1

75.7

11.5

Q3 2024

421.1

403.3

17.8

Q3 2025

437.3

408.8

28.6

EU goods account, breakdown by main partner countries
– neither calendar nor seasonally adjusted (bn euro) –

Partner

Period

Credit

Debit

Balance

Q3 2024

642.7

566.2

76.5

Q3 2025

657.9

566.5

91.4

Q3 2024

88.2

42.3

45.9

Q3 2025

88.1

41.8

46.4

Q3 2024

138.4

71.9

66.5

Q3 2025

141.9

75.4

66.5

Q3 2024

37.6

31.2

6.4

Q3 2025

38.3

33.1

5.2

Q3 2024

59.0

123.6

-64.6

Q3 2025

53.0

123.1

-70.1

Q3 2024

8.2

8.7

-0.5

Q3 2025

7.9

5.6

2.3

Q3 2024

17.7

13.6

4.1

Q3 2025

16.4

13.9

2.5

Q3 2024

13.1

5.6

7.5

Q3 2025

12.4

6.1

6.4

Q3 2024

8.4

5.0

3.4

Q3 2025

7.9

5.2

2.7

Q3 2024

12.1

13.8

-1.6

Q3 2025

12.4

13.8

-1.4

Q3 2024

9.4

10.6

-1.2

Q3 2025

8.9

10.3

-1.4

Q3 2024

22.0

15.3

6.7

Q3 2025

21.1

14.7

6.4

Q3 2024

237.0

229.7

7.2

Q3 2025

257.4

228.7

28.7

EU services account, breakdown by main partner countries
– neither calendar nor seasonally adjusted (bn euro) –

Partner

Period

Credit

Debit

Balance

Q3 2024

397.1

335.9

61.1

Q3 2025

399.8

353.6

46.2

Q3 2024

79.1

59.2

19.9

Q3 2025

83.7

63.5

20.2

Q3 2024

85.4

116.2

-30.8

Q3 2025

83.6

125.3

-41.6

Q3 2024

41.2

24.0

17.2

Q3 2025

42.1

24.6

17.6

Q3 2024

17.9

11.6

6.3

Q3 2025

16.4

10.8

5.6

Q3 2024

1.9

1.1

0.9

Q3 2025

1.4

1.0

0.4

Q3 2024

9.4

5.5

3.9

Q3 2025

11.3

5.9

5.4

Q3 2024

8.2

5.9

2.4

Q3 2025

7.9

5.4

2.5

Q3 2024

8.6

3.8

4.8

Q3 2025

8.6

3.8

4.8

Q3 2024

7.5

8.9

-1.4

Q3 2025

7.0

9.1

-2.2

Q3 2024

5.8

2.4

3.4

Q3 2025

5.5

2.5

3.0

Q3 2024

27.1

27.2

-0.2

Q3 2025

28.2

25.3

2.8

Q3 2024

113.6

74.1

39.5

Q3 2025

112.7

80.2

32.5

EU direct investment, breakdown by main partner countries
– neither calendar nor seasonally adjusted (bn euro) –

Partner

Period

Net acquisition of
Assets

Net incurrence of
Liabilities

Net

Q3 2024

4.6

-47.3

51.9

Q3 2025

33.7

22.5

11.1

Q3 2024

20.6

-25.7

46.3

Q3 2025

31.1

8.9

22.2

Q3 2024

-2.8

-17.8

14.9

Q3 2025

35.0

5.5

29.4

Q3 2024

7.7

11.7

-4.0

Q3 2025

-8.6

22.3

-30.9

Q3 2024

-4.2

1.8

-6.0

Q3 2025

-4.5

0.5

-5.0

Q3 2024

0.7

0.0

0.7

Q3 2025

0.0

0.9

-0.9

Q3 2024

1.8

0.2

1.6

Q3 2025

-2.6

-3.2

0.6

Q3 2024

-0.6

-7.5

6.9

Q3 2025

-1.6

4.5

-6.1

Q3 2024

-3.9

-11.9

7.9

Q3 2025

2.9

-1.3

4.2

Q3 2024

1.2

0.6

0.6

Q3 2025

2.8

-1.0

3.7

Q3 2024

4.4

-0.3

4.7

Q3 2025

6.0

2.7

3.3

Q3 2024

-35.7

-22.8

-12.9

Q3 2025

-14.3

-5.0

-9.3

Q3 2024

11.6

12.5

-0.9

Q3 2025

-9.5

-13.6

4.1

Current accounts balances – national data (intra-EU + extra-EU)
– neither calendar nor seasonally adjusted (bn euro) –

2024

2025

Countries

Q3

Q4

Q1

Q2

Q3

-2.0

0.3

-2.2

-7.2

-3.8

1.1

-1.8

-1.2

-0.7

-1.2

-0.1

1.4

3.9

-2.3

-0.6

14.4

12.7

8.1

12.9

14.8

56.2

50.2

65.7

45.5

41.0

-0.3

0.1

-0.2

0.0

-0.1

19.7

18.2

5.8

19.5

13.9

-0.1

-7.7

-5.0

-3.5

1.4

15.3

9.2

10.0

14.2

15.4

1.7

15.3

-12.1

-11.1

-4.8

4.6

-2.1

-3.5

-1.7

3.9

9.5

3.6

-2.3

10.3

14.4

-0.1

-1.4

-1.1

-0.3

-0.1

-0.4

0.1

-0.3

-0.5

-0.3

1.1

0.1

0.0

0.1

0.1

4.5

-3.2

1.9

2.2

1.8

0.5

0.7

1.2

1.0

0.9

0.5

0.1

0.4

0.5

0.6

19.8

34.5

26.8

13.4

19.7

0.2

1.2

5.6

-2.0

-0.1

-3.1

-0.8

-1.1

-0.9

-4.2

3.4

-0.3

0.1

0.5

3.5

-8.2

-8.3

-6.4

-6.7

-8.3

1.1

0.7

0.4

0.9

0.9

-1.6

-2.4

-1.8

-1.1

-1.1

1.9

0.7

-1.5

0.8

2.4

7.7

7.7

11.6

8.9

8.4

0.3

-0.6

-0.4

-0.8

0.2

16.4

15.0

23.5

15.8

14.5

8.0

25.1

28.2

13.4

16.4

0.0

-0.2

-0.5

-0.2

0.0

0.1

-0.5

-0.5

-0.5

0.1

0.3

-0.3

-0.3

-0.2

:

0.3

-0.4

-0.3

-0.3

0.7

-1.5

-1.2

-0.6

-1.3

-0.9

8.3

-4.9

-11.9

-9.4

7.0

0.2

-0.5

-0.3

-0.5

:

Services accounts balances – national data (intra-EU + extra-EU)
– neither calendar nor seasonally adjusted (bn euro) –

2024

2025

Countries

Q3

Q4

Q1

Q2

Q3

-5.3

-1.4

-1.5

-5.0

-4.8

2.7

1.9

1.7

2.2

2.5

1.0

0.5

1.3

0.8

0.9

3.7

-1.6

-0.3

-0.2

1.6

-25.2

-17.3

-12.4

-18.7

-26.5

0.8

0.7

0.6

0.8

0.8

11.4

6.9

-0.4

12.4

6.1

12.0

3.3

0.9

6.5

12.1

31.6

22.0

23.0

30.2

34.5

16.6

13.2

9.8

20.5

14.0

9.0

1.7

0.7

3.4

8.9

3.3

-4.9

-4.2

1.8

2.3

2.6

2.2

1.5

2.3

2.9

0.7

0.7

0.4

0.5

0.6

2.4

2.2

2.1

2.5

2.7

8.0

7.6

7.4

6.7

7.2

3.2

2.4

1.9

2.8

3.6

2.0

1.4

1.7

2.1

2.2

8.7

12.6

9.0

13.5

9.2

-0.4

1.9

5.5

-0.8

0.2

10.2

9.4

9.2

10.8

10.0

10.8

7.1

6.7

8.3

11.5

2.9

2.9

3.3

3.2

2.9

1.1

1.0

0.7

1.0

1.2

0.2

0.0

0.1

0.1

0.1

-0.7

-0.6

-1.6

-1.0

-1.5

-2.5

-2.7

-2.5

-3.7

-4.6

0.9

0.4

0.1

0.4

1.0

-2.5

-2.3

-1.2

-2.3

-2.7

-4.0

-4.9

-4.4

-2.1

-3.0

0.7

0.6

0.4

0.5

0.7

0.9

0.2

0.1

0.4

1.0

0.4

0.1

0.2

0.2

:

1.5

0.9

0.7

0.9

1.9

0.4

1.0

0.7

0.6

0.3

22.0

13.0

7.6

13.7

21.5

1.0

0.3

0.4

0.4

:

Notes for users

Revisions and timetable

The EU balance of payments estimates for the reference quarter are based on figures provided by the Member States to Eurostat 82 days (euro area Member States) or 85 days (non-euro area Member States) after the end of the reference quarter and should be considered as provisional. Figures may be subject to revision when data for later quarters are transmitted by the Member States.

A more limited set of monthly data is available in the Eurostat on-line database approximately 51 days after the end of the reference month. The publication timetable of balance of payments statistics for 2025 and 2026 is available here.

Methods and definitions

The current account covers all transactions occurring between resident and non-resident entities, and refers to international trade in goods and services, as well as primary and secondary income. The capital account comprises capital transfers and the acquisition and disposal of non-produced, non-financial assets. The financial account records transactions that involve financial assets and liabilities, and take place between residents and non-residents and is further subdivided into direct investment, portfolio investment, other investment, financial derivatives and employee stock options and reserve assets. Further details of the statistical concepts and definitions used can be found on the Eurostat website here.

In line with the agreed allocation of responsibility, the European Central Bank (ECB) is in charge of compiling and disseminating monthly and quarterly balance of payments and quarterly international investment position statistics for the euro area, while the European Commission (Eurostat) is responsible for monthly, quarterly and annual aggregates of the EU. The aggregates for the euro area and the EU are compiled consistently on the basis of Member States’ transactions with residents of countries outside the euro area and the European Union respectively.

Geographical information

Up to 31 December 2025, the euro area included Belgium, Germany, Estonia, Ireland, Greece, Spain, France, Croatia, Italy, Cyprus, Latvia, Lithuania, Luxembourg, Malta, the Netherlands, Austria, Portugal, Slovenia, Slovakia and Finland (EA20). From 1 January 2026, the euro area also includes Bulgaria (EA21).

The aggregate data series commented on in this Euro indicator release refer to the official composition of the euro area in the most recent month for which data are available. Thus, Euro indicator releases with data for months up to December 2025 comment on EA20 series, while releases with data for January 2026 onwards will comment on EA21 series.

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.

Offshore Financial Centres (OFC) is an aggregate that includes 40 countries. As example, the aggregate contains financial centres such as Liechtenstein, Guernsey, Jersey, the Isle of Man, Andorra, Gibraltar, Panama, Bermuda, the Bahamas, the Cayman Islands, British Virgin Islands, Bahrain, Hong Kong, Singapore and the Philippines.

For more information

Share the release

Share component will be rendered here.

* Here the title * … * … * * Here the logo and notes * */ function tableConfiguration() { /** Retrieves the list of table elements (images) */ const tables = document.getElementsByTagName(‘table’); /** We go through the list of tables */ for (let table of tables) { /** We create a section to wrap the table */ let section = document.createElement(‘section’); /** Add table-wrapper class to section element */ section.classList.add(‘table-wrapper’); /** We create a caption element to place the title */ let caption = document.createElement(‘caption’); /** We create thead element to place the headers */ let tHead = document.createElement(‘thead’); /** We create a footer to place notes, datasource and logo */ let footer = document.createElement(‘footer’); /** Retrieves the tBody */ let tBody = table.tBodies[0]; /** Retrieves the table rows */ let rows = tBody.rows; let datalabels = []; let captionContent = []; /** Stores the indexes of the rows to be removed after processing the whole table */ let rowsToRemove = []; /** We go through the rows within the table and extract caption, headers and footnotes */ buildTable(rows, captionContent, datalabels, footer, rowsToRemove); deleteRows(table, rowsToRemove); addTableCaption(caption, captionContent); addTableHeaders(table, tHead, datalabels); wrapInSection(section, table, caption, tHead, tBody, footer); linkHeaders(table); } } /** * Builds a table with the expected format: adding caption, datalabels and footer * @param {*} rows – The table rows * @param {*} captionContent – The content of the caption (title) * @param {*} datalabels – The list of datalabels (table headers) * @param {*} footer – The footer element * @param {*} rowsToRemove – Array containing the index of the rows to be removed */ function buildTable(rows, captionContent, datalabels, footer, rowsToRemove) { let rowIndex = 0; for (let row of rows) { let cells = row.cells; /** We check the first cell in order to guess the cell type: th, td; and cell classes: title, datalabel… */ let firstCell = row.firstElementChild; /** If the th class name is title, we convert this th into a caption */ if (isCaption(firstCell)) { addCaption(cells, captionContent, rowIndex, rowsToRemove) } /** If the th class name is datalabel, we add the header to the tHead component */ else if (isDatalabel(firstCell)) { addDatalabels(row, datalabels, rowIndex, rowsToRemove); } /** If the th class name is title, we convert this th into a caption */ else if (isFooter(firstCell)) { addFooter(row, footer, rowIndex, rowsToRemove); } else { row.setAttribute(‘initial-position’, rowIndex); } rowIndex++; } } /** * Checks whether the given cell has the given tagName and className * @param {*} cell – The cell to be checked * @param {*} tagName – The tag name to be checked * @param {*} className – The class name to be checked * @returns true if the cell’s tagName and className matches the given ones, false otherwise */ function checkCell(cell, tagName, className) { return cell.tagName.toLowerCase() === tagName && cell.className.indexOf(className) > -1; } /** * Whether a cell is a caption (title) * @param {*} cell – The cell to be checked * @returns true if the cell is a caption, false otherwise */ function isCaption(cell) { return checkCell(cell, ‘th’, ‘title’); } /** * Whether a cell is a datalabel * @param {*} cell – The cell to be checked * @returns true if the cell is a datalabel, false otherwise */ function isDatalabel(cell) { return checkCell(cell, ‘th’, ‘datalabel’); } /** * Whether a cell is a vertical header * @param {*} cell – The cell to be checked * @returns true if the cell is a vertical header, false otherwise */ function isVerticalHeader(cell) { return checkCell(cell, ‘th’, ‘vertical-header’); } /** * Whether a cell is a footer * @param {*} cell – The cell to be checked * @returns true if the cell is a footer, false otherwise */ function isFooter(cell) { return checkCell(cell, ‘td’, ‘footer’); } /** * Adds the content of the caption cells: paragraphs * @param {*} cells – The cells belonging to the row * @param {*} captionContent – The content of the caption * @param {*} rowIndex – The index of current row * @param {*} rowsToRemove – Array containing the index of the rows to be removed */ function addCaption(cells, captionContent, rowIndex, rowsToRemove) { for (let cell of cells) { /** We must add all the Child Nodes of each th title Cell */ for (let childNode of cell.childNodes) { captionContent.push(childNode); } } /** We remove the row from within the tables as now it’s out in the caption */ rowsToRemove.push(rowIndex); } /** * Adds the row as a datalabel * @param {*} row – The current row * @param {*} datalabels – List of datalabels * @param {*} rowIndex – The index of current row * @param {*} rowsToRemove – Array containing the index of the rows to be removed */ function addDatalabels(row, datalabels, rowIndex, rowsToRemove) { datalabels.push(row); /** We remove the row from within the tables as now it’s out in the caption */ rowsToRemove.push(rowIndex); } /** * Adds the notes and logo * @param {*} row – The current row * @param {*} footer – The footer of the table * @param {*} rowIndex – The index of current row * @param {*} rowsToRemove – Array containing the index of the rows to be removed */ function addFooter(row, footer, rowIndex, rowsToRemove) { /** We create a div element for notes and logo */ const notes = document.createElement(‘div’); notes.classList.add(‘footer-element’, ‘notes’); /** We add the content to the new note element */ notes.innerHTML = row.firstElementChild.innerHTML; /** We create a footer to place notes, datasource and logo */ footer.appendChild(notes); /** We remove the row from within the tables as now it’s out in the footer */ rowsToRemove.push(rowIndex); } /** * Deletes the rows which data has been moved to either caption, tHead or footer * @param {*} table – The current table * @param {*} rowsToRemove – Array containing the index of the rows to be removed */ function deleteRows(table, rowsToRemove) { /** We go through the title rows and append them to the caption element */ for (let j = rowsToRemove.length – 1; j >= 0; j–) { table.deleteRow(rowsToRemove[j]); } } /** * Adds the caption to the table. * @param {*} caption – The caption dom element * @param {*} captionContent – The content of the caption */ function addTableCaption(caption, captionContent) { /** We go through the Caption Content and append the nodes to the caption element */ for (let node of captionContent) { caption.appendChild(node); } } /** * Adds the headers to the table * @param {*} table – The table to make sortable * @param {*} tHead – The thead dom element * @param {*} datalabels – The datalabels to be added (headers) */ function addTableHeaders(table, tHead, dataLabels) { let sortable = false; /** We go through the header rows and append them to the tHead element */ for (let dataLabelRow of dataLabels) { let cells = dataLabelRow.cells; for (let th of cells) { if (th.classList.contains(‘sortable’)) { sortable = true; let button = createNewSortButton(); th.appendChild(button); } } tHead.appendChild(dataLabelRow); } if (sortable) { table.classList.add(‘sortable’); } } function createNewSortButton() { // creates sort button const button = document.createElement(‘button’); button.classList.add(‘ecl-table__arrow’); // creates a generic svg element for the two arrows const svgIconUp = document.createElementNS(‘http://www.w3.org/2000/svg’, ‘svg’); svgIconUp.setAttribute(‘xml:space’, ‘preserve’); svgIconUp.setAttribute(‘viewBox’, ‘0 0 24 24’); svgIconUp.setAttribute(‘enable-background’, ‘new 0 0 24 24’); svgIconUp.setAttribute(‘focusable’, ‘false’); svgIconUp.setAttribute(‘aria-hidden’, ‘true’); svgIconUp.setAttribute(‘class’, ‘ecl-table__icon ecl-icon ecl-icon–m’); // adds path element of the arrow to the arrow svg const pathIconArrow = document.createElementNS(‘http://www.w3.org/2000/svg’, ‘path’); pathIconArrow.setAttribute(‘d’, ‘M7.4 13 11 9.4c.5-.5 1.4-.5 2 0l3.6 3.6c.9.9.2 2.4-1 2.4H8.4c-1.3 0-1.9-1.5-1-2.4’); svgIconUp.appendChild(pathIconArrow); // clones the generic arrow svg including the child path also const svgIconDown = svgIconUp.cloneNode(true); // seups the arrow directions to up and down by extra css classes svgIconUp.classList.add(‘ecl-table__icon-up’); svgIconDown.classList.add(‘ecl-table__icon-down’); // insert the two arrow svg elements into the button button.appendChild(svgIconUp); button.appendChild(svgIconDown); return button; } /** * Places all the elements in their places and wraps the table into a section. * @param {*} section – The section (dom element) which will wrap table and footer * @param {*} table – The table to be wrapped * @param {*} caption – The caption (dom element) to be added to the table * @param {*} tHead – The thead (dom element) to be added to the table * @param {*} tBody – The tbody (dom element) to be added to the table * @param {*} footer – The footer (dom element) to be added to the section */ function wrapInSection(section, table, caption, tHead, tBody, footer) { /** We insert caption and thead before tbody */ table.insertBefore(caption, tBody); table.insertBefore(tHead, tBody); /** We wrap the table into a section */ table.parentNode.insertBefore(section, table); section.appendChild(table); section.appendChild(footer); } /** * Adds ids and header attributes to link every cell to all related headers so that machines can correctly read the figures. * @param {*} table – The table to be wrapped */ function linkHeaders(table) { const headers = getHeaders(table.tHead); const tBody = table.tBodies ? table.tBodies[0] : null; addHeaderLinks(tBody, headers); } function getHeaders(tHead) { const headers = []; if (tHead) { let i = 0; for (let row of tHead.rows) { /** We add a new row in the headers array */ headers.push([]); /** Stores the header ids and colSpan so we can guess to which cells (td) we must add the headers */ let j = 0; for (const cell of row.cells) { cell.setAttribute(‘id’, ‘h_’ + i + ‘_’ + j); headers[i].push({ id: cell.id, colSpan: cell.colSpan ? cell.colSpan : 1 }); j++; } i++; } } return headers; } function addHeaderLinks(tBody, headers) { if (tBody) { let i = 0; for (let row of tBody.rows) { let j = 0; for (const cell of row.cells) { /** If the cell is a vertical header we add its id */ if (cell.className.indexOf(‘vertical-header’) > -1) { cell.setAttribute(‘id’, ‘vh_’ + i + ‘_’ + j); } const headerLinks = getHeaderLinks(headers, j, cell.colSpan, row.cells[0]); cell.setAttribute(‘headers’, headerLinks); j++; } i++; } } } /** * Retrieves the header (ths) ids in order to link them to a specific cell (td) * @param {*} rows – The rows containing all headers * @param {*} index – The index of the specific cell * @param {*} colSpan – The colspan of the specific cell * @param {*} firstCell – The first cell of the row. Used to reference possible vertical headers * @returns A string containing the list of header ids split by spaces */ function getHeaderLinks(rows, index, colSpan, firstCell) { /** It will contain the header ids */ let links = ”; /** We add the reference of the vertical header if there is */ if (index > 0 && firstCell.className.indexOf(‘vertical-header’) > -1) { links = firstCell.id; } /** We go through the list of header rows */ for (const headers of rows) { /** Accumulates the colspan of the checked headers */ let sumColSpan = 0; /** We go through the list of headers for the specific header row */ for (const header of headers) { /** We check that the index of the cell belongs to a specific column */ if (index >= sumColSpan && index chartObj.resize()).observe(chartDiv); } } /** * Customizes the chart by applying custom events, axis formats, tooltips, and axis labels. * @param option – The chart options object. */ function customChartOptions(option) { setClickableDatasourceLinks(option); setAxisFormatter(option); setTooltipFormatter(option); } /** * Attaches event handlers to a chart: ‘legendselectchanged’. * * @param {Chart} chart – The chart object. */ function addEventHandlers(chart) { /** Attach an event handler for the ‘legendselectchanged’ event */ chart.on(‘legendselectchanged’, (event) => { /** Call the onChartLegendSelected function with the event and chart object */ onChartLegendSelected(event, chart); }); } /** * Handles the legend selected changed event of the chart. * @param {any} event – The event object containing the selected legend items. * @param {any} chart – The chart object. */ function onChartLegendSelected(event, chart) { /** Get the selected legend items */ const selected = event.selected; /** Count the number of selected legend items */ const selectedCount = Object.values(selected).filter(Boolean).length; /** If all legend items are deselected, keep the selection on the last clicked item */ if (selectedCount === 0) { selected[event.name] = true; } /** Update the legend selection */ chart.setOption({ legend: { selected: selected } }); } /** * Attaches custom events to the provided option object. * * @param {object} option – The option object to attach custom events to. */ function setClickableDatasourceLinks(option) { /** If the table has datasource link */ if (option.graphic && option.graphic.length >= 3) { /** Attach an onclick event handler to the third element of the graphic array (datasource links) */ option.graphic[2].onclick = function (event) { /** If the element has a link defined in its style */ if (this.style?.link) { /** Open the link in a new tab/window */ window.open(this.style.link, ‘_blank’); } }; } } /** * Sets the default axis formatter for axis labels. * @param {object} option – The option object to update the axis formatter * */ function setAxisFormatter(option) { /** The default unit used in axis labels */ const defaultUnit = ‘%’; /** If the yAxis are used as values */ if (option.yAxis.type === ‘value’) { /** If the yAxis unit is not defined, set % as default */ option.yAxis.axisLabel.unit = option.yAxis.axisLabel.unit ? option.yAxis.axisLabel.unit : defaultUnit; /** If the yAxis label padding is not defined, set 15 as default suffix */ option.yAxis.axisLabel.padding = option.yAxis?.axisLabel?.padding ? option.yAxis.axisLabel.padding : 15; /** Use the custom formatter */ option.yAxis.axisLabel.formatter = (value) => customAxisFormatter(option.lang, value, option.yAxis.axisLabel.unit, parseInt(option.yAxis.axisLabel.decimals)); // Use the custom formatter } /** If the xAxis are used as values */ if (option.xAxis.type === ‘value’) { /** If the xAxis unit is not defined, set % as default */ option.xAxis.axisLabel.unit = option.xAxis.axisLabel.unit ? option.xAxis.axisLabel.unit : defaultUnit; /** Use the custom formatter */ option.xAxis.axisLabel.formatter = (value) => customAxisFormatter(option.lang, value, option.xAxis.axisLabel.unit, parseInt(option.xAxis.axisLabel.decimals)); } /** If xAxis type is category */ else if (option.xAxis.type === ‘category’) { richStyle(option); } } /** * Formats a numeric value with a specified unit and decimal precision. * * @param {number} value – The numeric value to be formatted. * @param {string} unit – The unit to be appended to the formatted value. * @param {number} decimals – The number of decimal places to round the value to. * @returns {string} The formatted string representation of the value with unit. */ function customAxisFormatter(lang, value, unit, decimals) { /** * Check the language and format the value accordingly. * For French (fr) and German (de), use commas instead of dots. * For other languages (en), use the default format with dots. */ const formattedValue = lang === ‘fr’ || lang === ‘de’ ? `${value.toFixed(decimals).replace(‘.’, ‘,’)}${unit}` : `${value.toFixed(decimals)}${unit}`; return formattedValue; } /** * Applies custom rich text formatting to axis labels based on certain string patterns and HTML tags. * * Checks if the axis label contains certain values such as “EU”, “Euro Area”, and specific HTML tags. * It formats the labels by applying bold or italic styles as needed. * * @param axis – The axis object to which the formatting will be applied. * @returns The updated axis object with the formatted axis label. */ function richStyle(option) { /** Regular expression to match HTML tags like and */ const htmlTagRegex = /(.*?)/g; /** Mapping of HTML tags to corresponding rich text formatting styles */ const style = { strong: “bold”, em: “italic” }; /** * Formatter function for axis labels. * Converts specific label values into rich text format (e.g., bold). * * @param value – The value of the axis label to be formatted. * @returns The formatted axis label. */ option.xAxis.axisLabel.formatter = function (value) { /** Convert input string to lowercase for case-insensitive comparison */ const lowerCaseV = value ? value.toLowerCase() : ”; /** Check for “EU”, “UE”, “Euro Area”, “Euroraum” or “Zone Euro” and format them as bold */ if (lowerCaseV === ‘eu’ || lowerCaseV === ‘ue’ || lowerCaseV === ‘euro area’ || lowerCaseV === ‘euroraum’ || lowerCaseV === ‘zone euro’) { return `{bold|${value}}`; } /** Strictly check if the string contains supported HTML tags before formatting */ if (htmlTagRegex.test(value)) { /** Replace HTML tags with corresponding rich text formatting */ return value.replace(htmlTagRegex, (match, tag, content) => { return `{${style[tag]}|${content}}`; }); } /** Return the value as is if no formatting is needed */ return value; }; /** * Define the rich text styles for the axis labels. * These styles will be applied to specific HTML tags detected in the formatter function. */ option.xAxis.axisLabel.rich = { bold: { fontWeight: ‘bold’ }, italic: { fontStyle: ‘italic’ } }; } /** * Handles formatting the tooltip decimal convention in the graphic. * @remarks * This function formats the tooltip based on the language and decimal convention. * * @param {object} option – The option object to add custom tooltip. */ function setTooltipFormatter(option) { /** * Tooltip formatter for ECharts. * @param {object[]} params – Parameters for the tooltip formatter. * @param {string} params[].name – Name of the x-axis value. * @param {string} params[].seriesName – Name of the series. * @param {number} params[].value – Value of the data point. * @param {string} params[].color – Color of the series. * @param {string} ticket – Ticket for the callback. * @param {Function} callback – Callback function. * @returns {string} – Formatted tooltip content. */ option.tooltip.formatter = function (params, ticket, callback) { /** Retrieve the x-axis value for the tooltip */ const xAxisValue = params[0].name; /** If xAxisValue is empty, return null to hide the tooltip */ if (!xAxisValue) { return null; } /** Create the tooltip content container with a white background and padding */ let tooltipContent = ”; /** Add the x-axis value to the tooltip content */ /** @type {string} XAxis */ tooltipContent += ” + xAxisValue + ”; /** Retrieve the order from the tooltip option */ const 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 (const param of params) { /** Retrieve the name and value of the current series */ let seriesName = param.seriesName; let value = param.value; /** Replace every specific apostrphe by simple one. */ seriesName = seriesName.replaceAll(“’”, “‘”); /** Convert the numeric value to its string representation. */ const strValue = String(value); /** Retrieve the axis used as value */ const axis = option.yAxis.type === ‘value’ ? option.yAxis : option.xAxis; /** Initialize the number of decimal places */ let 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 || 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 */ const unit = axis.axisLabel.unit ? axis.axisLabel.unit : ”; /** Format the value using the appropriate number of decimal places */ if (isNaN(value)) { value = ‘N/A’; } else { value = Number(value).toLocaleString(option.lang ? option.lang : ‘en’, { minimumFractionDigits: decimals }) + unit; } /** Retrieve the color of the current series */ const color = param.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 */ class SortableTable { constructor(tableNode) { this.tableNode = tableNode; this.columnHeaders = tableNode.querySelectorAll(‘thead th.sortable’); this.sortColumns = []; for (let i = 0; i < this.columnHeaders.length; i++) { const ch = this.columnHeaders[i]; const buttonNode = ch.querySelector('button'); if (buttonNode) { this.sortColumns.push(i); 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 (let i = 0; i b.value ? -1 : 1; } } else if (isNumber) { return a.value - b.value; } else { return a.value

Subscribe to receive the latest Eurostat Euro indicators releases

{ if (document.querySelector(selector)) { return resolve(document.querySelector(selector)); } const observer = new MutationObserver(mutations => { if (document.querySelector(selector)) { resolve(document.querySelector(selector)); observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true }); }); } waitForElm(‘div.chart’).then((elm) => { // Has to be run after cool-ngx-editor.js script that is tweeking the charts const elements = document.getElementsByClassName(“chart”); for (let i = 0; i < elements.length; i++) { let div = document.createElement('div'); div.id = "share-chart-" + i; div.style = "position: absolute; right: 0; z-index: 50;"; elements[i].prepend(div); let script = document.createElement('script'); script.type = "application/json"; let url = new URL(window.location.href); url.searchParams.set('item', 'chart'); url.searchParams.set('id', i); let code = '{"service": "sbkm", "version": "2.0", "popup": false, "icon": true, "more" : ["facebook", "x", "linkedin", "email"], "renderTo": "' + div.id + '", "to": ["more"], "target": true, "link": "' + url.href + '", "via": "EU_Eurostat", "title": "' + getJournalArticleTitle() + '"}'; try { script.appendChild(document.createTextNode(code)); } catch (e) { // Older browsers may not support appendChild(document.createTextNode(...)) on . // Fallback to setting text directly on the script element. console.warn('Failed to append text node to script element, falling back to setting text', e); script.text = code; } elements[i].parentNode.insertBefore(script, elements[i].nextSibling); } }); // Add share button to tables $(document).ready(function() { // Has to be run after cool-ngx-editor.js script that is tweeking the tables const tables = document.getElementsByTagName("table"); for (let i = 0; i position) { await new Promise(r => setTimeout(r, 500)); // Wait a bit so that it doesn’t scroll too far allItems[position].scrollIntoView(true); } } });;}());]]>