Skip to content

Commit d1aa005

Browse files
authored
Merge pull request #4352 from devgateway/fix/AMP-30906/Fix-ndd-dashboard-bug
AMP-30906: Resolve ndd dash bug
2 parents 62d94bf + 7dfdfee commit d1aa005

File tree

8 files changed

+56
-30
lines changed

8 files changed

+56
-30
lines changed

amp/TEMPLATE/reampv2/packages/reampv2-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"react-spinner": "^0.2.7",
6868
"react-spinners": "^0.13.8",
6969
"react-table": "^7.3.2",
70-
"react-tooltip": "^5.25.1",
70+
"react-tooltip": "^5.28.0",
7171
"react-transition-group": "^4.4.5",
7272
"react-visibility-sensor": "^5.1.1",
7373
"redux": "^4.0.5",
@@ -111,6 +111,7 @@
111111
"@types/react-bootstrap-table2-paginator": "^2.1.3",
112112
"@types/react-dom": "^17.0.2",
113113
"@types/react-redux": "^7.1.24",
114+
"@types/react-tooltip": "^4.2.4",
114115
"@typescript-eslint/eslint-plugin": "^6.13.2",
115116
"@typescript-eslint/parser": "^6.13.2",
116117
"cross-env": "7.0.3",

amp/TEMPLATE/reampv2/packages/reampv2-app/src/modules/ndddashboard/actions/callReports.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export const callReport = (fundingType, filters, programIds, settings) => dispat
2323
return Promise.all([fetchApiData({
2424
url: DIRECT_INDIRECT_REPORT,
2525
body
26-
})]).then((data) => dispatch(fetchIndirectReportSuccess(data[0])))
26+
})]).then((data) => {
27+
return dispatch(fetchIndirectReportSuccess(data[0]))
28+
})
2729
.catch(error => dispatch(fetchIndirectReportError(error)));
2830
};
2931

amp/TEMPLATE/reampv2/packages/reampv2-app/src/modules/ndddashboard/actions/reportActions.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ export function fetchIndirectReportPending() {
1717
};
1818
}
1919

20-
export function fetchIndirectReportSuccess(payload) {
21-
return {
22-
type: FETCH_DIRECT_INDIRECT_NDD_SUCCESS,
23-
payload
24-
};
25-
}
20+
export const fetchIndirectReportSuccess = (payload) => ({
21+
type: FETCH_DIRECT_INDIRECT_NDD_SUCCESS,
22+
payload,
23+
});
2624

2725
export function fetchIndirectReportError(error) {
2826
return {

amp/TEMPLATE/reampv2/packages/reampv2-app/src/modules/ndddashboard/components/NDDDashboardHome.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,14 @@ const NDDDashboardHome = (props) => {
151151
}
152152

153153
const handleOuterChartClick = (event, outerData) => {
154+
154155
const {
155156
selectedDirectProgram, filters, settings, fundingType
156157
} = state;
157158
if (event.points[0].data.name === DIRECT) {
158159
if (!selectedDirectProgram) {
159160
setState(prevState => ({ ...prevState, selectedDirectProgram: outerData[event.points[0].i], fundingByYearSource: SRC_DIRECT }));
160-
_callTopReport(fundingType || dashboardSettings.find(i => i.id === FUNDING_TYPE).value.defaultId,
161+
_callTopReport(fundingType || dashboardSettings?.find(i => i.id === FUNDING_TYPE).value.defaultId,
161162
settings, filters, outerData[event.points[0].i]);
162163
} else {
163164
_clearTopReport();

amp/TEMPLATE/reampv2/packages/reampv2-app/src/modules/ndddashboard/components/charts/NestedDonutsProgramChart.jsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import {connect} from 'react-redux';
44
import {bindActionCreators} from 'redux';
5-
import {CSSTransitionGroup} from 'react-transition-group';
5+
import {TransitionGroup,CSSTransition} from 'react-transition-group';
66

77
// Dont use react-plotly directly: https://github.com/plotly/react-plotly.js/issues/135#issuecomment-501398125
88
import Plotly from 'plotly.js';
@@ -16,7 +16,6 @@ import {
1616
} from '../../utils/Utils';
1717
import ToolTip from '../tooltips/ToolTip';
1818
// eslint-disable-next-line no-unused-vars
19-
import styles from '../styles.css';
2019

2120
const Plot = createPlotlyComponent(Plotly);
2221

@@ -260,15 +259,19 @@ class NestedDonutsProgramChart extends Component {
260259
}
261260
] : [];
262261
return (
263-
<CSSTransitionGroup
264-
/* key={selectedDirectProgram} */
265-
transitionName="solar-chart"
266-
transitionAppear
267-
transitionLeave
268-
transitionEnter
269-
transitionEnterTimeout={TRANSITIONS}
270-
transitionLeaveTimeout={TRANSITIONS}
271-
transitionAppearTimeout={TRANSITIONS}>
262+
<TransitionGroup>
263+
<CSSTransition
264+
key="solarChart"
265+
classNames="solar-chart"
266+
appear
267+
enter
268+
exit
269+
timeout={{
270+
appear: TRANSITIONS,
271+
enter: TRANSITIONS,
272+
exit: TRANSITIONS
273+
}}
274+
>
272275
<Plot
273276
key="solarChart"
274277
data={
@@ -348,6 +351,8 @@ class NestedDonutsProgramChart extends Component {
348351
onHover={event => this.onHover(event)}
349352
onUnhover={() => this.onUnHover()}
350353
/>
354+
</CSSTransition>
355+
351356
<div
352357
style={{
353358
display: (!showLegend ? 'none' : 'block'),
@@ -357,7 +362,7 @@ class NestedDonutsProgramChart extends Component {
357362
className="pie-legend-wrapper">
358363
{this.createTooltip()}
359364
</div>
360-
</CSSTransitionGroup>
365+
</TransitionGroup>
361366
);
362367
}
363368
}
@@ -377,7 +382,7 @@ NestedDonutsProgramChart.defaultProps = {
377382
};
378383

379384
const mapStateToProps = state => ({
380-
translations: state.translationsReducer.translations
385+
translations: state.translationsReducer.translations
381386
});
382387

383388
const mapDispatchToProps = dispatch => bindActionCreators({}, dispatch);

amp/TEMPLATE/reampv2/packages/reampv2-app/src/modules/ndddashboard/components/charts/TopChart.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import PropTypes from 'prop-types';
44
import { NDDTranslationContext } from '../StartUp';
55
import ToolTip from '../tooltips/ToolTip';
66
import { formatKMB, formatNumberWithSettings } from '../../utils/Utils';
7-
import SimpleLegend from '../../../../utils/components/SimpleLegend';
87
import { CURRENCY_CODE } from '../../utils/constants';
8+
import SimpleLegend from '../../../../utils/components/SimpleLegend';
99

1010
const styles = {
1111
fontFamily: 'sans-serif',
@@ -61,7 +61,7 @@ class TopChart extends Component {
6161
data={data.values}
6262
getColor={this.getColor.bind(this)}
6363
/>
64-
<div style={{ height: '335px' }}>
64+
<div style={{ height: '355px' }}>
6565
<ResponsiveBar
6666
data={transformedData}
6767
colors={this.getColor.bind(this)}

amp/TEMPLATE/reampv2/packages/reampv2-app/src/modules/ndddashboard/utils/Utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ function getSuffixForLang(prefix, lang) {
135135

136136
export function formatNumber(currency, translations, value, precision, decimalSeparator, groupSeparator, numberDivider,
137137
numberDividerDescriptionKey) {
138+
if (decimalSeparator==='.')
139+
decimalSeparator='';
138140
const formatString = `${decimalSeparator}.${precision}f`;
139141
const dividedValue = (numberDivider && numberDividerDescriptionKey) ? value / numberDivider : value;
140142
// eslint-disable-next-line max-len
@@ -162,6 +164,8 @@ export function formatNumberWithSettings(currency, translations, settings, value
162164

163165
// TODO: Unify with formatNumber();
164166
export function formatOnlyNumber(settings, value) {
167+
if (settings.decimalSeparator==='.')
168+
settings.decimalSeparator='';
165169
const formatString = `${settings.decimalSeparator}.${settings.precision}f`;
166170
const dividedValue = (settings.numberDivider && settings.numberDividerDescriptionKey)
167171
? value / settings.numberDivider

amp/TEMPLATE/reampv2/packages/reampv2-app/src/utils/components/SimpleLegend.jsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import ReactTooltip from 'react-tooltip';
2+
import ReactTooltip, { Tooltip } from 'react-tooltip';
33
import PropTypes from 'prop-types';
44
import './SimpleLegend.css';
55

@@ -23,12 +23,27 @@ export default class SimpleLegend extends Component {
2323
border: `2px solid ${getColor(d)}`,
2424
backgroundColor: `${getColor(d)}`
2525
}}
26-
data-tip={d.name}
27-
data-for={index.toString()}
28-
/>
29-
<span className="label">
26+
data-tooltip-content={d.name}
27+
data-tooltip-id={index.toString()}
28+
data-tooltip-place="top"
29+
30+
>
31+
32+
</span>
33+
<span className="label"
34+
data-tooltip-content={d.name}
35+
data-tooltip-id={index.toString()}
36+
data-tooltip-place="top"
37+
style={{cursor: 'pointer'}}
38+
>
3039
{d.name.substring(0, 10)}
31-
<ReactTooltip place="top" effect="float" backgroundColor={getColor(d)} id={index.toString()} />
40+
<Tooltip
41+
place="top"
42+
effect="float"
43+
style={{
44+
backgroundColor: `${getColor(d)}`
45+
}}
46+
id={index.toString()} />
3247
</span>
3348
</li>
3449
);

0 commit comments

Comments
 (0)