Commit 2ecfab3d authored by Moreau Nicolas's avatar Moreau Nicolas
Browse files

modification to support highcharts instead of plotly

parent 31d9f0a8
......@@ -1644,11 +1644,13 @@ var SAMPPNGPublishControl = (function (Control) {
},
series: [
{
//type : 'scatter',
// unlimited number of points when zooming
cropThreshold: Infinity,
showInLegend: false,
data : highData,
marker: {
radius: 0
width: 16,
height: 16
}
},getPoint(_frequencyMarker.x)
......@@ -1828,47 +1830,47 @@ var SAMPPNGPublishControl = (function (Control) {
** The layout utilized to display the spectrum of summed values on each slice.
** bottom right
*/
let _layout = {
xaxis: {
title: xtitle,
hoverformat: '.4f',
ticks: "",
showgrid: false,
zeroline: false
},
yaxis: {
title: ytitle,
hoverformat: '.4f',
mirror: "ticks",
ticks: "inside",
tickmode: 'array',
showgrid: true,
zeroline: true
},
xaxis: {
zeroline: false,
showgrid: true,
ticks: 'outside',
side: 'bottom',
autotick: true,
overlaying: 'x'
},
margin: {
r: 100,
l: 60,
b: 60,
t: 30,
autoexpand: false
},
hovermode: 'closest',
showlegend: false,
forceRelayout: false, // Not present in Plotly library. Added to check if plot was relayouted manually.
title: {
font: {
size: 12
}
}
};
//~ let _layout = {
//~ xaxis: {
//~ title: xtitle,
//~ hoverformat: '.4f',
//~ ticks: "",
//~ showgrid: false,
//~ zeroline: false
//~ },
//~ yaxis: {
//~ title: ytitle,
//~ hoverformat: '.4f',
//~ mirror: "ticks",
//~ ticks: "inside",
//~ tickmode: 'array',
//~ showgrid: true,
//~ zeroline: true
//~ },
//~ xaxis: {
//~ zeroline: false,
//~ showgrid: true,
//~ ticks: 'outside',
//~ side: 'bottom',
//~ autotick: true,
//~ overlaying: 'x'
//~ },
//~ margin: {
//~ r: 100,
//~ l: 60,
//~ b: 60,
//~ t: 30,
//~ autoexpand: false
//~ },
//~ hovermode: 'closest',
//~ showlegend: false,
//~ forceRelayout: false, // Not present in Plotly library. Added to check if plot was relayouted manually.
//~ title: {
//~ font: {
//~ size: 12
//~ }
//~ }
//~ };
let _relFITSFilePath = relFITSFilePath;
......@@ -1888,21 +1890,23 @@ var SAMPPNGPublishControl = (function (Control) {
return _itsGD;
}
let _frequencyPlotBorder = {
type: 'scatter',
mode: 'markers',
y: [],
line: {
color: 'yellow',
width: 0.0001
},
marker : {
color: 'blue',
size : 1
},
hoverinfo: 'x+y',
xaxis : 'x'
};
//~ let _frequencyPlotBorder = {
//~ type: 'scatter',
//~ mode: 'markers',
//~ y: [],
//~ line: {
//~ color: 'yellow',
//~ width: 0.0001
//~ },
//~ marker : {
//~ color: 'blue',
//~ size : 1
//~ },
//~ hoverinfo: 'x+y',
//~ xaxis : 'x'
//~ };
let _frequencyPlot = {
type: 'scatter',
......@@ -1918,7 +1922,7 @@ var SAMPPNGPublishControl = (function (Control) {
hoverinfo: 'x+y',
xaxis: 'x'
};
var plotData2 = JSON.parse(JSON.stringify(_frequencyPlot));
let _companion = null;
/*
......@@ -1954,10 +1958,81 @@ var SAMPPNGPublishControl = (function (Control) {
return _relayoutTriggeredBy;
}
Plotly.newPlot(_itsGD, _frequencyPlot, _layout);
//Plotly.newPlot(_itsGD, _frequencyPlot, _layout);
this.plot = function (iRA0, iRA1, iDEC0, iDEC1, zmin, zmax) {
ENTER();
var myChart2 = Highcharts.chart(_itsGD, {
title: {
text: toptitle
},
chart: {
zoomType: 'xy',
events:{
selection: function(event){
console.log("selection");
var imin = Math.round((event.xAxis[0].min - plotData2.x[0]) / (plotData2.x[1]-plotData2.x[0]));
var imax = Math.round((event.xAxis[0].max - plotData2.x[0]) / (plotData2.x[1]-plotData2.x[0]));
console.log("imin / imax");
console.log(imin+" "+imax);
if (_cunit3 in unitFactor) {
switch (_ctype3) {
case 'FREQ':
if (_cdelt3 > 0) {
sliceViewer.updateSummedSlices(plotData2.x.length-1-imax, plotData2.x.length-1-imin);
}
else {
sliceViewer.updateSummedSlices(imin, imax);
}
break;
case 'VRAD' :
case 'WAVE':
case 'WAVN' :
case 'AWAV':
if (_cdelt3 > 0) {
sliceViewer.updateSummedSlices(imin, imax);
}
else {
sliceViewer.updateSummedSlices(plotData2.x.length-1-imax, plotData2.x.length-1-imin);
}
break;
default:
console.log("This should not happen");
}
}
return false;
}
}
},
boost: {
useGPUTranslations: true,
usePreAllocated: true
},
xAxis: {
title: {
text: xtitle
},
reversed : false
},
yAxis: {
title: {
text: ytitle
}
},
tooltip:{
formatter : function(){
return '( ' + this.x.toFixed(4) + ', ' + this.y.toFixed(4); + ')';
}
},
series: [
{}
]
});
document.getElementById('loading').style.display = 'block';
$.post("",{"method":"getAverageSpectrum", "relFITSFilePath":_relFITSFilePath, "iRA0": iRA0, "iRA1": iRA1, "iDEC0": iDEC0, "iDEC1": iDEC1 }).done(function(resp) {
......@@ -2014,7 +2089,7 @@ var SAMPPNGPublishControl = (function (Control) {
cdelt3prim = 1;
}
var plotData = JSON.parse(JSON.stringify(_frequencyPlot));
for (var i = 0; i < rlen; i++) {
let tmp = linearTabulator(_crval3, _cdelt3, _crpix3, i+1);
......@@ -2056,15 +2131,15 @@ var SAMPPNGPublishControl = (function (Control) {
}
}
}
plotData.x = xData;
plotData2.x = xData;
switch (_ctype3) {
case 'FREQ' :
if (_cdelt3 > 0) {
plotData.y = revertArray(averageSpectrum);
plotData2.y = revertArray(averageSpectrum);
}
else {
plotData.y = averageSpectrum;
plotData2.y = averageSpectrum;
}
break;
......@@ -2074,10 +2149,10 @@ var SAMPPNGPublishControl = (function (Control) {
case 'AWAV':
averageSpectrum = averageSpectrum.map(function(x) {return x* unitRescale(summedPixelsSpectrumUnit(_bunit))});
if (_cdelt3 > 0) {
plotData.y = averageSpectrum;
plotData2.y = averageSpectrum;
}
else {
plotData.y = revertArray(averageSpectrum);
plotData2.y = revertArray(averageSpectrum);
}
break;
......@@ -2085,37 +2160,56 @@ var SAMPPNGPublishControl = (function (Control) {
console.log("This should not happen");
break;
}
let highChartData = [];
for(let i=0; i< plotData2.x.length; i++){
highChartData.push([plotData2.x[i], plotData2.y[i]]);
}
myChart2.series[0].update({
name : '',
// unlimited number of points when zooming
cropThreshold: Infinity,
showInLegend: false,
marker: {
width: 16,
height: 16
},
data: highChartData
} );
summedAverageSpectrum = sumArr(averageSpectrum, start, end, cdelt3prim);
//~ summedAverageSpectrum = sumArr(averageSpectrum, start, end, cdelt3prim);
var maxVal = Math.max.apply(Math, plotData.y);
var minVal = Math.min.apply(Math, plotData.y);
//~ var maxVal = Math.max.apply(Math, plotData.y);
//~ var minVal = Math.min.apply(Math, plotData.y);
_layout.title = toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit);
_layout.xaxis.title = xtitle;
_layout.xaxis.range = [plotData.x[0], plotData.x[plotData.x.length-1]];
_layout.xaxis.tickvals = xIndexes;
_layout.xaxis.tickmode = "auto";
_layout.dragmode = "select";
//~ _layout.title = toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit);
//~ _layout.xaxis.title = xtitle;
//~ _layout.xaxis.range = [plotData.x[0], plotData.x[plotData.x.length-1]];
//~ _layout.xaxis.tickvals = xIndexes;
//~ _layout.xaxis.tickmode = "auto";
//~ _layout.dragmode = "select";
_frequencyPlotBorder.xaxis = "x";
_frequencyPlotBorder.x = plotData.x;
_frequencyPlotBorder.y = Array.apply(null, Array(plotData.x.length)).map(function(x, i) { return plotData.y[i]; });
_frequencyPlotBorder.fill = 'tozeroy';
//~ _frequencyPlotBorder.xaxis = "x";
//~ _frequencyPlotBorder.x = plotData.x;
//~ _frequencyPlotBorder.y = Array.apply(null, Array(plotData.x.length)).map(function(x, i) { return plotData.y[i]; });
//~ _frequencyPlotBorder.fill = 'tozeroy';
_frequencyPlotBorder.fillcolor = "yellow";
//~ _frequencyPlotBorder.fillcolor = "yellow";
_itsGD.data = [ plotData, _frequencyPlotBorder];
//~ _itsGD.data = [ plotData, _frequencyPlotBorder];
_itsGD.layout = _layout;
Plotly.redraw(_itsGD);
//~ _itsGD.layout = _layout;
var data = [];
//~ Plotly.redraw(_itsGD);
_itsGD.removeAllListeners('plotly_relayout');
_itsGD.removeAllListeners('plotly_selected');
//~ _itsGD.removeAllListeners('plotly_relayout');
//~ _itsGD.removeAllListeners('plotly_selected');
_itsGD.on('plotly_afterplot', function() {
_itsGD.layout.dragmode = "select";
});
//~ _itsGD.on('plotly_afterplot', function() {
//~ _itsGD.layout.dragmode = "select";
//~ });
var justRelayedout = false;
......@@ -2139,7 +2233,7 @@ var SAMPPNGPublishControl = (function (Control) {
}
var velocityUpdate = {
'xaxis.autorange' : false,
'xaxis.range' : [plotData.x[0], plotData.x[plotData.x.length-1]],
'xaxis.range' : [plotData2.x[0], plotData2.x[plotData2.x.length-1]],
'yaxis.range[0]' : minVal,
'yaxis.range[1]' : maxVal
};
......@@ -2147,8 +2241,8 @@ var SAMPPNGPublishControl = (function (Control) {
else {
if (_companion && _companion.getGD()) {
ifrequency0 = Math.round((pdata["xaxis.range[0]"] - plotData.x[0])/(plotData.x[1] - plotData.x[0]));
ifrequency1 = Math.round((pdata["xaxis.range[1]"] - plotData.x[0])/(plotData.x[1] - plotData.x[0]));
ifrequency0 = Math.round((pdata["xaxis.range[0]"] - plotData2.x[0])/(plotData2.x[1] - plotData2.x[0]));
ifrequency1 = Math.round((pdata["xaxis.range[1]"] - plotData2.x[0])/(plotData2.x[1] - plotData2.x[0]));
var frequencyUpdate = {
'xaxis.autorange' : false,
......@@ -2193,14 +2287,14 @@ var SAMPPNGPublishControl = (function (Control) {
return;
}
var imin = Math.round((pdata["range"]["x"][0] - plotData.x[0]) / (plotData.x[1]-plotData.x[0]));
var imax = Math.round((pdata["range"]["x"][1] - plotData.x[0]) / (plotData.x[1]-plotData.x[0]));
var imin = Math.round((pdata["range"]["x"][0] - plotData2.x[0]) / (plotData2.x[1]-plotData2.x[0]));
var imax = Math.round((pdata["range"]["x"][1] - plotData2.x[0]) / (plotData2.x[1]-plotData2.x[0]));
ROI.iFREQ0 = imin;
ROI.iFREQ1 = imax;
_frequencyPlotBorder.x=range(imin, imax-imin+1).map( i => plotData.x[i]) ;
_frequencyPlotBorder.y=range(imin, imax-imin+1).map( i => plotData.y[i] );
_frequencyPlotBorder.x=range(imin, imax-imin+1).map( i => plotData2.x[i]) ;
_frequencyPlotBorder.y=range(imin, imax-imin+1).map( i => plotData2.y[i] );
summedAverageSpectrum = sumArr(averageSpectrum, imin, imax+1, cdelt3prim);
_itsGD.layout.title = toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit);
......@@ -2210,7 +2304,7 @@ var SAMPPNGPublishControl = (function (Control) {
switch (_ctype3) {
case 'FREQ':
if (_cdelt3 > 0) {
sliceViewer.updateSummedSlices(plotData.x.length-1-imax, plotData.x.length-1-imin);
sliceViewer.updateSummedSlices(plotData2.x.length-1-imax, plotData2.x.length-1-imin);
}
else {
sliceViewer.updateSummedSlices(imin, imax);
......@@ -2224,7 +2318,7 @@ var SAMPPNGPublishControl = (function (Control) {
sliceViewer.updateSummedSlices(imin, imax);
}
else {
sliceViewer.updateSummedSlices(plotData.x.length-1-imax, plotData.x.length-1-imin);
sliceViewer.updateSummedSlices(plotData2.x.length-1-imax, plotData2.x.length-1-imin);
}
break;
default:
......@@ -2595,7 +2689,7 @@ var SAMPPNGPublishControl = (function (Control) {
var gdSpectrum = document.getElementById('spectrum');//d3.select('#spectrum').node();
spectrumViewer = new SpectrumViewer (relFITSFilePath, header, gdSpectrum);
var gdSummedPixelsPpectrum = d3.select('#summedpixelsspectrum').node();
var gdSummedPixelsPpectrum = document.getElementById('summedpixelsspectrum'); //d3.select('#summedpixelsspectrum').node();
summedPixelsSpectrumViewer = new SummedPixelsSpectrumViewer(relFITSFilePath, header, gdSummedPixelsPpectrum);
summedPixelsSpectrumViewer.setCompanion(spectrumViewer);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment