Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.

Commit c34e27c

Browse files
authored
Fix #97 - handle possibility of null value for axis tick label (#109)
1 parent 401ecdf commit c34e27c

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/Axis.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,25 @@ export default class Axis extends Component {
132132
let scaleBase = isNaN(c) ? i : c
133133
let gxy = horizontal ? [scale(scaleBase),chartArea.y.min]:[chartArea.x.min,scale(scaleBase)]
134134

135-
let returnValue = <G key={i} x={gxy[0]} y={gxy[1]}>
136-
137-
{options.showTicks &&
138-
<Circle r="2" cx="0" cy="0" stroke="grey" fill="grey" />
139-
}
140-
141-
{options.showLabels &&
142-
<Text x={xy[0]} y={xy[1]}
143-
fontFamily={textStyle.fontFamily}
144-
fontSize={textStyle.fontSize}
145-
fontWeight={textStyle.fontWeight}
146-
fontStyle={textStyle.fontStyle}
147-
fill={textStyle.fill}
148-
textAnchor={textAnchor}>
149-
{label}
150-
</Text>}
151-
</G>
135+
let returnValue
136+
if (label !== undefined && label !== null) {
137+
returnValue =
138+
<G key={i} x={gxy[0]} y={gxy[1]}>
139+
{options.showTicks &&
140+
<Circle r="2" cx="0" cy="0" stroke="grey" fill="grey" />
141+
}
142+
{options.showLabels &&
143+
<Text x={xy[0]} y={xy[1]}
144+
fontFamily={textStyle.fontFamily}
145+
fontSize={textStyle.fontSize}
146+
fontWeight={textStyle.fontWeight}
147+
fontStyle={textStyle.fontStyle}
148+
fill={textStyle.fill}
149+
textAnchor={textAnchor}>
150+
{label}
151+
</Text>}
152+
</G>
153+
}
152154

153155
return returnValue
154156
})

0 commit comments

Comments
 (0)