Skip to content

Commit

Permalink
fix label
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen authored and Amy Chen committed Mar 12, 2024
1 parent 45d2118 commit 10d16b9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/graph/SurveyGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,13 @@ export default class SurveyGraph extends Component {
/>
<div className="scale">
{arrNum.map((item, index) => {
const rotateLabelFlag = inYears && item < 1;
const prevItem = arrNum[index - 1];
const nextItem = arrNum[index + 1];
const rotateLabelFlag =
(inYears && item < 1) ||
(prevItem && prevItem < 1 && item >= 1) ||
(nextItem && nextItem >= 1 && item < 1);
const dataUnit = item < 1 ? "month" : "year";
return (
<span
key={`scale_${index}`}
Expand All @@ -782,7 +788,7 @@ export default class SurveyGraph extends Component {
}`}
ref={this.scaleLabelRefs[index]}
datavalue={item}
dataunit={item < 1 ? "month" : "year"}
dataunit={dataUnit}
>
{item < 1 || !inYears
? !inYears
Expand Down

0 comments on commit 10d16b9

Please sign in to comment.