Skip to content

Commit

Permalink
Merge branch 'feat/single-value-as-highcharts-chart-DHIS2-17928' of g…
Browse files Browse the repository at this point in the history
…ithub.com:dhis2/analytics into feat/single-value-as-highcharts-chart-DHIS2-17928
  • Loading branch information
HendrikThePendric committed Sep 23, 2024
2 parents b397268 + bbdd316 commit f4a4943
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 52 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## [26.8.5](https://github.com/dhis2/analytics/compare/v26.8.4...v26.8.5) (2024-09-22)


### Bug Fixes

* **translations:** sync translations from transifex (master) ([6285f9a](https://github.com/dhis2/analytics/commit/6285f9a43d7adf2b61bbe8bfbaae865380fb8b8a))

## [26.8.4](https://github.com/dhis2/analytics/compare/v26.8.3...v26.8.4) (2024-09-12)


### Bug Fixes

* add translucent prop to CachedDataQueryProvider (DHIS2-18029) ([#1699](https://github.com/dhis2/analytics/issues/1699)) ([ae4dbe6](https://github.com/dhis2/analytics/commit/ae4dbe63add659b4a2d0c8aab543721b0a85ab60))

## [26.8.3](https://github.com/dhis2/analytics/compare/v26.8.2...v26.8.3) (2024-08-27)


### Bug Fixes

* compute subtotals/totals for boolean types (DHIS2-9155) ([#1696](https://github.com/dhis2/analytics/issues/1696)) ([3392d78](https://github.com/dhis2/analytics/commit/3392d783b51dd8715beb09b673e567580005a0a2))

## [26.8.2](https://github.com/dhis2/analytics/compare/v26.8.1...v26.8.2) (2024-08-27)


### Bug Fixes

* add AO TYPE for event chart and event report ([#1697](https://github.com/dhis2/analytics/issues/1697)) ([efff1c8](https://github.com/dhis2/analytics/commit/efff1c81845a974fe8c60b593e6bbe42c19682d7))

## [26.8.1](https://github.com/dhis2/analytics/compare/v26.8.0...v26.8.1) (2024-08-08)


Expand Down
10 changes: 8 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-06-26T14:09:30.876Z\n"
"PO-Revision-Date: 2024-06-26T14:09:30.876Z\n"
"POT-Creation-Date: 2024-08-27T11:29:09.031Z\n"
"PO-Revision-Date: 2024-08-27T11:29:09.033Z\n"

msgid "view only"
msgstr "view only"
Expand Down Expand Up @@ -67,6 +67,12 @@ msgstr "About this line list"
msgid "About this visualization"
msgstr "About this visualization"

msgid "About this event chart"
msgstr "About this event chart"

msgid "About this event report"
msgstr "About this event report"

msgid "This app could not retrieve required data."
msgstr "This app could not retrieve required data."

Expand Down
74 changes: 40 additions & 34 deletions i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2024-01-25T12:05:03.360Z\n"
"POT-Creation-Date: 2024-08-27T11:29:09.031Z\n"
"PO-Revision-Date: 2020-04-28 22:05+0000\n"
"Last-Translator: Enzo Nicolas Rossi <[email protected]>, 2024\n"
"Language-Team: Spanish (https://app.transifex.com/hisp-uio/teams/100509/es/)\n"
Expand Down Expand Up @@ -86,6 +86,12 @@ msgstr "Acerca de este listado"
msgid "About this visualization"
msgstr "Acerca de esta visualización"

msgid "About this event chart"
msgstr "Acerca de este gráfico de eventos"

msgid "About this event report"
msgstr "Acerca de este informe"

msgid "This app could not retrieve required data."
msgstr "Esta aplicación no pudo recuperar los datos requeridos."

Expand Down Expand Up @@ -456,39 +462,6 @@ msgstr "No se pudo actualizar la interpretación"
msgid "Enter interpretation text"
msgstr "Introducir el texto de la interpretación"

msgid "Bold text"
msgstr "Texto en negrita"

msgid "Italic text"
msgstr "Texto en cursiva"

msgid "Link to a URL"
msgstr "Enlace a una URL"

msgid "Mention a user"
msgstr "Mencionar a un usuario"

msgid "Add emoji"
msgstr "Añadir emoji"

msgid "Preview"
msgstr "Vista previa"

msgid "Back to write mode"
msgstr "Volver al modo de escritura"

msgid "Too many results. Try refining the search."
msgstr "Demasiados resultados. Intenta refinar la búsqueda."

msgid "Search for a user"
msgstr "Buscar un usuario"

msgid "Searching for \"{{- searchText}}\""
msgstr "Buscando \"{{- searchText}}\""

msgid "No results found"
msgstr "No results found"

msgid "Not available offline"
msgstr "No disponible sin conexión a internet"

Expand Down Expand Up @@ -916,6 +889,27 @@ msgstr "Años fiscales"
msgid "Years"
msgstr "Años"

msgid "Bold text"
msgstr "Texto en negrita"

msgid "Italic text"
msgstr "Texto en cursiva"

msgid "Link to a URL"
msgstr "Enlace a una URL"

msgid "Mention a user"
msgstr "Mencionar a un usuario"

msgid "Add emoji"
msgstr "Añadir emoji"

msgid "Preview"
msgstr "Vista previa"

msgid "Back to write mode"
msgstr "Volver al modo de escritura"

msgid "Interpretations and details"
msgstr "Interpretaciones y detalles"

Expand Down Expand Up @@ -946,6 +940,18 @@ msgstr "No se pudieron cargar las traducciones"
msgid "Retry"
msgstr "Reintentar"

msgid "Too many results. Try refining the search."
msgstr "Demasiados resultados. Intenta refinar la búsqueda."

msgid "Search for a user"
msgstr "Buscar un usuario"

msgid "Searching for \"{{- searchText}}\""
msgstr "Buscando \"{{- searchText}}\""

msgid "No results found"
msgstr "No results found"

msgid "Series"
msgstr "Series"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dhis2/analytics",
"version": "26.8.1",
"version": "26.8.5",
"main": "./build/cjs/index.js",
"module": "./build/es/index.js",
"exports": {
Expand Down
14 changes: 14 additions & 0 deletions src/components/AboutAOUnit/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import i18n from '@dhis2/d2-i18n'
export const AO_TYPE_VISUALIZATION = 'visualization'
export const AO_TYPE_MAP = 'map'
export const AO_TYPE_EVENT_VISUALIZATION = 'eventVisualization'
export const AO_TYPE_EVENT_CHART = 'eventChart'
export const AO_TYPE_EVENT_REPORT = 'eventReport'

export const AOTypeMap = {
[AO_TYPE_VISUALIZATION]: {
Expand All @@ -14,6 +16,12 @@ export const AOTypeMap = {
[AO_TYPE_EVENT_VISUALIZATION]: {
apiEndpoint: 'eventVisualizations',
},
[AO_TYPE_EVENT_CHART]: {
apiEndpoint: 'eventCharts',
},
[AO_TYPE_EVENT_REPORT]: {
apiEndpoint: 'eventReports',
},
}

const NO_TYPE = 'NO_TYPE'
Expand All @@ -28,6 +36,12 @@ const texts = {
[AO_TYPE_VISUALIZATION]: {
unitTitle: i18n.t('About this visualization'),
},
[AO_TYPE_EVENT_CHART]: {
unitTitle: i18n.t('About this event chart'),
},
[AO_TYPE_EVENT_REPORT]: {
unitTitle: i18n.t('About this event report'),
},
[NO_TYPE]: {
unitTitle: i18n.t('About this visualization'),
},
Expand Down
10 changes: 8 additions & 2 deletions src/components/CachedDataQueryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ import React, { createContext, useContext } from 'react'

const CachedDataQueryCtx = createContext({})

const CachedDataQueryProvider = ({ query, dataTransformation, children }) => {
const CachedDataQueryProvider = ({
query,
dataTransformation,
children,
translucent = true,
}) => {
const { data: rawData, ...rest } = useDataQuery(query)
const { error, loading } = rest
const data =
rawData && dataTransformation ? dataTransformation(rawData) : rawData

if (loading) {
return (
<Layer translucent>
<Layer translucent={translucent}>
<CenteredContent>
<CircularLoader />
</CenteredContent>
Expand Down Expand Up @@ -43,6 +48,7 @@ CachedDataQueryProvider.propTypes = {
children: PropTypes.node.isRequired,
query: PropTypes.object.isRequired,
dataTransformation: PropTypes.func,
translucent: PropTypes.bool,
}

const useCachedDataQuery = () => useContext(CachedDataQueryCtx)
Expand Down
20 changes: 10 additions & 10 deletions src/modules/__tests__/renderValue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ const tests = [
// Numbers
{
value: 1000.5,
expected: '1 000.5',
expected: '1 000.50',
valueType: VALUE_TYPE_NUMBER,
round: true,
dgs: DGS_SPACE,
},
{
value: 33777889.55,
expected: '33,777,889.5',
value: 33777889.555,
expected: '33,777,889.55',
valueType: VALUE_TYPE_NUMBER,
round: true,
dgs: DGS_COMMA,
},
{
value: 33777889.556,
expected: '33 777 889.6',
expected: '33 777 889.56',
valueType: VALUE_TYPE_NUMBER,
round: true,
dgs: DGS_SPACE,
Expand All @@ -53,7 +53,7 @@ const tests = [
},
{
value: 33777889.56,
expected: '33777889.6',
expected: '33777889.56',
valueType: VALUE_TYPE_NUMBER,
round: true,
dgs: DGS_NONE,
Expand All @@ -74,7 +74,7 @@ const tests = [
},
{
value: 1.101,
expected: '1.1',
expected: '1.10',
valueType: VALUE_TYPE_NUMBER,
round: true,
dgs: DGS_SPACE,
Expand Down Expand Up @@ -135,16 +135,16 @@ const tests = [
dgs: DGS_SPACE,
},
{
value: -0.0234,
expected: '-2.3%',
value: -0.02345,
expected: '-2.34%',
valueType: VALUE_TYPE_NUMBER,
numberType: NUMBER_TYPE_ROW_PERCENTAGE,
round: true,
dgs: DGS_SPACE,
},
{
value: -0.0234,
expected: '-2.34%',
value: -0.02345,
expected: '-2.345%',
valueType: VALUE_TYPE_NUMBER,
numberType: NUMBER_TYPE_ROW_PERCENTAGE,
round: false,
Expand Down
17 changes: 15 additions & 2 deletions src/modules/pivotTable/PivotTableEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import {
} from '../dataTypes.js'
import { DIMENSION_ID_ORGUNIT } from '../predefinedDimensions.js'
import { renderValue } from '../renderValue.js'
import { VALUE_TYPE_NUMBER, VALUE_TYPE_TEXT } from '../valueTypes.js'
import {
VALUE_TYPE_NUMBER,
VALUE_TYPE_TEXT,
isBooleanValueType,
isNumericValueType,
} from '../valueTypes.js'
import { AdaptiveClippingController } from './AdaptiveClippingController.js'
import { addToTotalIfNumber } from './addToTotalIfNumber.js'
import { parseValue } from './parseValue.js'
Expand Down Expand Up @@ -744,7 +749,15 @@ export class PivotTableEngine {
totalCell.valueType = currentValueType
}

if (dxDimension?.valueType === VALUE_TYPE_NUMBER) {
// compute subtotals and totals for all numeric and boolean value types
// in that case, force value type of subtotal and total cells to NUMBER to format them correctly
// (see DHIS2-9155)
if (
isNumericValueType(dxDimension?.valueType) ||
isBooleanValueType(dxDimension?.valueType)
) {
totalCell.valueType = VALUE_TYPE_NUMBER

dataFields.forEach((field) => {
const headerIndex = this.dimensionLookup.dataHeaders[field]
const value = parseValue(dataRow[headerIndex])
Expand Down
2 changes: 1 addition & 1 deletion src/modules/renderValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const toFixedPrecisionString = (value, skipRounding) => {
return value
}

const precision = skipRounding ? 10 : value > -1 && value < 1 ? 2 : 1
const precision = skipRounding ? 10 : 2

return value.toFixed(precision)
}
Expand Down

0 comments on commit f4a4943

Please sign in to comment.