Skip to content

Commit

Permalink
[MIM-2104] MIM-2104_bugfix_highcharts_show_table (#3035)
Browse files Browse the repository at this point in the history
* Fixes bug for highcharts data with two column headers from tbProcessor
MIM-2104

* Add explanation comment

* MIM-2104:Revert first fix

* MIM-2104:New fix

---------

Co-authored-by: Carina <[email protected]>
  • Loading branch information
johnnadeluy and ssb-cgn authored Nov 18, 2024
1 parent f652ac8 commit 8f070c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/main/resources/lib/ssb/parts/highcharts/data/tbProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function seriesAndCategoriesFromTbml(
const thead: Array<TableRowUniform> = data.tbml.presentation.table.thead
const rows: TableRowUniform['tr'] = tbody[0].tr
const headerRows: Array<TableCellUniform> = thead[0].tr
const headers: TableCellUniform['th'] = headerRows[0].th
const headers: TableCellUniform['th'] = getHeaders(headerRows[0], tbody)
const categories: TableCellUniform['th'] = determineCategories(graphType, headers, rows, xAxisType)
const series: Array<Series> = determineSeries(graphType, headers, categories, rows, xAxisType)

Expand All @@ -30,6 +30,15 @@ export function seriesAndCategoriesFromTbml(
}
}

function getHeaders(headerRows: TableCellUniform, body: Array<TableRowUniform>): TableCellUniform['th'] {
//Table without td i thead, feks table from Dapla
if ((!headerRows.td || headerRows.td.length == 0) && headerRows.th.length > 1) {
const bodyFirstRowItemCount = Object.keys(body[0].tr[0]).length
return headerRows.th.length == bodyFirstRowItemCount ? headerRows.th.slice(1) : headerRows.th
}
return headerRows.th
}

function determineSeries(
graphType: string,
headers: TableCellUniform['th'],
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/site/parts/highchart/highchart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ function createDataFromDataSource(
highchart.data.dataSource.tbprocessor?.urlOrId
? getDataset(type, UNPUBLISHED_DATASET_BRANCH, getTbprocessorKey(highchart))
: null

// get dataset
const datasetFromRepo: DatasetRepoNode<JSONstatType | TbmlDataUniform | object> | undefined = draftData
? draftData
Expand Down

0 comments on commit 8f070c0

Please sign in to comment.