diff --git a/src/main/resources/lib/ssb/parts/highcharts/data/tbProcessor.ts b/src/main/resources/lib/ssb/parts/highcharts/data/tbProcessor.ts index bbec72681..7baf13c2f 100644 --- a/src/main/resources/lib/ssb/parts/highcharts/data/tbProcessor.ts +++ b/src/main/resources/lib/ssb/parts/highcharts/data/tbProcessor.ts @@ -19,7 +19,7 @@ export function seriesAndCategoriesFromTbml( const thead: Array = data.tbml.presentation.table.thead const rows: TableRowUniform['tr'] = tbody[0].tr const headerRows: Array = 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 = determineSeries(graphType, headers, categories, rows, xAxisType) @@ -30,6 +30,15 @@ export function seriesAndCategoriesFromTbml( } } +function getHeaders(headerRows: TableCellUniform, body: Array): 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'], diff --git a/src/main/resources/site/parts/highchart/highchart.ts b/src/main/resources/site/parts/highchart/highchart.ts index 8f331bbfe..bd4904614 100644 --- a/src/main/resources/site/parts/highchart/highchart.ts +++ b/src/main/resources/site/parts/highchart/highchart.ts @@ -168,7 +168,6 @@ function createDataFromDataSource( highchart.data.dataSource.tbprocessor?.urlOrId ? getDataset(type, UNPUBLISHED_DATASET_BRANCH, getTbprocessorKey(highchart)) : null - // get dataset const datasetFromRepo: DatasetRepoNode | undefined = draftData ? draftData