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

Fix #103 - cleanup x axis label offsets to avoid tie to chart offsets #111

Merged
merged 1 commit into from
Mar 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default class BarChart extends Component {
margin:options.margin}

let textStyle = fontAdapt(options.axisX.label)
let labelOffset = this.props.options.axisX.label.offset || 20

let lines = chart.curves.map(function (c, i) {
let color = this.color(i % 3)
Expand All @@ -129,11 +130,12 @@ export default class BarChart extends Component {
<G key={'lines' + i}>
<Path d={ c.line.path.print() } stroke={stroke} fill={color}/>
{options.axisX.showLabels ?
<G x={options.margin.left} y={options.margin.top}>
<Text fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize} fontWeight={textStyle.fontWeight} fontStyle={textStyle.fontStyle}
fill={textStyle.fill} x={c.line.centroid[0]} y={chartArea.y.min} rotate={45} textAnchor="middle">{c.item.name}</Text></G>
:null}
fontSize={textStyle.fontSize} fontWeight={textStyle.fontWeight} fontStyle={textStyle.fontStyle}
fill={textStyle.fill} x={c.line.centroid[0]} y={labelOffset + chartArea.y.min} rotate={45} textAnchor="middle">
{c.item.name}
</Text>
: null}
</G>
)
}, this)
Expand Down