Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

check for functional label padding #281

Merged
merged 1 commit into from
Aug 5, 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
15 changes: 8 additions & 7 deletions src/victory-util/label-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export default {
},

getPadding(props, datum) {
const { horizontal, style } = props;
const { horizontal, style, active } = props;
const labelStyle = style.labels || {};
const defaultPadding = labelStyle.padding || 0;
const defaultPadding = Helpers.evaluateProp(labelStyle.padding, datum, active) || 0;
const sign = datum._y < 0 ? -1 : 1;
return {
x: horizontal ? sign * defaultPadding : 0,
Expand All @@ -59,18 +59,19 @@ export default {
y: horizontal ? x + padding.y : y - padding.y
};
} else {
const degrees = this.getDegrees(props, datum);
const polarPadding = this.getPolarPadding(props, degrees);
const polarPadding = this.getPolarPadding(props, datum);
return {
x: x + polarPadding.x,
y: y + polarPadding.y
};
}
},

getPolarPadding(props, degrees) {
const labelStyle = props.style.labels || {};
const padding = labelStyle.padding || 0;
getPolarPadding(props, datum) {
const { active, style } = props;
const degrees = this.getDegrees(props, datum);
const labelStyle = style.labels || {};
const padding = Helpers.evaluateProp(labelStyle.padding, datum, active) || 0;
const angle = Helpers.degreesToRadians(degrees);
return {
x: padding * Math.cos(angle), y: -padding * Math.sin(angle)
Expand Down