Skip to content

Commit dcf579c

Browse files
Merge pull request #1195 from suppermancool/f2f-30069264-issue-1191
fix issue #1191 rating distribution graph
2 parents f4c54b3 + 00acfdc commit dcf579c

File tree

1 file changed

+18
-3
lines changed
  • src/shared/components/ProfilePage/Stats/DistributionGraph

1 file changed

+18
-3
lines changed

src/shared/components/ProfilePage/Stats/DistributionGraph/index.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default class DistributionGraph extends React.Component {
3737
constructor(props) {
3838
super(props);
3939
this.state = {};
40+
this.mobileWidth = 0;
4041
this.graphRef = React.createRef();
4142
}
4243

@@ -45,7 +46,9 @@ export default class DistributionGraph extends React.Component {
4546
$scope.desktop = window.innerWidth >= 900;
4647
this.draw();
4748
this.resizeHandle = () => {
48-
if (window.innerWidth < 900 && $scope.desktop) {
49+
if (window.innerWidth < 900
50+
&& ($scope.desktop
51+
|| (this.mobileWidth !== DistributionGraph.getMobileWidthGrapthMeasurements()))) {
4952
$scope.desktop = false;
5053
this.draw();
5154
} else if (window.innerWidth >= 900 && !$scope.desktop) {
@@ -67,6 +70,13 @@ export default class DistributionGraph extends React.Component {
6770
window.removeEventListener('resize', this.resizeHandle);
6871
}
6972

73+
static getMobileWidthGrapthMeasurements() {
74+
if (window.innerWidth < 400) {
75+
return 250;
76+
}
77+
return 370;
78+
}
79+
7080
draw() {
7181
const $scope = this;
7282
const { distribution: wrapper, rating } = this.props;
@@ -87,7 +97,7 @@ export default class DistributionGraph extends React.Component {
8797
};
8898

8999
const mobileMeasurements = {
90-
w: 370,
100+
w: 0,
91101
h: 200,
92102
padding: {
93103
top: 50,
@@ -98,7 +108,12 @@ export default class DistributionGraph extends React.Component {
98108
};
99109

100110
d3.select($scope.graphRef.current).select('svg').remove();
101-
const { w, h, padding } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
111+
let { w } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
112+
const { h, padding } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
113+
if (!$scope.desktop) {
114+
w = DistributionGraph.getMobileWidthGrapthMeasurements();
115+
this.mobileWidth = w;
116+
}
102117
const totalW = w + padding.left + padding.right;
103118
const totalH = h + padding.top + padding.bottom;
104119

0 commit comments

Comments
 (0)