Skip to content

Commit 9624608

Browse files
committed
Heatmap - support using the same XY space for multiple plots
1 parent 050d4d1 commit 9624608

File tree

6 files changed

+93
-43
lines changed

6 files changed

+93
-43
lines changed

src/firefly/html/demo/ffapi-slate-test2.html

Lines changed: 74 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@
5353
</div>
5454
<pre>
5555
try:
56-
148.88822;69.06529;EQ_J2000
57-
202.48417;47.23056;EQ_J2000
56+
148.88822;69.06529;EQ_J2000 # Galaxy M81
57+
202.48417;47.23056;EQ_J2000 # Galaxy M51
58+
136.9316774;+1.1195886;galactic # W5 star-forming region
59+
10.68479;41.26906;EQ_J2000 # Galaxy M31
5860
</pre>
5961

6062

@@ -74,16 +76,16 @@
7476
Add Some plotly Charts
7577
<ul>
7678
<li>
77-
<a href='javascript:loadNewCharts(0,0,2,2)'>Show new Plotly </a> <span class='smallCoords'>at row: 0, col: 4, w:2 h: 2</span>
79+
<a href='javascript:loadNewCharts(0,0,2,2)'>Show Scatter </a> <span class='smallCoords'>at row: 0, col: 4, w:2 h: 2</span>
7880
</li>
7981
<li>
80-
<a href='javascript:loadNewHeatmapCharts(2,0,2,3)'>Show new Heat Map </a> <span class='smallCoords'>at row: 2, col: 0, w:2 h: 3</span>
82+
<a href='javascript:loadNewHeatmapCharts(2,0,2,3)'>Show Heatmap </a> <span class='smallCoords'>at row: 2, col: 0, w:2 h: 3</span>
8183
</li>
8284
<li>
8385
<a href='javascript:loadHistogramCharts(2,2,2,3)'>Show Histogram</a> <span class='smallCoords'>at row: 2, col: 2, w:2 h: 3</span>
8486
</li>
8587
<li>
86-
<a href='javascript:load3DChart(2,4,2,3)'>3d Charts</a> <span class='smallCoords'>at row: 2, col: 4, w:2 h: 3</span>
88+
<a href='javascript:load3DChart(2,4,2,3)'>Show 3d Scatter</a> <span class='smallCoords'>at row: 2, col: 4, w:2 h: 3</span>
8789
</li>
8890
</ul>
8991

@@ -94,7 +96,7 @@
9496
<a href="javascript:load3C(getSTarget(),0,2,2,2)">3 Color</a> in cell <span class='smallCoords'>at row: 0, col: 2, w:2 h: 2</span>
9597
</li>
9698
</ul>
97-
99+
</body>
98100

99101

100102
<script type="text/javascript">
@@ -147,7 +149,7 @@
147149
WorldPt : sTarget,
148150
RangeValues : firefly.util.image.RangeValues.serializeSimple('Sigma',-2,8,'Linear'),
149151
SizeInDeg : '1'
150-
},
152+
}
151153
];
152154

153155

@@ -160,15 +162,23 @@
160162
function loadNewCharts(r,c,w,h) {
161163
firefly.getViewer().addCell(r,c,w,h, 'xyPlots', 'newChartContainer');
162164

163-
trace1 = {
164-
x: "tables::wiseCatTbl,ra",
165-
y: "tables::wiseCatTbl,dec",
165+
var trace1 = {
166+
x: "tables::wiseCatTbl,w1mpro-w2mpro",
167+
y: "tables::wiseCatTbl,w2mpro-w3mpro",
166168
mode: 'markers',
167-
type: 'scatter'
169+
type: 'scatter',
170+
marker: {size: 4, opacity: 0.5}
168171
};
169172

170-
firefly.getViewer().showPlot({chartId: 'newChart1', data: [trace1], fireflyData: [{dataType: 'fireflyScatter'}]},
171-
'newChartContainer');
173+
var layoutS = {
174+
title: 'Color-Color',
175+
xaxis: {title: 'w1mpro-w2mpro (mag)'},
176+
yaxis: {title: 'w2mpro-w3mpro (mag)'}
177+
};
178+
179+
firefly.getViewer().showPlot(
180+
{chartId: 'newChart1', layout: layoutS, data: [trace1], fireflyData: [{dataType: 'fireflyScatter'}]},
181+
'newChartContainer');
172182
}
173183

174184
function loadNewHeatmapCharts(r,c,w,h) {
@@ -199,22 +209,40 @@
199209
colorscale: 'Greens'
200210
}
201211
];
212+
// use firefly algorithm to create heatmap data
202213
var fireflyDataHM = [
203214
{dataType: 'fireflyHeatmap'},
204215
{dataType: 'fireflyHeatmap'},
205216
{dataType: 'fireflyHeatmap'}
206217
];
218+
var layoutHM = {
219+
title: 'Magnitude-magnitude densities',
220+
xaxis: {title: 'w1 photometry (mag)'},
221+
yaxis: {title: ''}
222+
};
223+
// user boundaries - so that heatmaps will be calculated in the same XY space
224+
var fireflyLayoutHM = {
225+
xaxis: {
226+
min: 5,
227+
max: 20
228+
},
229+
yaxis: {
230+
min: 4,
231+
max: 18
232+
}
233+
};
207234

208-
firefly.getViewer().showPlot({chartId: 'newChart2', data: dataHM, fireflyData:fireflyDataHM },
209-
'heatMapContainer');
235+
firefly.getViewer().showPlot(
236+
{chartId: 'newChart2', layout: layoutHM, data: dataHM, fireflyData:fireflyDataHM, fireflyLayout:fireflyLayoutHM},
237+
'heatMapContainer');
210238
}
211239

212240
function loadHistogramCharts(r,c,w,h) {
213241
firefly.getViewer().addCell(r,c,w,h, 'xyPlots', 'histContainer');
214242

215243
var dataH = [
216-
{name: 'dec-0.02', marker: {color: 'rgba(153, 51, 153, 0.8)'}},
217-
{name: 'dec+0.02', marker: {color: 'rgba(102,153,0, 0.7)'}}
244+
{name: 'w1mpro', marker: {color: 'rgba(153, 51, 153, 0.8)'}},
245+
{name: 'w2mpro', marker: {color: 'rgba(102,153,0, 0.7)'}}
218246
];
219247

220248
var fireflyDataH = [
@@ -225,7 +253,7 @@
225253
algorithm: 'fixedSizeBins',
226254
fixedBinSizeSelection: 'numBins',
227255
numBins: 30,
228-
columnOrExpr: 'dec-0.02'
256+
columnOrExpr: 'w1mpro'
229257
}
230258
},
231259
{
@@ -235,17 +263,26 @@
235263
algorithm: 'fixedSizeBins',
236264
fixedBinSizeSelection: 'numBins',
237265
numBins: 40,
238-
columnOrExpr: 'dec+0.02' // same column but shifted
266+
columnOrExpr: 'w2mpro' // same column but shifted
239267
}
240268
}
241269
];
242-
firefly.getViewer().showPlot({chartId: 'firefly-hist-tbl', data: dataH, fireflyData: fireflyDataH},
243-
'histContainer');
270+
271+
var layoutHist = {
272+
title: 'Photometry histogram',
273+
xaxis: {title: 'photometry (mag)'},
274+
yaxis: {title: ''}
275+
};
276+
277+
firefly.getViewer().showPlot(
278+
{chartId: 'firefly-hist-tbl', layout: layoutHist, data: dataH, fireflyData: fireflyDataH},
279+
'histContainer');
244280
}
245281

246282
function load3DChart(r,c,w,h) {
247283
firefly.getViewer().addCell(r,c,w,h, 'xyPlots', '3dChartContainer');
248284

285+
249286
var data3d = [
250287
{
251288
type: 'scatter3d',
@@ -265,29 +302,34 @@
265302
}
266303
];
267304

268-
layout3d = {
269-
title: 'Scatter 3D on w1mpro, w2mpro and w3mpro',
270-
scene: {
305+
var tfont = {size: 11};
306+
var layout3d = {
307+
title: 'Photometry in band 1, 2, 3',
308+
scene:{
271309
xaxis: {
272-
title: 'w1'
310+
title: 'w1 (mag)',
311+
titlefont: tfont
273312
},
274313
yaxis: {
275-
title: 'w2'
314+
title: 'w2 (mag)',
315+
titlefont: tfont
276316
},
277317
zaxis: {
278-
title: 'w3'
318+
title: 'w3 (mag)',
319+
titlefont: tfont
279320
}
280321
}
281322
};
282323

283-
firefly.getViewer().showPlot({chartId: 'newChart3', data: data3d, layout: layout3d },
284-
'3dChartContainer');
324+
firefly.getViewer().showPlot(
325+
{chartId: 'newChart3', layout: layout3d, data: data3d },
326+
'3dChartContainer');
285327
}
286328

287329

288330
function showATable(sTarget,r,c,w,h) {
289331
firefly.getViewer().addCell(r,c,w,h, 'tables');
290-
var req= firefly.util.table.makeIrsaCatalogRequest('another wise catalog', 'WISE', 'allwise_p3as_psd',
332+
var req= firefly.util.table.makeIrsaCatalogRequest('WISE catalog', 'WISE', 'allwise_p3as_psd',
291333
{ position: sTarget,
292334
SearchMethod: 'Cone',
293335
radius: 1200,
@@ -343,11 +385,12 @@
343385
};
344386

345387
}
346-
388+
347389
</script>
348390

349391
<!-- to try a container: <script type="text/javascript" src="http://localhost:8090/firefly/firefly_loader.js"></script>-->
350392

351393
<script type="text/javascript" src="../firefly_loader.js"></script>
352394

353395

396+
</html>

src/firefly/java/edu/caltech/ipac/firefly/server/util/QueryUtil.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -790,13 +790,17 @@ public static DataGroup doDecimation(DataGroup dg, DecimateInfo decimateInfo) th
790790
}
791791

792792
if (doDecimation) {
793-
794793
boolean checkLimits = false;
795794
if (checkDeciLimits) {
796-
if (xDeciMin > xMin) { xMin = xDeciMin; checkLimits = true; }
797-
if (xDeciMax < xMax) { xMax = xDeciMax; checkLimits = true; }
798-
if (yDeciMin > yMin) { yMin = yDeciMin; checkLimits = true; }
799-
if (yDeciMax < yMax) { yMax = yDeciMax; checkLimits = true; }
795+
if (xDeciMin > xMin || xDeciMax < xMax || yDeciMin > yMin || yDeciMax < yMax) {
796+
checkLimits = true;
797+
}
798+
799+
// use boundaries provided in decimate info, if available
800+
if (!Double.isNaN(decimateInfo.getXMin())) { xMin = xDeciMin; }
801+
if (!Double.isNaN(decimateInfo.getXMax())) { xMax = xDeciMax; }
802+
if (!Double.isNaN(decimateInfo.getYMin())) { yMin = yDeciMin; }
803+
if (!Double.isNaN(decimateInfo.getYMax())) { yMax = yDeciMax; }
800804
}
801805

802806
if (outRows < deciEnableSize) {

src/firefly/js/charts/ChartsCntlr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,13 @@ export function makeChartDataFetch (getChartDataType) {
313313

314314
function chartAdd(action) {
315315
return (dispatch) => {
316-
const {chartId, chartType, viewerId='main', data, fireflyData} = action.payload;
316+
const {chartId, chartType, viewerId='main', data, fireflyData, fireflyLayout} = action.payload;
317317
clearChartConn({chartId});
318318
dispatch(action);
319319
if (chartType === 'plot.ly') {
320320
dispatchAddViewer(viewerId,true,'plot2d',true);
321321
dispatchAddViewerItems(viewerId, [chartId], 'plot2d');
322-
handleTableSourceConnections({chartId, data, fireflyData});
322+
handleTableSourceConnections({chartId, data, fireflyData, fireflyLayout});
323323
}
324324
};
325325
}

src/firefly/js/charts/dataTypes/FireflyHeatmap.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ export function getTraceTSEntries({traceTS, chartId, traceNum}) {
2929
xyratio = xbins/ybins;
3030
}
3131

32-
//TODO: take into account zoom? and boundaries
33-
const {xmin, xmax, ymin, ymax} = {};
32+
//should we take into account zoom?
33+
const xmin = get(fireflyLayout, 'xaxis.min');
34+
const xmax = get(fireflyLayout, 'xaxis.max');
35+
const ymin = get(fireflyLayout, 'yaxis.min');
36+
const ymax = get(fireflyLayout, 'yaxis.max');
3437

3538
const options = {
3639
xColOrExpr: get(mappings, 'x'),

src/firefly/js/charts/dataTypes/FireflyScatter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ function addOtherChanges({changes, xLabel, xTipLabel, xUnit, yLabel, yTipLabel,
155155
const yval = y[idx];
156156
const xerr = hasXErrors ? formatError(xval, xErr[idx], xErrLow[idx], xErrHigh[idx]) : '';
157157
const yerr = hasYErrors ? formatError(yval, yErr[idx], yErrLow[idx], yErrHigh[idx]) : '';
158-
return `<span> ${xTipLabel} = ${xval}${xerr} ${xUnit} <br>` +
159-
` ${yTipLabel} = ${yval}${yerr} ${yUnit} </span>`;
158+
return `<span> ${xTipLabel} = ${parseFloat(xval)}${xerr} ${xUnit} <br>` +
159+
` ${yTipLabel} = ${parseFloat(yval)}${yerr} ${yUnit} </span>`;
160160
});
161161
changes[`data.${traceNum}.text`] = text;
162162
changes[`data.${traceNum}.hoverinfo`] = 'text';

src/firefly/js/tables/Decimate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const serializeDecimateInfo = function(xColumnName, yColumnName, maxPoint
2929
const orderedNumericProps = [maxPoints, xyRatio, xMin, xMax, yMin, yMax, deciEnableLimit];
3030
const deciStrStart = `${DECIMATE_TAG}=${xColumnName},${yColumnName}`;
3131
return orderedNumericProps.reduce((sres, val)=>{
32-
return sres + ',' + (Number.isFinite(val) ? val : '');
32+
return sres + ',' + (Number.isFinite(Number.parseFloat(val)) ? val : '');
3333
}, deciStrStart);
3434
};
3535

0 commit comments

Comments
 (0)