Skip to content

Commit

Permalink
fix x-axis
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperLekland committed Feb 18, 2018
1 parent a63ed4b commit ab64b2c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
12 changes: 4 additions & 8 deletions src/x-axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,30 +102,28 @@ class XAxis extends PureComponent {
// causes rendering issues
width > 0 &&
ticks.map((value, index) => {
console.log('x', x(value))
return (
<SVGText
textAnchor={'middle'}
originX={x(value)}
alignmentBaseline={'hanging'}
{...svg}
key={index}
x={x(value)}
>
{formatLabel(value, index)}
</SVGText>
)
})}
})
}
</Svg>
</View>
</View>
)
}
}

XAxis.Type = {
LINE: 'line',
BAR: 'bar',
}

XAxis.propTypes = {
data: PropTypes.array.isRequired,
labelStyle: PropTypes.any,
Expand All @@ -142,9 +140,7 @@ XAxis.propTypes = {
}

XAxis.defaultProps = {
type: 'line',
spacing: 0.05,
chartType: XAxis.Type.LINE,
contentInset: {},
svg: {},
xAccessor: ({ index }) => index,
Expand Down
1 change: 0 additions & 1 deletion storybook/stories/x-axis/scale-band.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class XAxisExample extends React.PureComponent {
data={ data }
scale={scale.scaleBand}
formatLabel={ (value, index) => index }
chartType={ XAxis.Type.BAR }
labelStyle={ { color: 'black' } }
/>
</View>
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/x-axis/scale-linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class XAxisExample extends React.PureComponent {
data={ data }
formatLabel={ (value, index) => index }
contentInset={{ left: 10, right: 10 }}
svg={{ fontSize: 10 }}
svg={{ fontSize: 10, fill: 'black' }}
/>
</View>
)
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/x-axis/scale-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ class XAxisScaleTimeExample extends React.PureComponent {
<XAxis
data={data}
svg={{
translate: '30',
fill: 'black',
fontSize: 8,
fontWeight: 'bold',
rotation: 20,
originY: 30,
y: 5,
}}
xAccessor={({ item }) => item.date}
scale={scale.scaleTime}
Expand Down

0 comments on commit ab64b2c

Please sign in to comment.