Skip to content

Commit af97f0d

Browse files
authored
DM-11601 showChart API changes – merge pr #459
DM-11601 showChart API changes
2 parents 8fb6553 + e71728e commit af97f0d

12 files changed

+214
-151
lines changed

src/firefly/html/demo/ffapi-highlevel-charttest.html

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h2>
3131
<br/><br/>
3232
<div id="xyplotHere" style="width: 800px; height: 550px; border: solid 1px;"></div>
3333
<br/><br/>
34-
<div id="plotly" style="resize: both; overflow: auto; padding: 5px; width: 800px; height: 550px; border: solid 1px gray;"></div>
34+
<div id="plotlyDiv" style="resize: both; overflow: auto; padding: 5px; width: 800px; height: 550px; border: solid 1px gray;"></div>
3535
<br/><br/>
3636
<div id="table-1" style="width: 800px; height: 550px; border: solid 1px;"></div>
3737
<br/><br/>
@@ -97,33 +97,36 @@ <h2>
9797
// firefly.util.renderDOM('histogramHere', firefly.ui.Histogram, props);
9898

9999
var dataH = [
100-
{name: 'dec-0.02', marker: {color: 'rgba(153, 51, 153, 0.8)'}},
101-
{name: 'dec+0.02', marker: {color: 'rgba(102,153,0, 0.7)'}}
102-
];
103-
104-
var fireflyDataH = [
105100
{
106-
dataType: 'fireflyHistogram',
107-
tbl_id: 'test-tbl',
108-
options: {
109-
algorithm: 'fixedSizeBins',
110-
fixedBinSizeSelection: 'numBins',
111-
numBins: 30,
112-
columnOrExpr: 'dec-0.02'
113-
}
101+
type: 'fireflyHistogram',
102+
firefly: {
103+
tbl_id: 'test-tbl',
104+
options: {
105+
algorithm: 'fixedSizeBins',
106+
fixedBinSizeSelection: 'numBins',
107+
numBins: 30,
108+
columnOrExpr: 'dec-0.02'
109+
}
110+
},
111+
name: 'dec-0.02',
112+
marker: {color: 'rgba(153, 51, 153, 0.8)'}
114113
},
115114
{
116-
dataType: 'fireflyHistogram',
117-
tbl_id: 'test-tbl',
118-
options: {
119-
algorithm: 'fixedSizeBins',
120-
fixedBinSizeSelection: 'numBins',
121-
numBins: 40,
122-
columnOrExpr: 'dec+0.02' // same column but shifted
123-
}
124-
}
115+
type: 'fireflyHistogram',
116+
firefly: {
117+
tbl_id: 'test-tbl',
118+
options: {
119+
algorithm: 'fixedSizeBins',
120+
fixedBinSizeSelection: 'numBins',
121+
numBins: 40,
122+
columnOrExpr: 'dec+0.02' // same column but shifted
123+
}
124+
},
125+
name: 'dec+0.02',
126+
marker: {color: 'rgba(102,153,0, 0.7)'}}
125127
];
126-
firefly.showPlot('histogramHere', {chartId: 'firefly-hist-tbl', chartType: 'plot.ly', data: dataH, fireflyData: fireflyDataH});
128+
129+
firefly.showChart('histogramHere', {data: dataH});
127130

128131

129132
// show scatter chart
@@ -151,7 +154,7 @@ <h2>
151154
};
152155

153156
var data = [trace1, trace2];
154-
firefly.showPlot('plotly', {chartId: 'test', chartType: 'plot.ly', data: data});
157+
firefly.showChart('plotlyDiv', {data: data});
155158

156159

157160
var tblReq = firefly.util.table.makeIrsaCatalogRequest('allwise_p3as_psd', 'WISE', 'allwise_p3as_psd',
@@ -167,14 +170,14 @@ <h2>
167170
firefly.showTable('table-1', tblReq);
168171

169172
trace1 = {
170-
tbl_id: "test-tbl",
171-
x: "tables::ra",
172-
y: "tables::dec",
173-
mode: 'markers',
174-
type: 'scatter'
173+
type: 'fireflyScatter',
174+
tbl_id: 'test-tbl',
175+
x: 'tables::ra',
176+
y: 'tables::dec',
177+
mode: 'markers'
175178
};
176179

177-
firefly.showPlot('plotly', {chartId: 'plotly-tbl', chartType: 'plot.ly', data: [trace1], fireflyData: [{dataType: 'fireflyScatter'}]});
180+
firefly.showChart('plotlyDiv', {data: [trace1]});
178181

179182

180183
var tblReqLg = firefly.util.table.makeIrsaCatalogRequest('allwise_p3as_psd', 'WISE', 'allwise_p3as_psd',
@@ -187,38 +190,33 @@ <h2>
187190

188191
var dataHM = [
189192
{
193+
type: 'fireflyHeatmap',
190194
tbl_id: "test-tbl-lg",
191-
type: 'heatmap',
192-
name: 'w1-w2',
193195
x: "tables::w1mpro",
194196
y: "tables::w2mpro",
197+
name: 'w1-w2',
195198
colorscale: 'Blues'
196199
},
197200
{
201+
type: 'fireflyHeatmap',
198202
tbl_id: "test-tbl-lg",
199-
type: 'heatmap',
200-
name: 'w1-w3',
201203
x: "tables::w1mpro",
202204
y: "tables::w3mpro",
205+
name: 'w1-w3',
203206
colorscale: 'Reds',
204207
reversescale: true
205208
},
206209
{
210+
type: 'fireflyHeatmap',
207211
tbl_id: "test-tbl-lg",
208-
type: 'heatmap',
209-
name: 'w1-w4',
210212
x: "tables::w1mpro",
211213
y: "tables::w4mpro",
214+
name: 'w1-w4',
212215
colorscale: 'Greens'
213216
}
214217
];
215-
var fireflyDataHM = [
216-
{dataType: 'fireflyHeatmap'},
217-
{dataType: 'fireflyHeatmap'},
218-
{dataType: 'fireflyHeatmap'}
219-
];
220218

221-
firefly.showPlot('heatmapHere', {chartId: 'plotly-tbl-lg', chartType: 'plot.ly', data: dataHM, fireflyData: fireflyDataHM});
219+
firefly.showChart('heatmapHere', {data: dataHM});
222220

223221
}
224222
}

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

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
x: "tables::w1mpro-w2mpro",
168168
y: "tables::w2mpro-w3mpro",
169169
mode: 'markers',
170-
type: 'scatter',
170+
type: 'fireflyScatter',
171171
marker: {size: 4, opacity: 0.5}
172172
};
173173

@@ -177,8 +177,8 @@
177177
yaxis: {title: 'w2mpro-w3mpro (mag)'}
178178
};
179179

180-
firefly.getViewer().showPlot(
181-
{chartId: 'newChart1', layout: layoutS, data: [trace1], fireflyData: [{dataType: 'fireflyScatter'}]},
180+
firefly.getViewer().showChart(
181+
{chartId: 'newChart1', layout: layoutS, data: [trace1]},
182182
'newChartContainer');
183183
}
184184

@@ -188,88 +188,83 @@
188188

189189
var dataHM = [
190190
{
191+
type: 'fireflyHeatmap',
191192
tbl_id: "wiseCatTbl",
192-
type: 'heatmap',
193-
name: 'w1-w2',
194193
x: "tables::w1mpro",
195194
y: "tables::w2mpro",
195+
name: 'w1-w2',
196196
colorscale: 'Blues'
197197
},
198198
{
199+
type: 'fireflyHeatmap',
199200
tbl_id: "wiseCatTbl",
200-
type: 'heatmap',
201-
name: 'w1-w3',
202201
x: "tables::w1mpro",
203202
y: "tables::w3mpro",
203+
name: 'w1-w3',
204204
colorscale: 'Reds',
205205
reversescale: true
206206
},
207207
{
208+
type: 'fireflyHeatmap',
208209
tbl_id: "wiseCatTbl",
209-
type: 'heatmap',
210-
name: 'w1-w4',
211210
x: "tables::w1mpro",
212211
y: "tables::w4mpro",
212+
name: 'w1-w4',
213213
colorscale: 'Greens'
214214
}
215215
];
216-
// use firefly algorithm to create heatmap data
217-
var fireflyDataHM = [
218-
{dataType: 'fireflyHeatmap'},
219-
{dataType: 'fireflyHeatmap'},
220-
{dataType: 'fireflyHeatmap'}
221-
];
222216
var layoutHM = {
223217
title: 'Magnitude-magnitude densities',
224218
xaxis: {title: 'w1 photometry (mag)'},
225-
yaxis: {title: ''}
226-
};
227-
// user boundaries - so that heatmaps will be calculated in the same XY space
228-
var fireflyLayoutHM = {
229-
xaxis: {
230-
min: 5,
231-
max: 20
232-
},
233-
yaxis: {
234-
min: 4,
235-
max: 18
219+
yaxis: {title: ''},
220+
firefly: { // user boundaries - so that heatmaps will be calculated in the same XY space
221+
xaxis: {
222+
min: 5,
223+
max: 20
224+
},
225+
yaxis: {
226+
min: 4,
227+
max: 18
228+
}
236229
}
237230
};
238231

239-
firefly.getViewer().showPlot(
240-
{chartId: 'newChart2', layout: layoutHM, data: dataHM, fireflyData:fireflyDataHM, fireflyLayout:fireflyLayoutHM},
232+
firefly.getViewer().showChart(
233+
{chartId: 'newChart2', layout: layoutHM, data: dataHM},
241234
'heatMapContainer');
242235
}
243236

244237
function loadHistogramCharts(r,c,w,h) {
245238
firefly.getViewer().addCell(r,c,w,h, 'xyPlots', 'histContainer');
246239

247240
var dataH = [
248-
{name: 'w1mpro', marker: {color: 'rgba(153, 51, 153, 0.8)'}},
249-
{name: 'w2mpro', marker: {color: 'rgba(102,153,0, 0.7)'}}
250-
];
251-
252-
var fireflyDataH = [
253241
{
254-
dataType: 'fireflyHistogram',
255-
tbl_id: 'wiseCatTbl',
256-
options: {
257-
algorithm: 'fixedSizeBins',
258-
fixedBinSizeSelection: 'numBins',
259-
numBins: 30,
260-
columnOrExpr: 'w1mpro'
261-
}
242+
type: 'fireflyHistogram',
243+
firefly: {
244+
tbl_id: 'wiseCatTbl',
245+
options: {
246+
algorithm: 'fixedSizeBins',
247+
fixedBinSizeSelection: 'numBins',
248+
numBins: 30,
249+
columnOrExpr: 'w1mpro'
250+
}
251+
},
252+
name: 'w1mpro',
253+
marker: {color: 'rgba(153, 51, 153, 0.8)'}
262254
},
263255
{
264-
dataType: 'fireflyHistogram',
265-
tbl_id: 'wiseCatTbl',
266-
options: {
267-
algorithm: 'fixedSizeBins',
268-
fixedBinSizeSelection: 'numBins',
269-
numBins: 40,
270-
columnOrExpr: 'w2mpro' // same column but shifted
271-
}
272-
}
256+
type: 'fireflyHistogram',
257+
firefly: {
258+
tbl_id: 'wiseCatTbl',
259+
options: {
260+
algorithm: 'fixedSizeBins',
261+
fixedBinSizeSelection: 'numBins',
262+
numBins: 40,
263+
columnOrExpr: 'w2mpro'
264+
}
265+
},
266+
name: 'w2mpro',
267+
marker: {color: 'rgba(102,153,0, 0.7)'}}
273268
];
274269

275270
var layoutHist = {
@@ -278,8 +273,8 @@
278273
yaxis: {title: ''}
279274
};
280275

281-
firefly.getViewer().showPlot(
282-
{chartId: 'firefly-hist-tbl', layout: layoutHist, data: dataH, fireflyData: fireflyDataH},
276+
firefly.getViewer().showChart(
277+
{chartId: 'firefly-hist-tbl', layout: layoutHist, data: dataH},
283278
'histContainer');
284279
}
285280

@@ -326,7 +321,7 @@
326321
}
327322
};
328323

329-
firefly.getViewer().showPlot(
324+
firefly.getViewer().showChart(
330325
{chartId: 'newChart3', layout: layout3d, data: data3d },
331326
'3dChartContainer');
332327
}

0 commit comments

Comments
 (0)