Skip to content

Commit eaf28c0

Browse files
committed
fix: real citations count disaplying in papers
1 parent 91cdad9 commit eaf28c0

1 file changed

Lines changed: 62 additions & 37 deletions

File tree

vis/js/templates/Paper.tsx

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const orderPriorityMap = {
1515
cited_by_accounts_count: "social",
1616
references: "references",
1717
readers: "readers",
18-
tweets: "tweets"
19-
}
18+
tweets: "tweets",
19+
};
2020

2121
class Paper extends React.Component {
2222
constructor(props) {
@@ -108,18 +108,35 @@ class Paper extends React.Component {
108108
}
109109

110110
render() {
111-
const { data, zoom, selected, hovered, maxSize, enlargeFactor, onClick, onMouseOver, onMouseOut } = this.props;
111+
const {
112+
data,
113+
zoom,
114+
selected,
115+
hovered,
116+
maxSize,
117+
enlargeFactor,
118+
onClick,
119+
onMouseOver,
120+
onMouseOut,
121+
} = this.props;
112122

113123
const {
114124
title,
115125
authors_string: authors,
116126
authors_list: authors_list,
117127
year,
118128
area,
119-
published_in: publisher
129+
published_in: publisher,
120130
} = data;
121131

122-
const { x, y, width: baseWidth, height: baseHeight, path: basePath, dogEar: baseDogEar } = this.state;
132+
const {
133+
x,
134+
y,
135+
width: baseWidth,
136+
height: baseHeight,
137+
path: basePath,
138+
dogEar: baseDogEar,
139+
} = this.state;
123140

124141
const {
125142
showSocialMedia,
@@ -135,14 +152,7 @@ class Paper extends React.Component {
135152
tweetsLabel,
136153
} = this.props;
137154

138-
const {
139-
// num_readers:
140-
readers,
141-
tweets,
142-
citations,
143-
social,
144-
references,
145-
} = data;
155+
const { readers, tweets, citations, social, references } = data;
146156

147157
let { width: realWidth, height: realHeight } =
148158
this.getCoordinatesAndDimensions();
@@ -226,11 +236,10 @@ class Paper extends React.Component {
226236
value: citations,
227237
label: citationsLabel,
228238
},
229-
// consider to refactor and retrieve correct data from the backend side instead of doing this hack with citations for pubmed
230239
{
231240
id: "citations pubmed",
232241
show: showPubmedCitations,
233-
value: readers,
242+
value: citations,
234243
label: citationsLabel,
235244
},
236245
{
@@ -257,15 +266,14 @@ class Paper extends React.Component {
257266
value: tweets,
258267
label: tweetsLabel,
259268
},
260-
].filter(stat => stat.show)
269+
].filter((stat) => stat.show);
261270

262271
let sortedStats = stats;
263272

264273
if (this.props.scaleValue) {
265274
const { scaleValue } = this.props;
266275

267-
268-
const tagPreference = orderPriorityMap[scaleValue]
276+
const tagPreference = orderPriorityMap[scaleValue];
269277

270278
sortedStats = tagPreference
271279
? [...stats].sort((a, b) => {
@@ -354,20 +362,35 @@ class Paper extends React.Component {
354362
)}
355363
</p>
356364
</div>
357-
{(hovered ? sortedStats : sortedStats.slice(0, 1)).map(({ value, label, id }) => (
358-
<div key={id} className="stat" style={{
359-
textWrap: 'nowrap'
360-
}}>
361-
<p className={`stat ${sizeModifierClass}`}>
362-
<span style={{
363-
textWrap: 'nowrap'
364-
}} className="num-stat">{value || value === 0 ? value : "n/a"} </span>
365-
<span style={{
366-
textWrap: 'nowrap'
367-
}}>{label}</span>
368-
</p>
369-
</div>
370-
))}
365+
{(hovered ? sortedStats : sortedStats.slice(0, 1)).map(
366+
({ value, label, id }) => (
367+
<div
368+
key={id}
369+
className="stat"
370+
style={{
371+
textWrap: "nowrap",
372+
}}
373+
>
374+
<p className={`stat ${sizeModifierClass}`}>
375+
<span
376+
style={{
377+
textWrap: "nowrap",
378+
}}
379+
className="num-stat"
380+
>
381+
{value || value === 0 ? value : "n/a"}{" "}
382+
</span>
383+
<span
384+
style={{
385+
textWrap: "nowrap",
386+
}}
387+
>
388+
{label}
389+
</span>
390+
</p>
391+
</div>
392+
)
393+
)}
371394
</div>
372395
</div>
373396
</foreignObject>
@@ -506,8 +529,9 @@ const DOGEAR_WIDTH = 0.15;
506529
const DOGEAR_HEIGHT = 0.15;
507530

508531
const getDogEar = ({ x, y, width: w, height: h }) => {
509-
return `M ${x + (1 - DOGEAR_WIDTH) * w} ${y} v ${DOGEAR_HEIGHT * h} h ${DOGEAR_WIDTH * w
510-
}`;
532+
return `M ${x + (1 - DOGEAR_WIDTH) * w} ${y} v ${DOGEAR_HEIGHT * h} h ${
533+
DOGEAR_WIDTH * w
534+
}`;
511535
};
512536

513537
const getRoundedPath = ({ x, y, width, height }) => {
@@ -527,8 +551,9 @@ const getRoundedPath = ({ x, y, width, height }) => {
527551
};
528552

529553
const getSquarePath = ({ x, y, width: w, height: h }) => {
530-
return `M ${x} ${y} h ${(1 - DOGEAR_WIDTH) * w} l ${DOGEAR_HEIGHT * w} ${DOGEAR_WIDTH * h
531-
} v ${(1 - DOGEAR_HEIGHT) * h} h ${-w} v ${-h}`;
554+
return `M ${x} ${y} h ${(1 - DOGEAR_WIDTH) * w} l ${DOGEAR_HEIGHT * w} ${
555+
DOGEAR_WIDTH * h
556+
} v ${(1 - DOGEAR_HEIGHT) * h} h ${-w} v ${-h}`;
532557
};
533558

534559
const getEnlargeFactor = (offsetWidth, scrollHeight) => {
@@ -551,7 +576,7 @@ const getEnlargeFactor = (offsetWidth, scrollHeight) => {
551576

552577
const getMetadataHeight = (realHeight, numOfLabels, isZoomed) => {
553578
let readersHeight = 0;
554-
579+
555580
if (numOfLabels && isZoomed) {
556581
readersHeight += numOfLabels * 12 + 10;
557582
}

0 commit comments

Comments
 (0)