@dhis2/analytics 26.8.6 → 26.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/build/cjs/__demo__/SingleValue.stories.js +706 -0
  2. package/build/cjs/components/PivotTable/PivotTableValueCell.js +6 -2
  3. package/build/cjs/components/PivotTable/styles/PivotTable.style.js +2 -2
  4. package/build/cjs/locales/en/translations.json +2 -0
  5. package/build/cjs/locales/lo/translations.json +16 -12
  6. package/build/cjs/modules/pivotTable/PivotTableEngine.js +59 -24
  7. package/build/cjs/modules/pivotTable/pivotTableConstants.js +6 -2
  8. package/build/cjs/modules/valueTypes.js +4 -1
  9. package/build/cjs/visualizations/config/adapters/dhis_highcharts/chart/default.js +26 -0
  10. package/build/cjs/visualizations/config/adapters/dhis_highcharts/chart/index.js +18 -0
  11. package/build/cjs/visualizations/config/adapters/dhis_highcharts/chart/singleValue.js +19 -0
  12. package/build/cjs/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js +36 -0
  13. package/build/cjs/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueBackgroundColor.js +12 -0
  14. package/build/cjs/visualizations/config/adapters/{dhis_dhis/value/index.js → dhis_highcharts/customSVGOptions/singleValue/getSingleValueFormattedValue.js} +8 -6
  15. package/build/cjs/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueLegendColor.js +11 -0
  16. package/build/cjs/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueSubtext.js +11 -0
  17. package/build/cjs/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTextColor.js +20 -0
  18. package/build/cjs/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTitleColor.js +26 -0
  19. package/build/cjs/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/index.js +31 -0
  20. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/index.js +24 -0
  21. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/index.js +18 -0
  22. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/addIconElement.js +34 -0
  23. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/checkIfFitsWithinContainer.js +19 -0
  24. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/computeLayoutRect.js +39 -0
  25. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/computeSpacingTop.js +21 -0
  26. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/constants.js +11 -0
  27. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/getAvailableSpace.js +14 -0
  28. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/index.js +48 -0
  29. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/positionElements.js +46 -0
  30. package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/styles.js +109 -0
  31. package/build/cjs/visualizations/config/adapters/dhis_highcharts/exporting.js +30 -0
  32. package/build/cjs/visualizations/config/adapters/dhis_highcharts/index.js +33 -23
  33. package/build/cjs/visualizations/config/adapters/dhis_highcharts/lang.js +17 -0
  34. package/build/cjs/visualizations/config/adapters/dhis_highcharts/plotOptions.js +1 -1
  35. package/build/cjs/visualizations/config/adapters/dhis_highcharts/series/index.js +5 -1
  36. package/build/cjs/visualizations/config/adapters/dhis_highcharts/subtitle/__tests__/singleValue.spec.js +62 -0
  37. package/build/cjs/visualizations/config/adapters/dhis_highcharts/subtitle/index.js +56 -22
  38. package/build/cjs/visualizations/config/adapters/dhis_highcharts/subtitle/singleValue.js +27 -0
  39. package/build/cjs/visualizations/config/adapters/dhis_highcharts/title/__tests__/singleValue.spec.js +44 -0
  40. package/build/cjs/visualizations/config/adapters/dhis_highcharts/title/index.js +50 -22
  41. package/build/cjs/visualizations/config/adapters/dhis_highcharts/title/singleValue.js +31 -0
  42. package/build/cjs/visualizations/config/adapters/dhis_highcharts/type.js +2 -0
  43. package/build/cjs/visualizations/config/adapters/dhis_highcharts/xAxis/index.js +1 -0
  44. package/build/cjs/visualizations/config/adapters/dhis_highcharts/yAxis/index.js +4 -5
  45. package/build/cjs/visualizations/config/adapters/index.js +2 -4
  46. package/build/cjs/visualizations/config/generators/highcharts/index.js +8 -0
  47. package/build/cjs/visualizations/config/generators/highcharts/pdfExportBugFixPlugin/index.js +13 -0
  48. package/build/cjs/visualizations/config/generators/highcharts/pdfExportBugFixPlugin/nonASCIIFont.js +17 -0
  49. package/build/cjs/visualizations/config/generators/highcharts/pdfExportBugFixPlugin/textShadow.js +289 -0
  50. package/build/cjs/visualizations/config/generators/index.js +2 -4
  51. package/build/cjs/visualizations/store/adapters/dhis_highcharts/index.js +3 -0
  52. package/build/cjs/visualizations/store/adapters/dhis_highcharts/singleValue.js +10 -0
  53. package/build/cjs/visualizations/store/adapters/index.js +2 -4
  54. package/build/cjs/visualizations/util/shouldUseContrastColor.js +24 -0
  55. package/build/es/__demo__/SingleValue.stories.js +702 -0
  56. package/build/es/components/PivotTable/PivotTableValueCell.js +6 -2
  57. package/build/es/components/PivotTable/styles/PivotTable.style.js +2 -2
  58. package/build/es/locales/en/translations.json +2 -0
  59. package/build/es/locales/lo/translations.json +16 -12
  60. package/build/es/modules/pivotTable/PivotTableEngine.js +61 -26
  61. package/build/es/modules/pivotTable/pivotTableConstants.js +4 -1
  62. package/build/es/modules/valueTypes.js +2 -0
  63. package/build/es/visualizations/config/adapters/dhis_highcharts/chart/default.js +19 -0
  64. package/build/es/visualizations/config/adapters/dhis_highcharts/chart/index.js +11 -0
  65. package/build/es/visualizations/config/adapters/dhis_highcharts/chart/singleValue.js +12 -0
  66. package/build/es/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js +29 -0
  67. package/build/es/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueBackgroundColor.js +6 -0
  68. package/build/es/visualizations/config/adapters/{dhis_dhis/value/index.js → dhis_highcharts/customSVGOptions/singleValue/getSingleValueFormattedValue.js} +4 -4
  69. package/build/es/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueLegendColor.js +5 -0
  70. package/build/es/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueSubtext.js +5 -0
  71. package/build/es/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTextColor.js +14 -0
  72. package/build/es/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTitleColor.js +20 -0
  73. package/build/es/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/index.js +25 -0
  74. package/build/es/visualizations/config/adapters/dhis_highcharts/events/index.js +16 -0
  75. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/index.js +11 -0
  76. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/addIconElement.js +28 -0
  77. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/checkIfFitsWithinContainer.js +13 -0
  78. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/computeLayoutRect.js +33 -0
  79. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/computeSpacingTop.js +15 -0
  80. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/constants.js +4 -0
  81. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/getAvailableSpace.js +8 -0
  82. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/index.js +42 -0
  83. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/positionElements.js +40 -0
  84. package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/styles.js +101 -0
  85. package/build/es/visualizations/config/adapters/dhis_highcharts/exporting.js +23 -0
  86. package/build/es/visualizations/config/adapters/dhis_highcharts/index.js +23 -13
  87. package/build/es/visualizations/config/adapters/dhis_highcharts/lang.js +11 -0
  88. package/build/es/visualizations/config/adapters/dhis_highcharts/plotOptions.js +1 -1
  89. package/build/es/visualizations/config/adapters/dhis_highcharts/series/index.js +6 -2
  90. package/build/es/visualizations/config/adapters/dhis_highcharts/subtitle/__tests__/singleValue.spec.js +59 -0
  91. package/build/es/visualizations/config/adapters/dhis_highcharts/subtitle/index.js +56 -24
  92. package/build/es/visualizations/config/adapters/dhis_highcharts/subtitle/singleValue.js +14 -0
  93. package/build/es/visualizations/config/adapters/dhis_highcharts/title/__tests__/singleValue.spec.js +42 -0
  94. package/build/es/visualizations/config/adapters/dhis_highcharts/title/index.js +52 -24
  95. package/build/es/visualizations/config/adapters/dhis_highcharts/title/singleValue.js +18 -0
  96. package/build/es/visualizations/config/adapters/dhis_highcharts/type.js +3 -1
  97. package/build/es/visualizations/config/adapters/dhis_highcharts/xAxis/index.js +2 -1
  98. package/build/es/visualizations/config/adapters/dhis_highcharts/yAxis/index.js +5 -6
  99. package/build/es/visualizations/config/adapters/index.js +1 -3
  100. package/build/es/visualizations/config/generators/highcharts/index.js +8 -0
  101. package/build/es/visualizations/config/generators/highcharts/pdfExportBugFixPlugin/index.js +6 -0
  102. package/build/es/visualizations/config/generators/highcharts/pdfExportBugFixPlugin/nonASCIIFont.js +11 -0
  103. package/build/es/visualizations/config/generators/highcharts/pdfExportBugFixPlugin/textShadow.js +283 -0
  104. package/build/es/visualizations/config/generators/index.js +1 -3
  105. package/build/es/visualizations/store/adapters/dhis_highcharts/index.js +4 -1
  106. package/build/es/visualizations/store/adapters/dhis_highcharts/singleValue.js +4 -0
  107. package/build/es/visualizations/store/adapters/index.js +1 -3
  108. package/build/es/visualizations/util/shouldUseContrastColor.js +17 -0
  109. package/package.json +1 -2
  110. package/build/cjs/visualizations/config/adapters/dhis_dhis/index.js +0 -39
  111. package/build/cjs/visualizations/config/adapters/dhis_dhis/subtitle/__tests__/index.spec.js +0 -49
  112. package/build/cjs/visualizations/config/adapters/dhis_dhis/subtitle/__tests__/singleValue.spec.js +0 -15
  113. package/build/cjs/visualizations/config/adapters/dhis_dhis/subtitle/index.js +0 -34
  114. package/build/cjs/visualizations/config/adapters/dhis_dhis/subtitle/singleValue.js +0 -11
  115. package/build/cjs/visualizations/config/adapters/dhis_dhis/title/__tests__/index.spec.js +0 -39
  116. package/build/cjs/visualizations/config/adapters/dhis_dhis/title/__tests__/singleValue.spec.js +0 -17
  117. package/build/cjs/visualizations/config/adapters/dhis_dhis/title/index.js +0 -31
  118. package/build/cjs/visualizations/config/adapters/dhis_dhis/title/singleValue.js +0 -18
  119. package/build/cjs/visualizations/config/adapters/dhis_dhis/type.js +0 -19
  120. package/build/cjs/visualizations/config/adapters/dhis_highcharts/chart.js +0 -39
  121. package/build/cjs/visualizations/config/generators/dhis/index.js +0 -28
  122. package/build/cjs/visualizations/config/generators/dhis/singleValue.js +0 -359
  123. package/build/cjs/visualizations/store/adapters/dhis_dhis/index.js +0 -83
  124. package/build/cjs/visualizations/store/adapters/dhis_dhis/singleValue.js +0 -10
  125. package/build/es/visualizations/config/adapters/dhis_dhis/index.js +0 -30
  126. package/build/es/visualizations/config/adapters/dhis_dhis/subtitle/__tests__/index.spec.js +0 -46
  127. package/build/es/visualizations/config/adapters/dhis_dhis/subtitle/__tests__/singleValue.spec.js +0 -12
  128. package/build/es/visualizations/config/adapters/dhis_dhis/subtitle/index.js +0 -27
  129. package/build/es/visualizations/config/adapters/dhis_dhis/subtitle/singleValue.js +0 -4
  130. package/build/es/visualizations/config/adapters/dhis_dhis/title/__tests__/index.spec.js +0 -36
  131. package/build/es/visualizations/config/adapters/dhis_dhis/title/__tests__/singleValue.spec.js +0 -14
  132. package/build/es/visualizations/config/adapters/dhis_dhis/title/index.js +0 -24
  133. package/build/es/visualizations/config/adapters/dhis_dhis/title/singleValue.js +0 -11
  134. package/build/es/visualizations/config/adapters/dhis_dhis/type.js +0 -13
  135. package/build/es/visualizations/config/adapters/dhis_highcharts/chart.js +0 -32
  136. package/build/es/visualizations/config/generators/dhis/index.js +0 -21
  137. package/build/es/visualizations/config/generators/dhis/singleValue.js +0 -353
  138. package/build/es/visualizations/store/adapters/dhis_dhis/index.js +0 -76
  139. package/build/es/visualizations/store/adapters/dhis_dhis/singleValue.js +0 -4
@@ -1,3 +1,4 @@
1
+ import i18n from '@dhis2/d2-i18n';
1
2
  import PropTypes from 'prop-types';
2
3
  import React, { useRef } from 'react';
3
4
  import { applyLegendSet } from '../../modules/pivotTable/applyLegendSet.js';
@@ -7,7 +8,7 @@ import { PivotTableCell } from './PivotTableCell.js';
7
8
  import { PivotTableEmptyCell } from './PivotTableEmptyCell.js';
8
9
  import { usePivotTableEngine } from './PivotTableEngineContext.js';
9
10
  export const PivotTableValueCell = _ref => {
10
- var _cellContent$rendered;
11
+ var _cellContent$titleVal, _cellContent$rendered;
11
12
  let {
12
13
  row,
13
14
  column,
@@ -45,7 +46,10 @@ export const PivotTableValueCell = _ref => {
45
46
  return /*#__PURE__*/React.createElement(PivotTableCell, {
46
47
  key: column,
47
48
  classes: classes,
48
- title: cellContent.renderedValue,
49
+ title: (_cellContent$titleVal = cellContent.titleValue) !== null && _cellContent$titleVal !== void 0 ? _cellContent$titleVal : i18n.t('Value: {{value}}', {
50
+ value: cellContent.renderedValue,
51
+ nsSeparator: '^^'
52
+ }),
49
53
  style: style,
50
54
  onClick: isClickable ? onClick : undefined,
51
55
  ref: cellRef,
@@ -2,7 +2,7 @@ import { colors } from '@dhis2/ui';
2
2
  import { BORDER_COLOR, DISPLAY_DENSITY_PADDING_COMPACT, DISPLAY_DENSITY_PADDING_NORMAL, DISPLAY_DENSITY_PADDING_COMFORTABLE, FONT_SIZE_SMALL, FONT_SIZE_NORMAL, FONT_SIZE_LARGE } from '../../../modules/pivotTable/pivotTableConstants.js';
3
3
  export const table = [`div.pivot-table-container.jsx-3572446209{font-family:'Roboto',Arial,sans-serif;overflow:auto;color:${colors.grey900};}`, `div.pivot-table-container.jsx-3572446209 table{border-spacing:0;white-space:nowrap;box-sizing:border-box;text-align:center;border:1px solid ${BORDER_COLOR};border-width:1px 1px 0 0;}`, "div.pivot-table-container.jsx-3572446209 table.fixed-headers{border-width:0 0 0 1px;}", "div.pivot-table-container.jsx-3572446209 table.fixed-headers tr th,div.pivot-table-container.jsx-3572446209 table.fixed-headers tr td{border-width:0 1px 1px 0;}", "div.pivot-table-container.jsx-3572446209 table.fixed-column-headers{border-width:0 1px 0 0;}", "div.pivot-table-container.jsx-3572446209 table.fixed-column-headers tr th,div.pivot-table-container.jsx-3572446209 table.fixed-column-headers tr td{border-width:0 0 1px 1px;}", `div.pivot-table-container.jsx-3572446209 table.fixed-headers thead tr:first-of-type th,div.pivot-table-container.jsx-3572446209 table.fixed-column-headers thead tr:first-of-type th{border-top:1px solid ${BORDER_COLOR};}`, "div.pivot-table-container.jsx-3572446209 table.fixed-row-headers{border-width:0 0 1px 1px;}", "div.pivot-table-container.jsx-3572446209 table.fixed-row-headers tr th,div.pivot-table-container.jsx-3572446209 table.fixed-row-headers tr td{border-width:1px 1px 0 0;}"];
4
4
  table.__hash = "3572446209";
5
- export const cell = [`td.jsx-3234356038,th.jsx-3234356038{box-sizing:border-box;font-weight:normal;overflow:hidden;text-overflow:ellipsis;border:1px solid ${BORDER_COLOR};border-width:0 0 1px 1px;cursor:default;}`, "th.fixed-header.jsx-3234356038{position:-webkit-sticky;position:sticky;z-index:1;top:0;left:0;}", `.fontsize-SMALL.jsx-3234356038{font-size:${FONT_SIZE_SMALL}px;line-height:${FONT_SIZE_SMALL}px;}`, `.fontsize-NORMAL.jsx-3234356038{font-size:${FONT_SIZE_NORMAL}px;line-height:${FONT_SIZE_NORMAL}px;}`, `.fontsize-LARGE.jsx-3234356038{font-size:${FONT_SIZE_LARGE}px;line-height:${FONT_SIZE_LARGE}px;}`, `.displaydensity-COMPACT.jsx-3234356038{padding:${DISPLAY_DENSITY_PADDING_COMPACT}px;}`, `.displaydensity-NORMAL.jsx-3234356038{padding:${DISPLAY_DENSITY_PADDING_NORMAL}px;}`, `.displaydensity-COMFORTABLE.jsx-3234356038{padding:${DISPLAY_DENSITY_PADDING_COMFORTABLE}px;}`, ".column-header.jsx-3234356038{background-color:#dae6f8;}", "div.column-header-inner.jsx-3234356038{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".title-cell.jsx-3234356038{font-weight:bold;background-color:#cddaed;padding:0;}", ".title-cell-content.jsx-3234356038{text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}", `.title-cell.displaydensity-COMPACT.jsx-3234356038>.title-cell-content.jsx-3234356038{padding:${DISPLAY_DENSITY_PADDING_COMPACT}px;}`, `.title-cell.displaydensity-NORMAL.jsx-3234356038>.title-cell-content.jsx-3234356038{padding:${DISPLAY_DENSITY_PADDING_NORMAL}px;}`, `.title-cell.displaydensity-COMFORTABLE.jsx-3234356038>.title-cell-content.jsx-3234356038{padding:${DISPLAY_DENSITY_PADDING_COMFORTABLE}px;}`, ".row-header.jsx-3234356038{background-color:#dae6f8;}", ".row-header-hierarchy.jsx-3234356038{text-align:left;}", ".empty-header.jsx-3234356038{background-color:#cddaed;}", ".total-header.jsx-3234356038{background-color:#bac6d8;}", ".value.jsx-3234356038{background-color:#ffffff;text-align:left;}", ".NUMBER.jsx-3234356038,.INTEGER.jsx-3234356038,.INTEGER_POSITIVE.jsx-3234356038,.INTEGER_NEGATIVE.jsx-3234356038,.INTEGER_ZERO_OR_POSITIVE.jsx-3234356038,.UNIT_INTERVAL.jsx-3234356038,.PERCENTAGE.jsx-3234356038,.BOOLEAN.jsx-3234356038,.TRUE_ONLY.jsx-3234356038{text-align:right;}", ".clickable.jsx-3234356038{cursor:pointer;}", ".value.jsx-3234356038:hover{background-color:#f3f3f3;}", ".subtotal.jsx-3234356038{background-color:#f4f4f4;}", ".total.jsx-3234356038{background-color:#d8d8d8;}", ".column-header-label.jsx-3234356038{overflow:hidden;text-overflow:ellipsis;}"];
6
- cell.__hash = "3234356038";
5
+ export const cell = [`td.jsx-2444037071,th.jsx-2444037071{box-sizing:border-box;font-weight:normal;overflow:hidden;text-overflow:ellipsis;border:1px solid ${BORDER_COLOR};border-width:0 0 1px 1px;cursor:default;}`, "th.fixed-header.jsx-2444037071{position:-webkit-sticky;position:sticky;z-index:1;top:0;left:0;}", `.fontsize-SMALL.jsx-2444037071{font-size:${FONT_SIZE_SMALL}px;line-height:${FONT_SIZE_SMALL}px;}`, `.fontsize-NORMAL.jsx-2444037071{font-size:${FONT_SIZE_NORMAL}px;line-height:${FONT_SIZE_NORMAL}px;}`, `.fontsize-LARGE.jsx-2444037071{font-size:${FONT_SIZE_LARGE}px;line-height:${FONT_SIZE_LARGE}px;}`, `.displaydensity-COMPACT.jsx-2444037071{padding:${DISPLAY_DENSITY_PADDING_COMPACT}px;}`, `.displaydensity-NORMAL.jsx-2444037071{padding:${DISPLAY_DENSITY_PADDING_NORMAL}px;}`, `.displaydensity-COMFORTABLE.jsx-2444037071{padding:${DISPLAY_DENSITY_PADDING_COMFORTABLE}px;}`, ".column-header.jsx-2444037071{background-color:#dae6f8;}", "div.column-header-inner.jsx-2444037071{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".title-cell.jsx-2444037071{font-weight:bold;background-color:#cddaed;padding:0;}", ".title-cell-content.jsx-2444037071{text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}", `.title-cell.displaydensity-COMPACT.jsx-2444037071>.title-cell-content.jsx-2444037071{padding:${DISPLAY_DENSITY_PADDING_COMPACT}px;}`, `.title-cell.displaydensity-NORMAL.jsx-2444037071>.title-cell-content.jsx-2444037071{padding:${DISPLAY_DENSITY_PADDING_NORMAL}px;}`, `.title-cell.displaydensity-COMFORTABLE.jsx-2444037071>.title-cell-content.jsx-2444037071{padding:${DISPLAY_DENSITY_PADDING_COMFORTABLE}px;}`, ".row-header.jsx-2444037071{background-color:#dae6f8;}", ".row-header-hierarchy.jsx-2444037071{text-align:left;}", ".empty-header.jsx-2444037071{background-color:#cddaed;}", ".total-header.jsx-2444037071{background-color:#bac6d8;}", ".value.jsx-2444037071{background-color:#ffffff;text-align:left;}", ".NUMBER.jsx-2444037071,.INTEGER.jsx-2444037071,.INTEGER_POSITIVE.jsx-2444037071,.INTEGER_NEGATIVE.jsx-2444037071,.INTEGER_ZERO_OR_POSITIVE.jsx-2444037071,.UNIT_INTERVAL.jsx-2444037071,.PERCENTAGE.jsx-2444037071,.BOOLEAN.jsx-2444037071,.TRUE_ONLY.jsx-2444037071{text-align:right;}", `.N_A.jsx-2444037071{text-align:center;color:${colors.grey600};}`, ".clickable.jsx-2444037071{cursor:pointer;}", ".value.jsx-2444037071:hover{background-color:#f3f3f3;}", ".subtotal.jsx-2444037071{background-color:#f4f4f4;}", ".total.jsx-2444037071{background-color:#d8d8d8;}", ".column-header-label.jsx-2444037071{overflow:hidden;text-overflow:ellipsis;}"];
6
+ cell.__hash = "2444037071";
7
7
  export const sortIcon = [`.fontsize-SMALL.jsx-2877616992{height:${FONT_SIZE_SMALL}px;margin-bottom:1px;margin-left:5px;}`, `.fontsize-NORMAL.jsx-2877616992{height:${FONT_SIZE_NORMAL}px;max-height:11px;margin-bottom:2px;margin-left:6px;}`, `.fontsize-LARGE.jsx-2877616992{height:${FONT_SIZE_LARGE}px;margin-bottom:2px;margin-left:7px;}`];
8
8
  sortIcon.__hash = "2877616992";
@@ -267,6 +267,7 @@
267
267
  "Six-months": "Six-months",
268
268
  "Financial Years": "Financial Years",
269
269
  "Years": "Years",
270
+ "Value: {{value}}": "Value: {{value}}",
270
271
  "Bold text": "Bold text",
271
272
  "Italic text": "Italic text",
272
273
  "Link to a URL": "Link to a URL",
@@ -357,6 +358,7 @@
357
358
  "{{thresholdFactor}} × Modified Z-score high": "{{thresholdFactor}} × Modified Z-score high",
358
359
  "{{thresholdFactor}} × Z-score low": "{{thresholdFactor}} × Z-score low",
359
360
  "{{thresholdFactor}} × Z-score high": "{{thresholdFactor}} × Z-score high",
361
+ "Not applicable": "Not applicable",
360
362
  "Data": "Data",
361
363
  "Organisation unit": "Organisation unit",
362
364
  "Assigned Categories": "Assigned Categories",
@@ -18,11 +18,13 @@
18
18
  "About this map": "ກ່ຽວກັບແຜນທີ່",
19
19
  "About this line list": "ກ່ຽວກັບບັນຊີລາຍຊື່",
20
20
  "About this visualization": "ກ່ຽວກັບການສ້າງພາບຂໍ້ມູນ",
21
+ "About this event chart": "ກ່ຽວກັບເຫດການແຜນຜັງ",
22
+ "About this event report": "ກ່ຽວກັບບົດລາຍງານເຫດການຕ່າງໆ",
21
23
  "This app could not retrieve required data.": "ແອັບນີ້ບໍ່ສາມາດດຶງຂໍ້ມູນທີ່ຕ້ອງການໄດ້",
22
24
  "Network error": "ຂໍ້ຜິດພາດທາງເຄື່ອຂ່າຍ",
23
25
  "Data / Edit calculation": "ຂໍ້ມູນ / ແກ້ໄຂການຄິດໄລ່",
24
26
  "Data / New calculation": "ຂໍ້ມູນ / ຄິດໄລ່ໃໝ່",
25
- "Remove item": "ລົບລາຍການ",
27
+ "Remove item": "ເອົາລາຍການອອກ",
26
28
  "Check formula": "ກວດເບິ່ງສູດ",
27
29
  "Calculation name": "ຊື່ການຄິດໄລ່",
28
30
  "Shown in table headers and chart axes/legends": "ສະ​ແດງ​​ຢູ່​ເທິງຕາ​ຕະ​ລາງ​ ແລະ​ ແກນ​ແຜນ​ວາດ",
@@ -132,17 +134,6 @@
132
134
  "Manage sharing": "ຈັດການການເຜີຍແຜ່",
133
135
  "Could not update interpretation": "ບໍ່ສາມາດອັບເດດຂໍ້ຄວາມ",
134
136
  "Enter interpretation text": "ປ້ອນຂໍ້ຄວາມ",
135
- "Bold text": "ຕົວອັກສອນເຂັ້ມ",
136
- "Italic text": "ຕົວອັກສອນສະຫຼ່ຽງ",
137
- "Link to a URL": "ເຊື່ອມຕໍ່ກັບ URL",
138
- "Mention a user": "ກ່າວເຖິງຜູ້ໃຊ້",
139
- "Add emoji": "ເພີ່ມ emoji",
140
- "Preview": "ເບິ່ງຕົວຢ່າງ",
141
- "Back to write mode": "ກັບໄປທີ່ໂໝດຂຽນ",
142
- "Too many results. Try refining the search.": "ຜົນໄດ້ຮັບຫຼາຍເກີນໄປ. ປັບປຸງການຄົ້ນຫາ.",
143
- "Search for a user": "ຄົ້ນຫາຜູ້ໃຊ້",
144
- "Searching for \"{{- searchText}}\"": "ຄົ້ນຫາ \"{{- searchText}}\"",
145
- "No results found": "ບໍ່ພົບຜົນການຊອກຫາ",
146
137
  "Not available offline": "ບໍ່ສາມາດໃຊ້ໄດ້ອອບລາຍ",
147
138
  "Created by": "ສ້າງໂດຍ",
148
139
  "Anyone": "ທຸກຄົນ",
@@ -271,6 +262,14 @@
271
262
  "Six-months": "6 ເດືອນ",
272
263
  "Financial Years": "ສົກປີງົບປະມານ",
273
264
  "Years": "ປີ",
265
+ "Value: {{value}}": "",
266
+ "Bold text": "ຕົວອັກສອນເຂັ້ມ",
267
+ "Italic text": "ຕົວອັກສອນສະຫຼ່ຽງ",
268
+ "Link to a URL": "ເຊື່ອມຕໍ່ກັບ URL",
269
+ "Mention a user": "ກ່າວເຖິງຜູ້ໃຊ້",
270
+ "Add emoji": "ເພີ່ມ emoji",
271
+ "Preview": "ເບິ່ງຕົວຢ່າງ",
272
+ "Back to write mode": "ກັບໄປທີ່ໂໝດຂຽນ",
274
273
  "Interpretations and details": "ຂໍ້ມູນ ແລະ ລາຍລະອຽດ",
275
274
  "Translating to": "ແປເປັນ",
276
275
  "Choose a locale": "ເລືອກສະຖານທີ່ເກີດເຫດ",
@@ -281,6 +280,10 @@
281
280
  "Cannot save while offline": "ບໍ່ສາມາດບັນທຶກແບບອອບລາຍ",
282
281
  "Could not load translations": "ບໍ່ສາມາດໂຫຼດການແປ",
283
282
  "Retry": "ລອງໃໝ່",
283
+ "Too many results. Try refining the search.": "ຜົນໄດ້ຮັບຫຼາຍເກີນໄປ. ປັບປຸງການຄົ້ນຫາ.",
284
+ "Search for a user": "ຄົ້ນຫາຜູ້ໃຊ້",
285
+ "Searching for \"{{- searchText}}\"": "ຄົ້ນຫາ \"{{- searchText}}\"",
286
+ "No results found": "ບໍ່ພົບຜົນການຊອກຫາ",
284
287
  "Series": "ແທ່ງ",
285
288
  "Category": "ລວງນອນ",
286
289
  "Filter": "ຕົວກອງ",
@@ -350,6 +353,7 @@
350
353
  "{{thresholdFactor}} × Modified Z-score high": "{{thresholdFactor}} x ແກ້ໄຂຄະແນນ z ສູງ",
351
354
  "{{thresholdFactor}} × Z-score low": "{{thresholdFactor}} x ຄະແນນ z ຕ່ຳ",
352
355
  "{{thresholdFactor}} × Z-score high": "{{thresholdFactor}} x ຄະແນນ z ສູງ",
356
+ "Not applicable": "",
353
357
  "Data": "ຂໍ້ມູນ",
354
358
  "Organisation unit": "​ຫົວ​ໜ່ວຍ​ການ​ຈັດ​ຕັ້ງ",
355
359
  "Assigned Categories": "ຈັດໝວດໝູ່",
@@ -6,11 +6,11 @@ import times from 'lodash/times';
6
6
  import { DIMENSION_TYPE_DATA, DIMENSION_TYPE_DATA_ELEMENT_GROUP_SET, DIMENSION_TYPE_ORGANISATION_UNIT, DIMENSION_TYPE_PERIOD } from '../dataTypes.js';
7
7
  import { DIMENSION_ID_ORGUNIT } from '../predefinedDimensions.js';
8
8
  import { renderValue } from '../renderValue.js';
9
- import { VALUE_TYPE_NUMBER, VALUE_TYPE_TEXT, isBooleanValueType, isNumericValueType } from '../valueTypes.js';
9
+ import { VALUE_TYPE_NUMBER, VALUE_TYPE_TEXT, isBooleanValueType, isCumulativeValueType, isNumericValueType } from '../valueTypes.js';
10
10
  import { AdaptiveClippingController } from './AdaptiveClippingController.js';
11
11
  import { addToTotalIfNumber } from './addToTotalIfNumber.js';
12
12
  import { parseValue } from './parseValue.js';
13
- import { AGGREGATE_TYPE_NA, AGGREGATE_TYPE_AVERAGE, AGGREGATE_TYPE_SUM, CELL_TYPE_VALUE, CELL_TYPE_TOTAL, CELL_TYPE_SUBTOTAL, SORT_ORDER_ASCENDING, SORT_ORDER_DESCENDING, DISPLAY_DENSITY_PADDING_COMPACT, DISPLAY_DENSITY_PADDING_COMFORTABLE, DISPLAY_DENSITY_OPTION_COMFORTABLE, DISPLAY_DENSITY_OPTION_COMPACT, DISPLAY_DENSITY_OPTION_NORMAL, DISPLAY_DENSITY_PADDING_NORMAL, FONT_SIZE_OPTION_SMALL, FONT_SIZE_SMALL, FONT_SIZE_OPTION_LARGE, FONT_SIZE_LARGE, FONT_SIZE_OPTION_NORMAL, FONT_SIZE_NORMAL, NUMBER_TYPE_COLUMN_PERCENTAGE, NUMBER_TYPE_ROW_PERCENTAGE, NUMBER_TYPE_VALUE } from './pivotTableConstants.js';
13
+ import { AGGREGATE_TYPE_NA, AGGREGATE_TYPE_AVERAGE, AGGREGATE_TYPE_SUM, CELL_TYPE_VALUE, CELL_TYPE_TOTAL, CELL_TYPE_SUBTOTAL, SORT_ORDER_ASCENDING, SORT_ORDER_DESCENDING, DISPLAY_DENSITY_PADDING_COMPACT, DISPLAY_DENSITY_PADDING_COMFORTABLE, DISPLAY_DENSITY_OPTION_COMFORTABLE, DISPLAY_DENSITY_OPTION_COMPACT, DISPLAY_DENSITY_OPTION_NORMAL, DISPLAY_DENSITY_PADDING_NORMAL, FONT_SIZE_OPTION_SMALL, FONT_SIZE_SMALL, FONT_SIZE_OPTION_LARGE, FONT_SIZE_LARGE, FONT_SIZE_OPTION_NORMAL, FONT_SIZE_NORMAL, NUMBER_TYPE_COLUMN_PERCENTAGE, NUMBER_TYPE_ROW_PERCENTAGE, NUMBER_TYPE_VALUE, VALUE_TYPE_NA, VALUE_NA } from './pivotTableConstants.js';
14
14
  const dataFields = ['value', 'numerator', 'denominator', 'factor', 'multiplier', 'divisor'];
15
15
  const defaultOptions = {
16
16
  hideEmptyColumns: false,
@@ -153,7 +153,7 @@ const applyTotalAggregationType = (_ref2, overrideTotalAggregationType) => {
153
153
  } = _ref2;
154
154
  switch (overrideTotalAggregationType || totalAggregationType) {
155
155
  case AGGREGATE_TYPE_NA:
156
- return 'N/A';
156
+ return VALUE_NA;
157
157
  case AGGREGATE_TYPE_AVERAGE:
158
158
  return (numerator || value) * multiplier / (denominator * divisor || 1);
159
159
  case AGGREGATE_TYPE_SUM:
@@ -258,15 +258,29 @@ export class PivotTableEngine {
258
258
  rawCell.rawValue = rawValue;
259
259
  rawCell.renderedValue = renderedValue;
260
260
  }
261
+ if ([CELL_TYPE_TOTAL, CELL_TYPE_SUBTOTAL].includes(rawCell.cellType) && rawCell.rawValue === AGGREGATE_TYPE_NA) {
262
+ rawCell.titleValue = i18n.t('Not applicable');
263
+ }
261
264
  if (this.options.cumulativeValues) {
265
+ let titleValue;
266
+ if (this.data[row] && this.data[row][column]) {
267
+ const dataRow = this.data[row][column];
268
+ const rawValue = cellType === CELL_TYPE_VALUE ? dataRow[this.dimensionLookup.dataHeaders.value] : dataRow.value;
269
+ titleValue = i18n.t('Value: {{value}}', {
270
+ value: renderValue(rawValue, valueType, this.visualization),
271
+ nsSeparator: '^^'
272
+ });
273
+ }
262
274
  const cumulativeValue = this.getCumulative({
263
275
  row,
264
276
  column
265
277
  });
266
278
  if (cumulativeValue !== undefined && cumulativeValue !== null) {
267
- // force to NUMBER for accumulated values
268
- rawCell.valueType = valueType === undefined || valueType === null ? VALUE_TYPE_NUMBER : valueType;
279
+ // force to TEXT for N/A (accumulated) values
280
+ // force to NUMBER for accumulated values if no valueType present
281
+ rawCell.valueType = cumulativeValue === VALUE_NA ? VALUE_TYPE_NA : valueType === undefined || valueType === null ? VALUE_TYPE_NUMBER : valueType;
269
282
  rawCell.empty = false;
283
+ rawCell.titleValue = titleValue;
270
284
  rawCell.rawValue = cumulativeValue;
271
285
  rawCell.renderedValue = renderValue(cumulativeValue, valueType, this.visualization);
272
286
  }
@@ -365,15 +379,12 @@ export class PivotTableEngine {
365
379
  return undefined;
366
380
  }
367
381
  const cellValue = this.data[row][column];
382
+
383
+ // empty cell
368
384
  if (!cellValue) {
369
- // Empty cell
370
- // The cell still needs to get the valueType to render correctly 0 and cumulative values
371
- return {
372
- valueType: VALUE_TYPE_NUMBER,
373
- totalAggregationType: AGGREGATE_TYPE_SUM
374
- };
385
+ return undefined;
375
386
  }
376
- if (!Array.isArray(cellValue)) {
387
+ if (cellValue && !Array.isArray(cellValue)) {
377
388
  // This is a total cell
378
389
  return {
379
390
  valueType: cellValue.valueType,
@@ -536,19 +547,26 @@ export class PivotTableEngine {
536
547
  } else {
537
548
  totalCell.totalAggregationType = currentAggType;
538
549
  }
539
- const currentValueType = dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType;
550
+
551
+ // Force value type of total cells to NUMBER for value cells with numeric or boolean types.
552
+ // This is to simplify the code below where we compare the previous value type.
553
+ // All numeric/boolean value types use the same style for rendering the total cell (right aligned content)
554
+ // and using NUMBER for the total cell is enough for that.
555
+ // (see DHIS2-9155)
556
+ const currentValueType = isNumericValueType(dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType) || isBooleanValueType(dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType) ? VALUE_TYPE_NUMBER : dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType;
540
557
  const previousValueType = totalCell.valueType;
541
558
  if (previousValueType && currentValueType !== previousValueType) {
542
- totalCell.valueType = AGGREGATE_TYPE_NA;
559
+ totalCell.valueType = VALUE_TYPE_NA;
543
560
  } else {
544
561
  totalCell.valueType = currentValueType;
545
562
  }
546
563
 
547
- // compute subtotals and totals for all numeric and boolean value types
548
- // in that case, force value type of subtotal and total cells to NUMBER to format them correctly
564
+ // Compute totals for all numeric and boolean value types only.
565
+ // In practice valueType here is NUMBER (see the comment above).
566
+ // When is not, it means there is some value cell with a valueType other than numeric/boolean,
567
+ // the total should not be computed then.
549
568
  // (see DHIS2-9155)
550
- if (isNumericValueType(dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType) || isBooleanValueType(dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType)) {
551
- totalCell.valueType = VALUE_TYPE_NUMBER;
569
+ if (isNumericValueType(totalCell.valueType)) {
552
570
  dataFields.forEach(field => {
553
571
  const headerIndex = this.dimensionLookup.dataHeaders[field];
554
572
  const value = parseValue(dataRow[headerIndex]);
@@ -642,6 +660,17 @@ export class PivotTableEngine {
642
660
  }
643
661
  }
644
662
  }
663
+ computeOverrideTotalAggregationType(totalCell, visualization) {
664
+ // Avoid undefined on total cells with valueTypes that cannot be totalized.
665
+ // This happens for example when a column/row has all value cells of type TEXT.
666
+ if (!(isNumericValueType(totalCell.valueType) || isBooleanValueType(totalCell.valueType))) {
667
+ return AGGREGATE_TYPE_NA;
668
+ }
669
+
670
+ // DHIS2-15698: do not override total aggregation type when numberType option is not present
671
+ // (numberType option default is VALUE)
672
+ return visualization.numberType && visualization.numberType !== NUMBER_TYPE_VALUE && AGGREGATE_TYPE_SUM;
673
+ }
645
674
  finalizeTotal(_ref11) {
646
675
  let {
647
676
  row,
@@ -652,10 +681,12 @@ export class PivotTableEngine {
652
681
  }
653
682
  const totalCell = this.data[row][column];
654
683
  if (totalCell && totalCell.count) {
655
- totalCell.value = applyTotalAggregationType(totalCell,
656
- // DHIS2-15698: do not override total aggregation type when numberType option is not present
657
- // (numberType option default is VALUE)
658
- this.visualization.numberType && this.visualization.numberType !== NUMBER_TYPE_VALUE && AGGREGATE_TYPE_SUM);
684
+ totalCell.value = applyTotalAggregationType(totalCell, this.computeOverrideTotalAggregationType(totalCell, this.visualization));
685
+
686
+ // override valueType for styling cells with N/A value
687
+ if (totalCell.value === AGGREGATE_TYPE_NA) {
688
+ totalCell.valueType = VALUE_TYPE_NA;
689
+ }
659
690
  this.adaptiveClippingController.add({
660
691
  row,
661
692
  column
@@ -756,10 +787,14 @@ export class PivotTableEngine {
756
787
  column
757
788
  });
758
789
  const valueType = (dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType) || VALUE_TYPE_TEXT;
790
+ const totalAggregationType = dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.totalAggregationType;
759
791
 
760
- // only accumulate numeric values
761
- // accumulating text values does not make sense
762
- if (valueType === VALUE_TYPE_NUMBER) {
792
+ // only accumulate numeric (except for PERCENTAGE and UNIT_INTERVAL) and boolean values
793
+ // accumulating other value types like text values does not make sense
794
+ if (isCumulativeValueType(valueType) && totalAggregationType === AGGREGATE_TYPE_SUM) {
795
+ // initialise to 0 for cumulative types
796
+ // (||= is not transformed correctly in Babel with the current setup)
797
+ acc || (acc = 0);
763
798
  if (this.data[row] && this.data[row][column]) {
764
799
  const dataRow = this.data[row][column];
765
800
  const rawValue = cellType === CELL_TYPE_VALUE ? dataRow[this.dimensionLookup.dataHeaders.value] : dataRow.value;
@@ -768,7 +803,7 @@ export class PivotTableEngine {
768
803
  this.accumulators.rows[row][column] = acc;
769
804
  }
770
805
  return acc;
771
- }, 0);
806
+ }, '');
772
807
  });
773
808
  } else {
774
809
  this.accumulators = {
@@ -6,6 +6,8 @@ export const CELL_TYPE_TOTAL = 'total';
6
6
  export const AGGREGATE_TYPE_SUM = 'SUM';
7
7
  export const AGGREGATE_TYPE_AVERAGE = 'AVERAGE';
8
8
  export const AGGREGATE_TYPE_NA = 'N/A';
9
+ export const VALUE_TYPE_NA = 'N_A'; // this ends up as CSS class and / is problematic
10
+
9
11
  export const NUMBER_TYPE_VALUE = 'VALUE';
10
12
  export const NUMBER_TYPE_ROW_PERCENTAGE = 'ROW_PERCENTAGE';
11
13
  export const NUMBER_TYPE_COLUMN_PERCENTAGE = 'COLUMN_PERCENTAGE';
@@ -26,4 +28,5 @@ export const CLIPPED_CELL_MAX_SIZE = 360;
26
28
  export const CLIPPED_CELL_MIN_SIZE = 36;
27
29
  export const WRAPPED_TEXT_JUSTIFY_BUFFER = 25;
28
30
  export const WRAPPED_TEXT_LINE_HEIGHT = 1.0;
29
- export const CLIPPED_AXIS_PARTITION_SIZE_PX = 1000;
31
+ export const CLIPPED_AXIS_PARTITION_SIZE_PX = 1000;
32
+ export const VALUE_NA = 'N/A';
@@ -25,5 +25,7 @@ export const VALUE_TYPE_ORGANISATION_UNIT = 'ORGANISATION_UNIT';
25
25
  export const VALUE_TYPE_AGE = 'AGE';
26
26
  const NUMERIC_VALUE_TYPES = [VALUE_TYPE_NUMBER, VALUE_TYPE_UNIT_INTERVAL, VALUE_TYPE_PERCENTAGE, VALUE_TYPE_INTEGER, VALUE_TYPE_INTEGER_POSITIVE, VALUE_TYPE_INTEGER_NEGATIVE, VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE];
27
27
  const BOOLEAN_VALUE_TYPES = [VALUE_TYPE_BOOLEAN, VALUE_TYPE_TRUE_ONLY];
28
+ const CUMULATIVE_VALUE_TYPES = [VALUE_TYPE_NUMBER, VALUE_TYPE_INTEGER, VALUE_TYPE_INTEGER_POSITIVE, VALUE_TYPE_INTEGER_NEGATIVE, VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE, ...BOOLEAN_VALUE_TYPES];
29
+ export const isCumulativeValueType = type => CUMULATIVE_VALUE_TYPES.includes(type);
28
30
  export const isNumericValueType = type => NUMERIC_VALUE_TYPES.includes(type);
29
31
  export const isBooleanValueType = type => BOOLEAN_VALUE_TYPES.includes(type);
@@ -0,0 +1,19 @@
1
+ import { getEvents } from '../events/index.js';
2
+ import getType from '../type.js';
3
+ const DEFAULT_CHART = {
4
+ spacingTop: 20,
5
+ style: {
6
+ fontFamily: 'Roboto,Helvetica Neue,Helvetica,Arial,sans-serif'
7
+ }
8
+ };
9
+ const DASHBOARD_CHART = {
10
+ spacingTop: 0,
11
+ spacingRight: 5,
12
+ spacingBottom: 2,
13
+ spacingLeft: 5
14
+ };
15
+ export default function getDefaultChart(layout, el, extraOptions) {
16
+ return Object.assign({}, getType(layout.type), {
17
+ renderTo: el || layout.el
18
+ }, DEFAULT_CHART, extraOptions.dashboard ? DASHBOARD_CHART : undefined, getEvents(layout.type));
19
+ }
@@ -0,0 +1,11 @@
1
+ import { VIS_TYPE_SINGLE_VALUE } from '../../../../../modules/visTypes.js';
2
+ import getDefaultChart from './default.js';
3
+ import getSingleValueChart from './singleValue.js';
4
+ export default function getChart(layout, el, extraOptions, series) {
5
+ switch (layout.type) {
6
+ case VIS_TYPE_SINGLE_VALUE:
7
+ return getSingleValueChart(layout, el, extraOptions, series);
8
+ default:
9
+ return getDefaultChart(layout, el, extraOptions);
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ import { getSingleValueBackgroundColor } from '../customSVGOptions/singleValue/getSingleValueBackgroundColor.js';
2
+ import getDefaultChart from './default.js';
3
+ export default function getSingleValueChart(layout, el, extraOptions, series) {
4
+ const chart = {
5
+ ...getDefaultChart(layout, el, extraOptions),
6
+ backgroundColor: getSingleValueBackgroundColor(layout.legend, extraOptions.legendSets, series[0])
7
+ };
8
+ if (extraOptions.dashboard) {
9
+ chart.spacingTop = 7;
10
+ }
11
+ return chart;
12
+ }
@@ -0,0 +1,29 @@
1
+ import { VIS_TYPE_SINGLE_VALUE } from '../../../../../modules/visTypes.js';
2
+ import getSingleValueCustomSVGOptions from './singleValue/index.js';
3
+ export default function getCustomSVGOptions(_ref) {
4
+ let {
5
+ extraConfig,
6
+ layout,
7
+ extraOptions,
8
+ metaData,
9
+ series
10
+ } = _ref;
11
+ const baseOptions = {
12
+ visualizationType: layout.type
13
+ };
14
+ switch (layout.type) {
15
+ case VIS_TYPE_SINGLE_VALUE:
16
+ return {
17
+ ...baseOptions,
18
+ ...getSingleValueCustomSVGOptions({
19
+ extraConfig,
20
+ layout,
21
+ extraOptions,
22
+ metaData,
23
+ series
24
+ })
25
+ };
26
+ default:
27
+ break;
28
+ }
29
+ }
@@ -0,0 +1,6 @@
1
+ import { LEGEND_DISPLAY_STYLE_FILL } from '../../../../../../modules/legends.js';
2
+ import { getSingleValueLegendColor } from './getSingleValueLegendColor.js';
3
+ export function getSingleValueBackgroundColor(legendOptions, legendSets, value) {
4
+ const legendColor = getSingleValueLegendColor(legendOptions, legendSets, value);
5
+ return legendColor && legendOptions.style === LEGEND_DISPLAY_STYLE_FILL ? legendColor : 'transparent';
6
+ }
@@ -1,7 +1,7 @@
1
- import { renderValue } from '../../../../../modules/renderValue.js';
2
- import { VALUE_TYPE_TEXT } from '../../../../../modules/valueTypes.js';
3
- import { INDICATOR_FACTOR_100 } from '../index.js';
4
- export default function (value, layout, metaData) {
1
+ import { renderValue } from '../../../../../../modules/renderValue.js';
2
+ import { VALUE_TYPE_TEXT } from '../../../../../../modules/valueTypes.js';
3
+ export const INDICATOR_FACTOR_100 = 100;
4
+ export function getSingleValueFormattedValue(value, layout, metaData) {
5
5
  const valueType = metaData.items[metaData.dimensions.dx[0]].valueType;
6
6
  const indicatorType = metaData.items[metaData.dimensions.dx[0]].indicatorType;
7
7
  let formattedValue = renderValue(value, valueType || VALUE_TYPE_TEXT, {
@@ -0,0 +1,5 @@
1
+ import { getColorByValueFromLegendSet } from '../../../../../../modules/legends.js';
2
+ export function getSingleValueLegendColor(legendOptions, legendSets, value) {
3
+ const legendSet = legendOptions && legendSets[0];
4
+ return legendSet ? getColorByValueFromLegendSet(legendSet, value) : undefined;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { INDICATOR_FACTOR_100 } from './getSingleValueFormattedValue.js';
2
+ export function getSingleValueSubtext(metaData) {
3
+ const indicatorType = metaData.items[metaData.dimensions.dx[0]].indicatorType;
4
+ return indicatorType !== null && indicatorType !== void 0 && indicatorType.displayName && (indicatorType === null || indicatorType === void 0 ? void 0 : indicatorType.factor) !== INDICATOR_FACTOR_100 ? indicatorType === null || indicatorType === void 0 ? void 0 : indicatorType.displayName : undefined;
5
+ }
@@ -0,0 +1,14 @@
1
+ import { colors } from '@dhis2/ui';
2
+ import { LEGEND_DISPLAY_STYLE_TEXT } from '../../../../../../modules/legends.js';
3
+ import { shouldUseContrastColor } from '../../../../../util/shouldUseContrastColor.js';
4
+ import { getSingleValueLegendColor } from './getSingleValueLegendColor.js';
5
+ export function getSingleValueTextColor(baseColor, value, legendOptions, legendSets) {
6
+ const legendColor = getSingleValueLegendColor(legendOptions, legendSets, value);
7
+ if (!legendColor) {
8
+ return baseColor;
9
+ }
10
+ if (legendOptions.style === LEGEND_DISPLAY_STYLE_TEXT) {
11
+ return legendColor;
12
+ }
13
+ return shouldUseContrastColor(legendColor) ? colors.white : baseColor;
14
+ }
@@ -0,0 +1,20 @@
1
+ import { colors } from '@dhis2/ui';
2
+ import { LEGEND_DISPLAY_STYLE_FILL } from '../../../../../../modules/legends.js';
3
+ import { shouldUseContrastColor } from '../../../../../util/shouldUseContrastColor.js';
4
+ import { getSingleValueLegendColor } from './getSingleValueLegendColor.js';
5
+ export function getSingleValueTitleColor(customColor, defaultColor, value, legendOptions, legendSets) {
6
+ // Never override custom color
7
+ if (customColor) {
8
+ return customColor;
9
+ }
10
+ const isUsingLegendBackground = (legendOptions === null || legendOptions === void 0 ? void 0 : legendOptions.style) === LEGEND_DISPLAY_STYLE_FILL;
11
+
12
+ // If not using legend background, always return default color
13
+ if (!isUsingLegendBackground) {
14
+ return defaultColor;
15
+ }
16
+ const legendColor = getSingleValueLegendColor(legendOptions, legendSets, value);
17
+
18
+ // Return default color or contrasting color when using legend background and default color
19
+ return shouldUseContrastColor(legendColor) ? colors.white : defaultColor;
20
+ }
@@ -0,0 +1,25 @@
1
+ import { colors } from '@dhis2/ui';
2
+ import { getSingleValueFormattedValue } from './getSingleValueFormattedValue.js';
3
+ import { getSingleValueSubtext } from './getSingleValueSubtext.js';
4
+ import { getSingleValueTextColor } from './getSingleValueTextColor.js';
5
+ export default function getSingleValueCustomSVGOptions(_ref) {
6
+ let {
7
+ layout,
8
+ extraOptions,
9
+ metaData,
10
+ series
11
+ } = _ref;
12
+ const {
13
+ dashboard,
14
+ icon
15
+ } = extraOptions;
16
+ const value = series[0];
17
+ return {
18
+ value,
19
+ fontColor: getSingleValueTextColor(colors.grey900, value, layout.legend, extraOptions.legendSets),
20
+ formattedValue: getSingleValueFormattedValue(value, layout, metaData),
21
+ icon,
22
+ dashboard,
23
+ subText: getSingleValueSubtext(metaData)
24
+ };
25
+ }
@@ -0,0 +1,16 @@
1
+ import loadCustomSVG from './loadCustomSVG/index.js';
2
+ export const getEvents = visType => ({
3
+ events: {
4
+ load: function () {
5
+ // Align legend icon with legend text
6
+ this.legend.allItems.forEach(item => {
7
+ if (item.legendSymbol) {
8
+ item.legendSymbol.attr({
9
+ translateY: -(item.legendItem.label.getBBox().height * 0.75 / 4) + item.legendSymbol.r / 2
10
+ });
11
+ }
12
+ });
13
+ loadCustomSVG.call(this, visType);
14
+ }
15
+ }
16
+ });
@@ -0,0 +1,11 @@
1
+ import { VIS_TYPE_SINGLE_VALUE } from '../../../../../../modules/visTypes.js';
2
+ import loadSingleValueSVG from './singleValue/index.js';
3
+ export default function loadCustomSVG(visType) {
4
+ switch (visType) {
5
+ case VIS_TYPE_SINGLE_VALUE:
6
+ loadSingleValueSVG.call(this);
7
+ break;
8
+ default:
9
+ break;
10
+ }
11
+ }
@@ -0,0 +1,28 @@
1
+ const parser = new DOMParser();
2
+ export function addIconElement(svgString, color) {
3
+ const svgIconDocument = parser.parseFromString(svgString, 'image/svg+xml');
4
+ const iconElHeight = svgIconDocument.documentElement.getAttribute('height');
5
+ const iconElWidth = svgIconDocument.documentElement.getAttribute('width');
6
+ const iconGroup = this.renderer.g('icon').attr({
7
+ color,
8
+ 'data-test': 'visualization-icon'
9
+ }).css({
10
+ visibility: 'hidden'
11
+ });
12
+
13
+ /* Force the group element to have the same dimensions as the original
14
+ * SVG image by adding this rect. This ensures the icon has the intended
15
+ * whitespace around it and makes scaling and translating easier. */
16
+ this.renderer.rect(0, 0, iconElWidth, iconElHeight).add(iconGroup);
17
+ Array.from(svgIconDocument.documentElement.children).forEach(pathNode => {
18
+ /* It is also possible to use the SVGRenderer to draw the icon but that
19
+ * approach is more error prone, so during review it was decided to just
20
+ * append the SVG children to the iconGroup using native the native DOM
21
+ * API. For reference see this commit, for an implementation using the
22
+ * SVVGRenderer:
23
+ * https://github.com/dhis2/analytics/pull/1698/commits/f95bee838e07f4cdfc3cab6e92f28f49a386a0ad */
24
+ iconGroup.element.appendChild(pathNode);
25
+ });
26
+ iconGroup.add();
27
+ return iconGroup;
28
+ }
@@ -0,0 +1,13 @@
1
+ import { ACTUAL_NUMBER_HEIGHT_FACTOR } from './constants.js';
2
+ export function checkIfFitsWithinContainer(availableSpace, valueElement, subTextElement, icon, subText, spacing) {
3
+ const valueRect = valueElement.getBBox(true);
4
+ const subTextRect = subText ? subTextElement.getBBox(true) : {
5
+ width: 0,
6
+ height: 0
7
+ };
8
+ const requiredValueWidth = icon ? valueRect.width + spacing.iconGap + spacing.iconSize : valueRect.width;
9
+ const requiredHeight = subText ? valueRect.height * ACTUAL_NUMBER_HEIGHT_FACTOR + spacing.subTextTop + subTextRect.height : valueRect.height * ACTUAL_NUMBER_HEIGHT_FACTOR;
10
+ const fitsHorizontally = availableSpace.width > requiredValueWidth && availableSpace.width > subTextRect.width;
11
+ const fitsVertically = availableSpace.height > requiredHeight;
12
+ return fitsHorizontally && fitsVertically;
13
+ }
@@ -0,0 +1,33 @@
1
+ import { computeSpacingTop } from './computeSpacingTop.js';
2
+ import { ACTUAL_NUMBER_HEIGHT_FACTOR } from './constants.js';
3
+ export function computeLayoutRect(valueElement, subTextElement, iconElement, spacing) {
4
+ const valueRect = valueElement.getBBox();
5
+ const containerCenterY = this.chartHeight / 2;
6
+ const containerCenterX = this.chartWidth / 2;
7
+ const minY = computeSpacingTop.call(this, spacing.valueTop);
8
+ let width = valueRect.width;
9
+ let height = valueRect.height * ACTUAL_NUMBER_HEIGHT_FACTOR;
10
+ let sideMarginTop = 0;
11
+ let sideMarginBottom = 0;
12
+ if (iconElement) {
13
+ width += spacing.iconGap + spacing.iconSize;
14
+ }
15
+ if (subTextElement) {
16
+ const subTextRect = subTextElement.getBBox();
17
+ if (subTextRect.width > width) {
18
+ sideMarginTop = (subTextRect.width - width) / 2;
19
+ width = subTextRect.width;
20
+ } else {
21
+ sideMarginBottom = (width - subTextRect.width) / 2;
22
+ }
23
+ height += spacing.subTextTop + subTextRect.height;
24
+ }
25
+ return {
26
+ x: containerCenterX - width / 2,
27
+ y: Math.max(containerCenterY - height / 2, minY),
28
+ width,
29
+ height,
30
+ sideMarginTop,
31
+ sideMarginBottom
32
+ };
33
+ }
@@ -0,0 +1,15 @@
1
+ export function computeSpacingTop(valueSpacingTop) {
2
+ if (this.subtitle.textStr) {
3
+ /* If a subtitle is present this will be below the title so base
4
+ * the value X position on this */
5
+ const subTitleRect = this.subtitle.element.getBBox();
6
+ return subTitleRect.y + subTitleRect.height + valueSpacingTop;
7
+ } else if (this.title.textStr) {
8
+ // Otherwise base on title
9
+ const titleRect = this.title.element.getBBox();
10
+ return titleRect.y + titleRect.height + valueSpacingTop;
11
+ } else {
12
+ // If neither are present only adjust for valueSpacingTop
13
+ return valueSpacingTop;
14
+ }
15
+ }