Skip to content

DM-9942: Add plotly support #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 327 additions & 0 deletions src/firefly/html/demo/plotly-concepts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,327 @@
<!doctype html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="icon" type="image/x-icon" href="images/fftools-logo-16x16.png">
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="apple-touch-icon" href="images/fftools-logo-57x57_ipad.png"/>
<link rel=”apple-touch-startup-image” href=”images/fftools-ipad_splash_768x1004.png”>
<title>Plotly Concept</title>

<script type="text/javascript" src="../plotly-1.25.0.min.js"></script>
</head>

<body style="margin: 0; background-color: rgb(200,200,200)">
<!-- attached location for firefly app -->
<div id='p1' > </div>
<div id='p2' > </div>
<div id='p3' > </div>
<div id='app'/>


<script>
(function() {
var y = [10, 23, 44, 22, 20, 0, 10, 33, 12, 35, 10, 23, 44, 22, 20, 5, 10, 33, 12, 35];
var xcen = [125, 130, 135, 143, 145, 150, 155, 160, 165, 174.5, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220];
var binSize = xcen.map((aX, idx) => idx < xcen.length - 1 ? xcen[idx + 1] - aX : 5);
var x = xcen.map((aX, idx) => aX + binSize[idx] / 2);
var text = y.map((v, idx) => `<b>Bin Center:</b> ${xcen[idx] / 2}<br><b>Range</b>:${xcen[idx]} to ${xcen[idx] + binSize[idx]}<br><b>Count:</b> ${v}<br><b>Bin Size</b>: ${binSize[idx]}`);
var color = xcen.map((v, idx) => idx % 2 === 0 ? 'black' : 'gray');

var data = [
{
y: y,
x: x,
text: text,
hoverinfo: 'text+x',
type: 'bar',
width: binSize,
marker: {
color,
line: {width: 1, color: 'black'},
},
}
];
const layout = {
bargap: 0,
title: 'Variable Bin Histogram Concept'
};
Plotly.newPlot('p1', data, layout);
})();
</script>



<script>
(function() {

const defSquareMarker= { symbol: 'square', size: 10, color: 'pink'};
const highlightMarker= {
symbol: 'circle',
size: 10,
color: 'orange',
line: { color: 'red', width: 1, }
};
const x= [2, 3, 4, 5, 5.1, 5.2, 7, 7.5];
const y= [3, 2, 4, 4, 3.3, 5.5, 2.2, 4];

const data = [
{
x: [1, 2, 3, 4, 4.1, 4.2, 6, 6.5],
y: [2, 1, 3, 4, 3.3, 5.5, 2.2, 4],
error_y: {
type: 'data',
symmetric: false,
array: [0, 0, 0, 0, .1,.3,.3,.4],
arrayminus: [0.2, 0.4, 1, 0.2, .1,.2,.21,.1],
color: 'orange',
},
error_x: {
type: 'data',
symmetric: false,
array: [.05, 0.2, 0.1, 0.1, .05, 0.2, 0.1, 0.1],
arrayminus: [0.2, 0.4, .2, 0.2, 0.24, 0.5, .23, 0.2],
color: 'red',
thickness: 2,
width:3

},
type: 'scatter',
mode: 'lines+markers',
marker: {
symbol: 'circle',
size: 10,
color: 'purple',
line: {
color: 'blue',
width: 1,
//dash : 'dots'
}

},
line: {
width: 1,
color: 'blue'
}

},
{
x,
y,
type: 'scatter',
mode: 'markers',
// marker: x.map( m => defSquareMarker),
marker: defSquareMarker,
},
{
type: 'scatter',
x: [2],
y: [1],
showlegend : false,
marker: highlightMarker,

}
];
const layout = {
title: 'Scatter with error bars and point selection Concept',
hovermode: 'closest'
};
Plotly.newPlot('p2', data, layout);
var myPlot = document.getElementById('p2');
var cnt = 0;
var originalData = Object.assign({}, data);
myPlot.on('plotly_click', function (ev) {
//console.log('data:'+ cnt);
const {curveNumber}= ev.points[0];
if (curveNumber===0) {
console.log('ata', originalData)
console.log('ev', ev);
var update = {
x: [[data[0].x[ev.points[0].pointNumber]]],
y: [[data[0].y[ev.points[0].pointNumber]]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am glad you have it in examples. This extra array wrapper for x and y updates is not documented.
It seems like it's needed only for x andy. For 'shapes' updates – which is also an array – it's not needed.

};
console.log('update', update);
Plotly.restyle(myPlot, update, [2])
}
else if (curveNumber===1) {

}
});
})();
</script>


<script>
(function() {
const data= [ {
"marker": {
colorscale: [[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']],
"color": [
0,
-1,
-2,
-3,
-4,
-5,
-6,
-7,
-8,
-9,
-10,
-11,
-12,
-13,
-14,
-15,
-16,
-17,
-18,
-19,
-20,
-21,
-22,
-23,
-24,
-25,
-26,
-27,
-28,
-29,
-30,
-31,
-32,
-33,
-34,
-35,
-36,
-37,
-38,
-39
],
"size": [
0,
10,
14.142135623730951,
17.320508075688775,
20,
22.360679774997898,
24.49489742783178,
26.457513110645905,
28.284271247461902,
30,
31.622776601683793,
33.166247903554,
34.64101615137755,
36.05551275463989,
37.416573867739416,
38.72983346207417,
40,
41.23105625617661,
42.42640687119285,
43.58898943540674,
44.721359549995796,
45.8257569495584,
46.9041575982343,
47.958315233127195,
48.98979485566356,
50,
50.99019513592785,
51.96152422706632,
52.91502622129181,
53.85164807134504,
54.772255750516614,
55.67764362830022,
56.568542494923804,
57.445626465380286,
58.309518948453004,
59.16079783099616,
60,
60.8276253029822,
61.644140029689765,
62.44997998398398
],
"colorbar": {
"title": "WOW"
}
},
"y": [
5,
5,
5,
5,
5,
5,
5.5,
5,
5,
5,
5,
5,
5,
5,
5,
5.1,
4,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
4.9,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
"type": "scatter",
"mode": "markers"
}
];
const layout= {
"title": "scatter + colorbar = <3",
"xaxis": {
"type": "linear",
"range": [
-2.501411175139456,
43.340777299865266
],
"autorange": true
},
"yaxis": {
"type": "linear",
"range": [
4,
6
],
"autorange": true
},
"height": 598,
"width": 1080,
"autosize": true,
"showlegend": false
};
Plotly.newPlot('p3', data, layout);

})();
</script>


</body>

</html>


3 changes: 2 additions & 1 deletion src/firefly/html/firefly.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
],
options : {
MenuItemKeys: {maskOverlay:true},
catalogSpacialOp: 'polygonWhenPlotExist'
catalogSpacialOp: 'polygonWhenPlotExist',
charts: {chartEngine: 'plotly'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, we'll have this option in all templates that use charts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I put it in everywhere so that they will all pick up the option and we can work on it. IrsaViewer in the IFE repository does not have this option s set.

}
},
};
Expand Down
3 changes: 2 additions & 1 deletion src/firefly/html/lsst-api-triview.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
catalogSpacialOp: 'polygonWhenPlotExist',
properties : {
daxUrl: 'http://lsst-qserv-dax01.ncsa.illinois.edu:5000'
}
},
charts: {chartEngine: 'plotly'}
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/firefly/html/lsst-pdac-triview.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
MenuItemKeys: {maskOverlay: true},
imageTabs: ['fileUpload', 'url', '2mass', 'wise', 'sdss', 'msx', 'dss', 'iras'],
irsaCatalogFilter: 'lsstFilter',
catalogSpacialOp: 'polygonWhenPlotExist'
catalogSpacialOp: 'polygonWhenPlotExist',
charts: {chartEngine: 'plotly'}
}
}
};
Expand Down
72 changes: 72 additions & 0 deletions src/firefly/html/plotly-1.25.0.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/firefly/html/ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
menu: [
{label:'Upload', action:'LCUpload'},
{label:'Help', action:'app_data.helpLoad', type:'COMMAND'},
]
],
options : {
charts: {chartEngine: 'plotly'}
}
},
};
</script>
Expand Down
Loading