Skip to content

Commit

Permalink
fix bug with topBottom aligment
Browse files Browse the repository at this point in the history
  • Loading branch information
susielu committed Mar 14, 2017
1 parent 36286ff commit 09f6362
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions d3-annotation.js
Expand Up @@ -4310,10 +4310,9 @@ exports.default = function (_ref) {

var x = -bbox.x;
var y = -bbox.y;

if (orientationTopBottom.indexOf(orientation) !== -1) {
align = topBottomDynamic(align, offset.x);
if (offset.y < 0 && orientation === "topBotom" || orientation === "top") {
if (offset.y < 0 && orientation === "topBottom" || orientation === "top") {
y -= bbox.height + padding;
} else {
y += padding;
Expand Down Expand Up @@ -4909,6 +4908,7 @@ var Type = exports.Type = function () {
if (lineType === "vertical") orientation = "leftRight";else if (lineType === "horizontal") orientation = "topBottom";

var noteParams = { padding: padding, bbox: context.bbox, offset: this.annotation.offset, orientation: orientation, align: align };
console.log('draw note content', orientation, lineType, align);

var _noteAlignment = (0, _alignment2.default)(noteParams),
x = _noteAlignment.x,
Expand Down
4 changes: 2 additions & 2 deletions docs/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/bundle.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/Note/alignment.js
Expand Up @@ -22,10 +22,9 @@ const orientationLeftRight = ["leftRight", "left", "right"]
export default ({ padding=0, bbox={x:0, y:0, width:0, height:0}, align, orientation, offset={x:0, y:0} }) => {
let x = -bbox.x
let y = -bbox.y

if ( orientationTopBottom.indexOf(orientation) !== -1 ) {
align = topBottomDynamic(align, offset.x)
if (offset.y < 0 && orientation === "topBotom" || orientation === "top") {
if (offset.y < 0 && orientation === "topBottom" || orientation === "top") {
y -= bbox.height + padding
} else {
y += padding
Expand Down
2 changes: 1 addition & 1 deletion src/Types-d3.js
Expand Up @@ -201,7 +201,7 @@ export class Type {

const noteParams = { padding, bbox: context.bbox, offset:
this.annotation.offset, orientation, align }

console.log('draw note content', orientation, lineType, align)
const { x, y } = noteAlignment(noteParams)
this.offsetCornerX = x + this.annotation.dx
this.offsetCornerY = y + this.annotation.dy
Expand Down
4 changes: 2 additions & 2 deletions test/note.js
Expand Up @@ -21,10 +21,10 @@ describe('Note-alignment', function () {
expect(a.x).to.equal(0)
expect(a.y).to.equal(-50)

a = alignment(assign(set, { orientation: "topBottom"}))
a = alignment(assign(set, { orientation: "topBottom", offset: {x: 0, y: -100}}))

expect(a.x).to.equal(0)
expect(a.y).to.equal(0)
expect(a.y).to.equal(-50)
})

it ('stays if orientation is left', function () {
Expand Down

0 comments on commit 09f6362

Please sign in to comment.