The showlegend behaviour appears to have changed recently
I use to specify showlegend: true, and it would add a new legend for every plot added
I’ve made a quick demo file to show what I mean
The showlegend behaviour appears to have changed recently
I use to specify showlegend: true, and it would add a new legend for every plot added
I’ve made a quick demo file to show what I mean
`
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="js/d3.min.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<meta charset="UTF-8" />
</head>
<body>
<script>
function makePlotly( x, y ,legendname ){
var plotDiv = document.getElementById("myDiv");
var traces = [{
x: x,
y: y,
name: legendname
}];
var layout = {
//showlegend: false, //always shows nothing
//showlegend: true, // only shows one legend at a time
//no legend setting works best for line but only shows a max of two legends
autosize: true,
width: 1000,
height: 1000,
xaxis: {
title: 'x'
},
yaxis: {
title: 'y'
},
font: {
family: "Open Sans, sans-serif",
size: 19
}
};
Plotly.plot('myDiv', traces,layout,{displayModeBar: true},{showLink: false});
//Plotly.newPlot('myDiv', traces,layout,{displayModeBar: true},{showLink: false});
};
</script>
<button onclick="makePlotly([1,2,3],[2,3,4],'plot 1')">plot data</button>
<button onclick="makePlotly([2,3.2,5],[2,3,4],'plot 2')">plot data</button>
<button onclick="makePlotly([6],[3],'plot 3')">plot data scatter</button>
<button onclick="makePlotly([6.5],[2],'plot 4')">plot data scatter</button>
<div align="center">
<div align="center" id="myDiv" style="width: 100%; height: 100%;"><!-- Plotly chart will be drawn inside this DIV --></div>
</div>
</body>
`
Here is an example of how the legend only shows two plots even when more than two are included
http://j-shimwell.postgrad.shef.ac.uk/test.html
I’m finding that
showlegend: false, //always shows nothing
showlegend: true, // only shows one legend at a time
no legend setting works shows a max of two legends
Any tips as this use to work about a week ago
I have reproduced the old plotly 1.6.3 and this works fine.
every new trace adds a new legend
here is an example
http://j-shimwell.postgrad.shef.ac.uk/test_old.html
cheers
Jon
This issue will be in the next plotly.js release. See https://github.com/plotly/plotly.js/pull/356 for more info.