diff --git a/package.json b/package.json index b0fab8f..74cc6f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@statisticsfinland/pxvisualizer", - "version": "1.4.1", + "version": "1.4.2", "description": "Component library for visualizing PxGraf data", "main": "./dist/pxv.cjs", "jestSonar": { diff --git a/src/core/tables/__snapshots__/htmlTable.test.ts.snap b/src/core/tables/__snapshots__/htmlTable.test.ts.snap index 0bb1359..97cdc47 100644 --- a/src/core/tables/__snapshots__/htmlTable.test.ts.snap +++ b/src/core/tables/__snapshots__/htmlTable.test.ts.snap @@ -261,12 +261,13 @@ exports[`Html table render tests should match snapshot: Table with column variab    - 

 +  Yksikkö: lukumäärä - 

 - 

 +  +  + 
 Lähde: PxVisualizer-fi - 

 +  " `; @@ -431,12 +432,13 @@ exports[`Html table render tests should match snapshot: Table with missing data    - 

 +  Yksikkö: Eur / m2 - 

 - 

 +  +  + 
 Lähde: PxVisualizer-fi - 

 +  " `; @@ -462,12 +464,13 @@ exports[`Html table render tests should match snapshot: Table with only one cell    - 

 +  Yksikkö: lukumäärä - 

 - 

 +  +  + 
 Lähde: PxVisualizer-fi - 

 +  " `; @@ -1104,12 +1107,13 @@ exports[`Html table render tests should match snapshot: Table with row and colum    - 

 +  Yksikkö: Lukumäärä: lukumäärä, Neliövuokra (eur/m2): eur / m2 - 

 - 

 +  +  + 
 Lähde: PxVisualizer-fi - 

 +  " `; @@ -1746,9 +1750,9 @@ exports[`Html table render tests should match snapshot: Table with row and colum    - 

 +  Test footnote - 

 +  " `; @@ -2378,12 +2382,13 @@ exports[`Html table render tests should match snapshot: Table with row and colum    - 

 +  Yksikkö: Lukumäärä: lukumäärä, Neliövuokra (eur/m2): eur / m2 - 

 - 

 +  +  + 
 Lähde: PxVisualizer-fi - 

 +  " `; @@ -3548,12 +3553,13 @@ exports[`Html table render tests should match snapshot: Table with row variables    - 

 +  Yksikkö: lukumäärä - 

 - 

 +  +  + 
 Lähde: PxVisualizer-fi - 

 +  " `; @@ -3579,14 +3585,16 @@ exports[`Html table render tests should match snapshot: Table with source and fo    - 

 +  Yksikkö: lukumäärä - 

 - 

 +  +  + 
 Test footnote - 

 - 

 +  +  + 
 Lähde: PxVisualizer-fi - 

 +  " `; diff --git a/src/core/tables/htmlTable.ts b/src/core/tables/htmlTable.ts index f62f03f..d55869a 100644 --- a/src/core/tables/htmlTable.ts +++ b/src/core/tables/htmlTable.ts @@ -33,38 +33,41 @@ export function renderHtmlTable(view: View, locale: string, options: IChartOptio container.append(table); + let isFirstMetadata: boolean = true; + + // Helper function to add metadata elements + const addMetadata = (text: string) => { + const span = document.createElement('span'); + if (!isFirstMetadata) span.append(document.createElement('br')); + span.append(text); + container.append(span); + isFirstMetadata = false; + }; + // Units if (options.showUnits) { - const pUnits = document.createElement('p'); const unitName = getFormattedUnits(view.units, locale); const units: string = `${Translations.unit[locale]}: ${unitName}`; - pUnits.append(units); - container.append(pUnits); + addMetadata(units); } // Footnote if (footnote) { - const pFootnote = document.createElement('p'); - pFootnote.append(footnote); - container.append(pFootnote); + addMetadata(footnote); } // Last Updated if (options.showLastUpdated && view.lastUpdated) { - const pLastUpdated = document.createElement('p'); const lastUpdatedText = getFormattedLastUpdatedText(view.lastUpdated, locale); if (lastUpdatedText) { - pLastUpdated.append(lastUpdatedText); - container.append(pLastUpdated); + addMetadata(lastUpdatedText); } } // Sources if (options.showSources) { - const pSources = document.createElement('p'); const sources: string = `${Translations.source[locale]}: ${view.sources.map(source => source[locale]).join(', ')}`; - pSources.append(sources); - container.append(pSources); + addMetadata(sources); } } catch (error) { diff --git a/src/react/components/chart/__snapshots__/chart.test.tsx.snap b/src/react/components/chart/__snapshots__/chart.test.tsx.snap index 959f910..d20f9d2 100644 --- a/src/react/components/chart/__snapshots__/chart.test.tsx.snap +++ b/src/react/components/chart/__snapshots__/chart.test.tsx.snap @@ -117,9 +117,9 @@ exports[`Rendering test renders chart data correctly 1`] = ` -

+ Lähde: PxVisualizer-fi -

+ @@ -204,9 +204,9 @@ exports[`Rendering test renders chart data correctly with hidden context menu 1` -

+ Lähde: PxVisualizer-fi -

+ @@ -323,9 +323,9 @@ exports[`Rendering test renders chart data correctly with hidden title 1`] = ` -

+ Lähde: PxVisualizer-fi -

+ @@ -442,9 +442,9 @@ exports[`Rendering test renders chart data correctly with hidden title and conte -

+ Lähde: PxVisualizer-fi -

+ @@ -522,9 +522,9 @@ exports[`Rendering test renders chart data correctly with hidden title and hidde -

+ Lähde: PxVisualizer-fi -

+ @@ -648,12 +648,13 @@ exports[`Rendering test renders chart data correctly with last updated date 1`] -

+ Päivitetty: 19.1.2023 -

-

+ + +
Lähde: PxVisualizer-fi -

+ @@ -1349,9 +1350,9 @@ exports[`Rendering test renders table data correctly 1`] = ` -

+ Lähde: PxVisualizer-fi -

+ @@ -2034,12 +2035,13 @@ exports[`Rendering test renders table data correctly when given footnote 1`] = ` -

+ Test footnote -

-

+ + +
Lähde: PxVisualizer-fi -

+ @@ -2722,9 +2724,9 @@ exports[`Rendering test renders table data correctly when sources are on 1`] = ` -

+ Lähde: PxVisualizer-fi -

+ @@ -3407,9 +3409,9 @@ exports[`Rendering test renders table data correctly when titles are forced on 1 -

+ Lähde: PxVisualizer-fi -

+ @@ -4092,15 +4094,17 @@ exports[`Rendering test renders table data correctly when units and footnote are -

+ Yksikkö: Lukumäärä: lukumäärä, Neliövuokra (eur/m2): eur / m2 -

-

+ + +
Test footnote -

-

+ + +
Lähde: PxVisualizer-fi -

+ @@ -4744,9 +4748,9 @@ exports[`Rendering test renders table data correctly with hidden context menu 1` -

+ Lähde: PxVisualizer-fi -

+ @@ -5422,9 +5426,9 @@ exports[`Rendering test renders table data correctly with hidden titles 1`] = ` -

+ Lähde: PxVisualizer-fi -

+ @@ -6100,9 +6104,9 @@ exports[`Rendering test renders table data correctly with hidden titles and cont -

+ Lähde: PxVisualizer-fi -

+ @@ -6739,9 +6743,9 @@ exports[`Rendering test renders table data correctly with hidden titles and hidd -

+ Lähde: PxVisualizer-fi -

+ @@ -7424,12 +7428,13 @@ exports[`Rendering test renders table data correctly with last updated date 1`] -

+ Päivitetty: 19.1.2023 -

-

+ + +
Lähde: PxVisualizer-fi -

+ diff --git a/src/react/components/chart/__snapshots__/tableView.test.tsx.snap b/src/react/components/chart/__snapshots__/tableView.test.tsx.snap index afab433..4d97ebf 100644 --- a/src/react/components/chart/__snapshots__/tableView.test.tsx.snap +++ b/src/react/components/chart/__snapshots__/tableView.test.tsx.snap @@ -635,12 +635,13 @@ exports[`TableView render tests Should render correctly 1`] = ` -

+ Yksikkö: Lukumäärä: lukumäärä, Neliövuokra (eur/m2): eur / m2 -

-

+ + +
Lähde: PxVisualizer-fi -

+ `;