Skip to content

Commit

Permalink
refactor: hide no-data text by clearing string instead of setting opa…
Browse files Browse the repository at this point in the history
…city to 0
  • Loading branch information
HendrikThePendric committed Oct 22, 2024
1 parent 3065022 commit fa6f221
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/visualizations/config/adapters/dhis_highcharts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import getExporting from './exporting.js'
import getScatterData from './getScatterData.js'
import getSortedConfig from './getSortedConfig.js'
import getTrimmedConfig from './getTrimmedConfig.js'
import getLang from './lang.js'
import getLegend from './legend.js'
import { applyLegendSet, getLegendSetTooltip } from './legendSet.js'
import getNoData from './noData.js'
Expand Down Expand Up @@ -121,10 +122,7 @@ export default function ({ store, layout, el, extraConfig, extraOptions }) {
pane: getPane(_layout.type),

// no data + zoom
lang: {
noData: _extraOptions.noData.text,
resetZoom: _extraOptions.resetZoom.text,
},
lang: getLang(_layout.type, _extraOptions),
noData: getNoData(_layout.type),

// credits
Expand Down Expand Up @@ -242,5 +240,7 @@ export default function ({ store, layout, el, extraConfig, extraOptions }) {
// force apply extra config
Object.assign(config, extraConfig)

console.log(objectClean(config))

return objectClean(config)
}
15 changes: 15 additions & 0 deletions src/visualizations/config/adapters/dhis_highcharts/lang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { VIS_TYPE_SINGLE_VALUE } from '../../../../modules/visTypes.js'

export default function getLang(visType, extraOptions) {
return {
/* The SingleValue visualization consists of some custom SVG elements
* rendered on an empty chart. Since the chart is empty, there is never
* any data and Highcharts will show the noData text. To avoid this we
* clear the text here. */
noData:
visType === VIS_TYPE_SINGLE_VALUE
? undefined
: extraOptions.noData.text,
resetZoom: extraOptions.resetZoom.text,
}
}
7 changes: 1 addition & 6 deletions src/visualizations/config/adapters/dhis_highcharts/noData.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { VIS_TYPE_SINGLE_VALUE } from '../../../../modules/visTypes.js'

export default function (visualizationType) {
export default function () {
return {
style: {
fontSize: '13px',
fontWeight: 'normal',
/* Hide no data label for single value visualizations because
* the data is always missing. */
opacity: visualizationType === VIS_TYPE_SINGLE_VALUE ? 0 : 1,
},
}
}

0 comments on commit fa6f221

Please sign in to comment.