Skip to content

Commit fc5a73a

Browse files
authored
Merge pull request #1975 from plotly/shape-overlay-fix
fix and test shapes on overlaid axes
2 parents ff8ecb1 + c2a135f commit fc5a73a

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

src/components/shapes/draw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function drawOne(gd, index) {
7777
else {
7878
var plotinfo = gd._fullLayout._plots[options.xref + options.yref];
7979
if(plotinfo) {
80-
var mainPlot = plotinfo.mainplot || plotinfo;
80+
var mainPlot = plotinfo.mainplotinfo || plotinfo;
8181
drawShape(mainPlot.shapelayer);
8282
}
8383
else {

test/jasmine/tests/shapes_test.js

+42-20
Original file line numberDiff line numberDiff line change
@@ -580,32 +580,54 @@ describe('Test shapes: a plot with shapes and an overlaid axis', function() {
580580
gd = createGraphDiv();
581581

582582
data = [{
583-
'y': [1934.5, 1932.3, 1930.3],
584-
'x': ['1947-01-01', '1947-04-01', '1948-07-01'],
585-
'type': 'scatter'
583+
y: [1934.5, 1932.3, 1930.3],
584+
x: ['1947-01-01', '1947-04-01', '1948-07-01'],
585+
type: 'scatter'
586586
}];
587587

588588
layout = {
589-
'yaxis': {
590-
'type': 'linear'
589+
yaxis: {
590+
type: 'linear'
591591
},
592-
'xaxis': {
593-
'type': 'date'
592+
xaxis: {
593+
type: 'date'
594594
},
595-
'yaxis2': {
596-
'side': 'right',
597-
'overlaying': 'y'
595+
yaxis2: {
596+
side: 'right',
597+
overlaying: 'y'
598598
},
599-
'shapes': [{
600-
'fillcolor': '#ccc',
601-
'type': 'rect',
602-
'x0': '1947-01-01',
603-
'x1': '1947-04-01',
604-
'xref': 'x',
605-
'y0': 0,
606-
'y1': 1,
607-
'yref': 'paper',
608-
'layer': 'below'
599+
shapes: [{
600+
fillcolor: '#ccc',
601+
type: 'rect',
602+
x0: '1947-01-01',
603+
x1: '1947-04-01',
604+
xref: 'x',
605+
y0: 0,
606+
y1: 1,
607+
yref: 'paper',
608+
layer: 'below'
609+
}, {
610+
type: 'path',
611+
xref: 'x',
612+
yref: 'y2',
613+
path: 'M1947-01-01_12:00,2V4H1947-03-01Z'
614+
}, {
615+
type: 'rect',
616+
xref: 'x',
617+
yref: 'y2',
618+
x0: '1947-02-01',
619+
x1: '1947-03-01',
620+
y0: 3,
621+
y1: 5,
622+
layer: 'below'
623+
}, {
624+
type: 'circle',
625+
xref: 'x',
626+
yref: 'y',
627+
x0: '1947-01-15',
628+
x1: '1947-02-15',
629+
y0: 1931,
630+
y1: 1934
609631
}]
610632
};
611633
});

0 commit comments

Comments
 (0)