Skip to content

Commit 58b91e7

Browse files
committed
test: add annotation with category positions case
1 parent 6e7d5d6 commit 58b91e7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/jasmine/tests/annotations_test.js

+35
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,41 @@ describe('Test annotations', function() {
8787
expect(layoutOut.annotations[0].x).toEqual('2008-07-01');
8888
expect(layoutOut.annotations[0].ax).toEqual('2004-07-01');
8989
});
90+
91+
it('should convert ax/ay category coordinates to linear coords', function() {
92+
var layoutIn = {
93+
annotations: [{
94+
showarrow: true,
95+
axref: 'x',
96+
ayref: 'y',
97+
x: 'c',
98+
ax: 1,
99+
y: 'A',
100+
ay: 3
101+
}]
102+
};
103+
104+
var layoutOut = {
105+
xaxis: {
106+
type: 'category',
107+
_categories: ['a', 'b', 'c'],
108+
range: [-0.5, 2.5] },
109+
yaxis: {
110+
type: 'category',
111+
_categories: ['A', 'B', 'C'],
112+
range: [-0.5, 3]
113+
}
114+
};
115+
Axes.setConvert(layoutOut.xaxis);
116+
Axes.setConvert(layoutOut.yaxis);
117+
118+
_supply(layoutIn, layoutOut);
119+
120+
expect(layoutOut.annotations[0].x).toEqual(2);
121+
expect(layoutOut.annotations[0].ax).toEqual(1);
122+
expect(layoutOut.annotations[0].y).toEqual(0);
123+
expect(layoutOut.annotations[0].ay).toEqual(3);
124+
});
90125
});
91126
});
92127

0 commit comments

Comments
 (0)