Plotly ScatterGL Legend Size Tests
by brian428
HTML
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<p>
Here's a simple Plotly plot -
<a href="http://bit.ly/1Or9igj">plotly.js documentation</a>
</p>
<!-- Plots go in blank <div> elements.
You can size them in the plot layout,
or give the div a size as shown here.
<div id="testChart" style="width:100vw; height:calc(100vh - 100px);"></div>
-->
<div id="testChart" style="width:100%; height:100%;"></div>
<!--
<div id="testChart2" style="width:100%; height:100%;"></div>
<div id="testChart3" style="width:100%; height:100%;"></div>
-->
CSS
html, body {
width: 90%;
height: 90%;
}
JavaScript
// Some docs examples: https://plot.ly/javascript/line-and-scatter/
// More complex example: https://plot.ly/~chris/17389.embed
console.log( Plotly.PlotSchema.get() );
/* Speed results: (point count: first render, redraw, redraw 2):
500 points: 350ms, 38ms, 22ms
5000 points: 330ms, 66ms, 20ms
50000 points: 570ms, 75ms, 60ms
500000 points: 900ms, 400ms, 325ms
*/
var colorList = [
"#006385", "#F06E75", "#90ed7d", "#f7a35c", "#8085e9",
"#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1",
"#5DA5DA", "#F06E75", "#F15854", "#B2912F", "#B276B2",
"#DECF3F", "#FAA43A", "#4D4D4D", "#F17CB0", "#60BD68"
];
var testChart = document.getElementById('testChart');
var traceCount = 5;
var npoints = 40;
var createData = function( dataObj ) {
for (var i = 0, l = npoints; i < l; i++) {
dataObj.y.push(Math.random() * 5000)
dataObj.x.push(i);
};
};
var t0 = performance.now();
var createPlot = function( divId, traceCount ) {
var dataObjArray = [];
for (var i = 0, l = traceCount; i < l; i++) {
var dataObj = { x: [], y: [], color: colorList[0], symbol: "cross", size: 4 };
createData( dataObj );
dataObjArray.push( dataObj );
};
var series = [];
for (var i = 0; i < dataObjArray.length; i++) {
var dataObj = dataObjArray[i];
series.push(
{
type: 'scattergl',
mode: 'lines+markers',
marker: {
symbol: dataObj.symbol,
size: dataObj.size,
color: dataObj.color
},
line: {
width: 0
},
x: dataObj.x,
y: dataObj.y,
name: "My Trace " + i
}
);
};
var dataObj = dataObjArray[i];
Plotly.plot(
document.getElementById(divId),
series,
{
title: "My Test Plot",
margin: { t: 40, b:50, l:75, r:30 },
xaxis: { title: "My X Axis", domain: [0,1] },
yaxis: { title: "My Y Axis", domain: [0,1] },
annotations: [{
showarrow: false,
text: 'MY TOP ANNOTATION 1',
...