Commit 4b1788ec authored by Caillat Michel's avatar Caillat Michel
Browse files

Fix click on graph problem

parent 6d2a2ccb
......@@ -156,8 +156,7 @@ padding-top : 0.5em;
}
.col .chart-title{
padding-left : 750px;
margin-bottom : 2em;
margin-left : -80px;
}
.hidden{
......
......@@ -105,7 +105,7 @@
<div id="external_mouse_position_1" class="external_mouse_position"></div>
</div>
<div class="col">
<div id="debug_jpk"></div>
<div id="spectrum_info_title" class="chart-title"></div>
</div>
</div>
<div class="row">
......@@ -131,6 +131,11 @@
<div class="col">
<div id="external_mouse_position_2" class="external_mouse_position"></div>
</div>
<div class="col">
<div class="chart-title">
<span id="chart_title"></span>
</div>
</div>
</div>
<div class="row">
<div class="col chart-img">
......@@ -143,13 +148,6 @@
<div id="publish_summedpixelsspectrum"></div>
</div>
</div>
<div class="row">
<div class="col">
<div class="chart-title">
<span id="chart_title"></span>
</div>
</div>
</div>
</div>
<div class="container chart-container hidden">
......@@ -274,7 +272,7 @@
var EXIT = function () { console.log(arguments.callee.name + ": exiting."); };
const PLOT_WIDTH = 780;
const PLOT_RATIO = "65%";
const PLOT_COLOR ="#F5F101";
const PLOT_COLOR = "#F5F101";
<%if (useSAMP) {%>
var sAMPPublisher = null;
......@@ -317,6 +315,46 @@
}
/**
Returns index of slice to be displayed
plotData : spectrum
x : x position clicked on graph
*/
function computeSliceIndex(plotData, x){
var rlen = plotData.x.length;
switch (_ctype3) {
case 'FREQ':
if (_cdelt3 > 0) {
var forigin = plotData.x[rlen - 1];
var deltaf = plotData.x[0] - plotData.x[1];
}
else {
var forigin = plotData.x[0];
var deltaf = plotData.x[1] - plotData.x[0];
}
break;
case 'VRAD':
case 'WAVE':
case 'WAVN':
case 'AWAV':
if (_cdelt3 > 0) {
var forigin = plotData.x[0];
var deltaf = plotData.x[1] - plotData.x[0];
}
else {
var forigin = plotData.x[rlen - 1];
var deltaf = plotData.x[0] - plotData.x[1];
}
break;
default:
console.log("This should not happen");
}
return phys2Index(x, forigin, deltaf);
}
/**
calculate the value displayed as title of summed average spectrum
avgSpectrum array is reversed if data are radial velocities and
......@@ -363,9 +401,9 @@
lambda = null;
if (_origin.startsWith("GILDAS")){
if (_origin.startsWith("GILDAS")) {
lambda = speedOfLight / _restfreq;
}else{
} else {
lambda = speedOfLight / _crval3;
}
......@@ -373,12 +411,12 @@
step1 = 2 * kb * omega / (lambda * lambda);
let result = step1 / 1e-26;
let result = step1 / 1e-26;
return result;
}
function kelvinPerJansky() {
let jperk = janskyPerKelvin();
let jperk = janskyPerKelvin();
let result = 1. / jperk;
return result;
}
......@@ -387,6 +425,10 @@
return arcsec / 3600;
}
function degToArcsec(deg) {
return deg * 3600;
}
function degToRad(deg) {
return deg * (Math.PI / 180);
}
......@@ -1357,6 +1399,45 @@
return _relayoutTriggeredBy;
}
this.clickAction = function(event){
console.log("A click occurred on the spectrum : enter");
switch (_ctype3) {
case 'FREQ':
if (_cdelt3 > 0) {
var forigin = plotData.x[rlen - 1];
var deltaf = plotData.x[0] - plotData.x[1];
}
else {
var forigin = plotData.x[0];
var deltaf = plotData.x[1] - plotData.x[0];
}
break;
case 'VRAD':
case 'WAVE':
case 'WAVN':
case 'AWAV':
if (_cdelt3 > 0) {
var forigin = plotData.x[0];
var deltaf = plotData.x[1] - plotData.x[0];
}
else {
var forigin = plotData.x[rlen - 1];
var deltaf = plotData.x[0] - plotData.x[1];
}
break;
default:
console.log("This should not happen");
}
var sliceIndex = phys2Index(event.xAxis[0].value, forigin, deltaf);
// Display slice at index sliceIndex
sliceViewer.display(sliceIndex);
sliceViewer.setFluxDensityInPopup(event.yAxis[0].value);
this.series[1].update(getPoint(event.xAxis[0].value, true));
}
/*
** Let's initialize the plot.
*/
......@@ -1452,6 +1533,7 @@
let rlen = xData.length;
var plotData = JSON.parse(JSON.stringify(_frequencyPlot));
var self = this;
for (var i = 0; i < rlen; i++) {
let tmp = linearTabulator(_crval3, _cdelt3, _crpix3, i + 1);
if (getCunit3() in unitFactor) {
......@@ -1547,7 +1629,7 @@
}
<%}%>
plotData.xaxis = "x";
plotData.xaxis = "x";
var maxVal = Math.max.apply(Math, plotData.y);
var minVal = Math.min.apply(Math, plotData.y);
......@@ -1562,13 +1644,14 @@
highData.push([plotData.x[i], plotData.y[i]]);
}
let getPoint = function (x) {
let getPoint = function (x, visible) {
return {
type: 'scatter',
name: '',
showInLegend: false,
visible : visible,
marker: {
radius: 1
radius: 5
},
data: [{
x: x,
......@@ -1583,7 +1666,7 @@
text: toptitle
},
chart: {
type : 'area',
type: 'area',
width: PLOT_WIDTH,
height: PLOT_RATIO,
animation: false,
......@@ -1599,37 +1682,7 @@
click: function (event) {
console.log("A click occurred on the spectrum : enter");
switch (_ctype3) {
case 'FREQ':
if (_cdelt3 > 0) {
var forigin = plotData.x[rlen - 1];
var deltaf = plotData.x[0] - plotData.x[1];
}
else {
var forigin = plotData.x[0];
var deltaf = plotData.x[1] - plotData.x[0];
}
break;
case 'VRAD':
case 'WAVE':
case 'WAVN':
case 'AWAV':
if (_cdelt3 > 0) {
var forigin = plotData.x[0];
var deltaf = plotData.x[1] - plotData.x[0];
}
else {
var forigin = plotData.x[rlen - 1];
var deltaf = plotData.x[0] - plotData.x[1];
}
break;
default:
console.log("This should not happen");
}
var sliceIndex = phys2Index(event.xAxis[0].value, forigin, deltaf);
let sliceIndex = computeSliceIndex(plotData, event.xAxis[0].value);
// Display slice at index sliceIndex
sliceViewer.display(sliceIndex);
sliceViewer.setFluxDensityInPopup(event.yAxis[0].value);
......@@ -1686,36 +1739,50 @@
// result can be NaN if _bmin/_bmaj not available
// then nothing to display
if(!isNaN(kpj)){
label = " <br/> " + Number(this.value * kpj ).toExponential(2) + " K";
if (!isNaN(kpj)) {
label = " <br/> " + Number(this.value * kpj).toExponential(2) + " K";
}
document.getElementById("debug_jpk").innerHTML = "Jy per K : "+ Number(janskyPerKelvin()).toExponential(4);
document.getElementById("spectrum_info_title").innerHTML = "<span>" + Number(degToArcsec(_bmin)).toFixed(2) + "' x " + "</span>" +
"<span>" + Number(degToArcsec(_bmaj)).toFixed(2) + "', " + "</span>" +
"<span>"+"PA "+ Number(_bpa).toFixed(1) + "°" + "</span>"+
"<span>, " + Number(janskyPerKelvin()).toExponential(2) + " Jy/K</span> ";
return Number(this.value).toExponential(2) + label;
}
}
},
plotOptions: {
series: {
cursor : 'pointer',
step: true,
color: PLOT_COLOR,
animation: {
duration: 0
},
lineWidth: 1
lineWidth: 1,
events: {
click: function (event) {
console.log("A click occurred on the LINE : enter");
let sliceIndex = computeSliceIndex(plotData, event.point.x);
// Display slice at index sliceIndex
sliceViewer.display(sliceIndex);
sliceViewer.setFluxDensityInPopup(event.point.y);
this.chart.series[1].update(getPoint(event.point.x));
}
}
},
marker: {
radius: 0
}
},
tooltip: {
formatter: function () {
let label = '( ' + this.x.toFixed(4) + ', ' + this.y.toFixed(4) + ') ';
if(!isNaN(kpj)){
label = label + ", " + Number(this.y * kpj ).toExponential(2) + " K";
}
return label;
}
formatter: function () {
let label = '( ' + this.x.toFixed(4) + ', ' + this.y.toFixed(4) + ') ';
if (!isNaN(kpj)) {
label = label + ", " + Number(this.y * kpj).toExponential(2) + " K";
}
return label;
}
},
series: [
{
......@@ -1727,7 +1794,7 @@
radius: 0
}
}, getPoint(_frequencyMarker.x)
}, getPoint(_frequencyMarker.x, false)
]
});
sliceViewer.setFluxDensityInPopup(plotData.y[ifrequencyMarker]);
......@@ -1771,9 +1838,10 @@
let _averageSpectrum = null;
var toptitle = function (value, unit, vmin, vmax) {
return value.toExponential(4) +
" (" + unit + "), vmin = " +
vmin.toFixed(4) + " , vmax = " + vmax.toFixed(4);
return value.toExponential(2) +
unit + ", vmin = " +
vmin.toFixed(2) + " "+ "km/s" +" , vmax = " +
vmax.toFixed(2) + " " + "km/s";
}
this.setAverageSpectrum = function (averageSpectrum) {
......@@ -1822,17 +1890,17 @@
if (_instrume == "SITELLE") {
xtitle = _ctype3 + " (" + getCunit3() + ")";
ytitle = "FLUX (" + summedPixelsSpectrumUnit(header["BUNIT"]) + ")";
toptitle_unit = "ergs / s / cm^2";
toptitle_unit = "ergs/s/cm^2";
}
else if (_origin.startsWith("CASA")) {
xtitle = "Velocity (km/s) - " + _specsys;
ytitle = "Int. flux density (" + summedPixelsSpectrumUnit(_bunit) + ")";
toptitle_unit = "Jy . km / s";
toptitle_unit = "Jy.km/s";
}
else if (_origin.startsWith("GILDAS")) {
xtitle = "Velocity (km/s)"
ytitle = "Int. flux density (" + summedPixelsSpectrumUnit(_bunit) + ")"
toptitle_unit = "Jy . km / s";
toptitle_unit = "Jy.km/s";
}
else if (_instrume == "MUSE") {
xtitle = _ctype3 + " (" + getCunit3() + ")";
......@@ -1881,7 +1949,7 @@
text: ''
},
chart: {
type : 'area',
type: 'area',
animation: false,
width: PLOT_WIDTH,
height: PLOT_RATIO,
......@@ -1956,8 +2024,8 @@
return '( ' + this.x.toFixed(4) + ', ' + this.y.toFixed(4) + ')';
}
},
series: [
{color: PLOT_COLOR,}
series: [
{ color: PLOT_COLOR, }
]
});
......@@ -2454,9 +2522,9 @@
summedPixelsSpectrumViewer.plot(0, width - 1, 0, height - 1);
$('#rccap').click(function () { console.log("### click"); sliceViewer.refresh() });
$('#rccap').click(function () { sliceViewer.refresh() });
console.log('$.post("", {"method": "RADECRangeInDegrees", "relFITSFilePath": relFITSFilePath}).done(function (resp) { : exiting');
console.log('$.post("", {"method": "RADECRangeInDegrees", "relFITSFilePath": relFITSFilePath}).done(function (resp) { : exiting');
});
......
Markdown is supported
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