feat: configurable decimal precision for automatic legends [PR4] [DHIS2-18242]#3648
Open
BRaimbault wants to merge 14 commits into
Open
feat: configurable decimal precision for automatic legends [PR4] [DHIS2-18242]#3648BRaimbault wants to merge 14 commits into
BRaimbault wants to merge 14 commits into
Conversation
…ect [DHIS2-19203]
Contributor
|
🚀 Deployed on https://pr-3648.maps.netlify.dhis2.org |
3442e70 to
c520c9b
Compare
78342d0 to
070dd74
Compare
BRaimbault
commented
Apr 26, 2026
Collaborator
Author
BRaimbault
left a comment
There was a problem hiding this comment.
Ready for review.
396fabe to
1261149
Compare
|
edoardo
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Parent
Implements
Overview
Fourth PR in the series extracted from the parent epic. Adds a
legendDecimalPlacessetting that controls how many decimal places are shown in automatic legend range labels, and fixes four smaller issues surfaced during the same work.Changes
Configurable decimal precision for automatic legends DHIS2-3156
A new
DecimalPlacesSelectcomponent (0–6 places) is added to the Classification and Single Color panels for automatic and single-color legends. The selected value is stored in Redux via a newSET_LEGEND_DECIMAL_PLACESaction and persisted intolayer.configJSON on save (viafavorites.js) and parsed back on load (viaparseJsonConfig).getLegendItemsaccepts aprecisionoption that rounds bin boundaries viagetRoundToPrecisionFn.getAutomaticLegendItemsacceptslegendDecimalPlacesand stampsdecimalPlacesonto each item. BothLegendItemRangeandBubbles.jsxread per-itemdecimalPlacesand pass it asprecisiontoformatWithSeparator, so legend range labels and bubble text labels render with the configured precision.styleByDataItem.jspropagateslegendDecimalPlacesfor event layer style-by-data-item.legendDecimalPlacesis added tovalidLayerPropertiesso it survives thepickincleanMapConfig.Note that values are displayed using their stored precision; this setting only affects legend formatting. Also, range is only passed to the data table for Thematic Automatic and Prefefined legends, this behavior is not modified.
Files:
src/util/classify.js,src/util/legend.js,src/util/config.js,src/util/favorites.js,src/util/styleByDataItem.js,src/components/classification/Classification.jsx,src/components/classification/DecimalPlacesSelect.jsx,src/components/classification/SingleColor.jsx,src/components/legend/Bubbles.jsx,src/components/legend/LegendItem.jsx,src/components/legend/LegendItemRange.jsx,src/loaders/thematicLoader.js,src/loaders/eventLoader.js,src/actions/layerEdit.js,src/reducers/layerEdit.js,src/constants/actionTypes.jsNUMBER data items with option sets show empty cells in the data table DHIS2-19984
When a program stage data element has
valueType = NUMBERand an associated option set, the values stored in event data are option codes (strings such as"high"or"low").eventLoaderwas runningparseFloat()on all numeric-typed headers unconditionally —parseFloat("high")=NaN.useTableDatathen typed those headers asTYPE_NUMBER, and theisNaNguard rendered the cell empty.Fixed by excluding option-set-backed headers from the
parseFloatconversion ineventLoader, and by typing them asTYPE_STRINGinuseTableDataregardless of theirvalueType.Files:
src/loaders/eventLoader.js,src/components/datatable/useTableData.jsRange column sorts lexicographically instead of numerically DHIS2-19983
The range column in the data table was typed as
TYPE_STRING, so "10 - 20" sorted before "9 - 15". Fixed by typing it asTYPE_NUMBERand providing a custom sort key that parses the range string viaparseRangeand compares bystartValue(withendValueas a tiebreaker).Files:
src/components/datatable/useTableData.jsColor picker button too narrow in option set and boolean styles DHIS2-19982
The color picker trigger button was clipped at small widths. Widened via CSS.
Files:
src/components/optionSet/OptionStyle.jsx,src/components/optionSet/styles/OptionStyle.module.cssEarth Engine style select labels the bin count field "Steps" instead of "Classes" DHIS2-19203
Renamed to "Classes" to match the label used elsewhere in the classification UI.
Files:
src/components/edit/earthEngine/StyleSelect.jsxTests update
src/util/__tests__/classify.spec.jssrc/util/__tests__/legend.spec.jssrc/util/__tests__/favorites.spec.jssrc/components/datatable/__tests__/useTableData.spec.jsxManual testing
Netlify: https://pr-3648.maps.netlify.dhis2.org/ + Instance: https://dev.im.dhis2.org/maps-app-42-3
DHIS2-3156: Decimal places option for automatic legend classification
Test maps
DHIS2-19984: Values not displayed for NUMBER data items with option sets in data table
Test map: wDv1BBwTCyQ
DHIS2-19983: Range column not sorted numerically in data table
Test map: ak918KjTtpU
DHIS2-19982: Color picker button too narrow in option set and boolean styles
Test map: YS94jSwZruA
DHIS2-19203: Earth Engine style select uses "Steps" instead of "Classes"
Test map: WO3QtOL3wL4
Quality checklist
Add N/A to items that are not applicable.