Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIM-2104] MIM-2104_bugfix_highcharts_show_table #3035

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading