Skip to content

Commit

Permalink
Fix labelStyle argument (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
krissalvador27 authored Mar 4, 2019
1 parent a9b4ba1 commit 479fd14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/XAxisLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ function resolveXLabelsForValues(scale, values, formats, style, force = true) {

let labels;
let attempts = [];

const goodFormat = _.find(formats, format => {
const testLabels = values.map((value, i) =>
MeasuredValueLabel.getLabel({
const testLabels = values.map((value, i) => {
return MeasuredValueLabel.getLabel({
value,
format,
style: _.defaults(
getValue(style.labelStyle, value, i),
getValue(style.labelStyle, { value }, i),
style.defaultStyle
)
})
);
});
});

const areLabelsDistinct = checkLabelsDistinct(testLabels);
if (!areLabelsDistinct) {
Expand Down Expand Up @@ -219,7 +220,7 @@ class XAxisLabels extends React.Component {

static getMargin(props) {
props = _.defaults({}, props, XAxisLabels.defaultProps);
const { xScale, position, placement, distance, labelStyle } = props;
const { xScale, position, placement, distance } = props;
const labels = props.labels || XAxisLabels.getLabels(props);
const zeroMargin = {
marginTop: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/YAxisLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function resolveYLabelsForValues(scale, values, formats, style, force = true) {
value,
format,
style: _.defaults(
getValue(style.labelStyle, value, i),
getValue(style.labelStyle, { value }, i),
style.defaultStyle
)
})
Expand Down

0 comments on commit 479fd14

Please sign in to comment.