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

fix: legend sets fail to load in table with data dimension in the row (DHIS2-12830) v38 #2900

Merged
merged 1 commit into from
Nov 9, 2023
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
20 changes: 20 additions & 0 deletions cypress/integration/options/legend.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
visTypeDisplayNames,
DIMENSION_ID_PERIOD,
AXIS_ID_COLUMNS,
AXIS_ID_ROWS,
} from '@dhis2/analytics'
import {
expectChartTitleToBeVisible,
Expand Down Expand Up @@ -338,6 +339,25 @@ describe('Options - Legend', () => {
expectLegendKeyToBeVisible()
expectLegedKeyItemAmountToBe(1)
})
it('legend is applied when data is in rows', () => {
// swap data and period
openContextMenu(DIMENSION_ID_PERIOD)
clickContextMenuMove(DIMENSION_ID_PERIOD, AXIS_ID_COLUMNS)
openContextMenu(DIMENSION_ID_DATA)
clickContextMenuMove(DIMENSION_ID_DATA, AXIS_ID_ROWS)
clickMenuBarUpdateButton()

// expect legend to still be applied
expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE)
expectLegendKeyToBeVisible()
expectLegedKeyItemAmountToBe(1)
cy.getBySel(valueCellEl).each(($el) => {
cy.wrap($el)
.invoke('attr', 'style')
.should('not.contain', 'background-color')
.and('not.contain', EXPECTED_STANDARD_TEXT_COLOR)
})
})
})
describe('Transferring a legend: Pivot table -> Gauge', () => {
const TEST_ITEM = TEST_ITEMS[0]
Expand Down
4 changes: 3 additions & 1 deletion packages/plugin/src/VisualizationPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM,
isLegendSetType,
VIS_TYPE_LINE,
DIMENSION_ID_DATA,
} from '@dhis2/analytics'
import { useDataEngine } from '@dhis2/app-runtime'
import { Button, IconLegend24, Layer } from '@dhis2/ui'
Expand Down Expand Up @@ -212,8 +213,9 @@ export const VisualizationPlugin = ({
case LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM:
{
if (
fetchResult.visualization.type !== VIS_TYPE_PIVOT_TABLE &&
!fetchResult.visualization.columns.some(
(item) => item.dimension === 'dx'
(item) => item.dimension === DIMENSION_ID_DATA
)
) {
break
Expand Down
Loading