Skip to content

Commit fc5cafa

Browse files
committed
DM-7920 response to review comments:
- moved adding a default chart to FireflyViewerManager - renamed XYPlotCntlr to ChartDataTypeXYCols - renamed HistogramCntlr to ChartDataTypeHistogram - a bit of cleanup in docs
1 parent a933c56 commit fc5cafa

14 files changed

+202
-261
lines changed

src/firefly/js/api/ApiHighlevelBuild.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ function doShowXYPlot(llApi, targetDiv, params={}) {
467467
}
468468

469469
function doShowHistogram(llApi, targetDiv, params={}) {
470-
const {dispatchTableFetch, dispatchChartAdd, dispatchChartOptionsReplace}= llApi.action;
470+
const {dispatchTableFetch, dispatchChartAdd, dispatchChartRemove}= llApi.action;
471471
const {TBL_RESULTS_ACTIVE} = llApi.action.type;
472472
const {renderDOM} = llApi.util;
473473
const {makeFileRequest, getActiveTableId} = llApi.util.table;
@@ -502,13 +502,16 @@ function doShowHistogram(llApi, targetDiv, params={}) {
502502
const new_tblId = getActiveTableId(tblGroup);
503503
if (new_tblId !== tblId) {
504504
tblId = new_tblId;
505-
dispatchChartOptionsReplace({chartId,
506-
newOptions: {
507-
type: 'histogram', // DATATYPE_HISTOGRAM.id
505+
dispatchChartRemove(chartId);
506+
dispatchChartAdd({chartId, chartType: 'histogram', help_id, deletable: false,
507+
mounted: 1,
508+
chartDataElements: [
509+
{
510+
type: 'histogram', //DATATYPE_XYCOLS.id
508511
options: histogramParams,
509512
tblId
510513
}
511-
});
514+
]});
512515
}
513516
});
514517
}

src/firefly/js/charts/ChartDataTypes.js renamed to src/firefly/js/charts/ChartDataType.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44

5-
import {DATATYPE_XYCOLS} from './XYPlotCntlr.js';
6-
import {DATATYPE_HISTOGRAM} from './HistogramCntlr.js';
5+
import {DATATYPE_XYCOLS} from './ChartDataTypeXYCols.js';
6+
import {DATATYPE_HISTOGRAM} from './ChartDataTypeHistogram.js';
77
import {logError} from '../util/WebUtil.js';
88

99
/**

src/firefly/js/charts/HistogramCntlr.js renamed to src/firefly/js/charts/ChartDataTypeHistogram.js

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
4-
import {flux} from '../Firefly.js';
54

65
import {get} from 'lodash';
76

87
import {doFetchTable, getTblById, isFullyLoaded, makeTblRequest, cloneRequest} from '../tables/TableUtil.js';
9-
import {getChartDataElement, chartDataLoaded, dispatchChartAdd} from './ChartsCntlr.js';
8+
import {getChartDataElement, chartDataLoaded} from './ChartsCntlr.js';
109
import {logError} from '../util/WebUtil.js';
1110

1211
/**
13-
* Returns chart data type based
14-
* @returns {ChartDataType}
12+
* Chart data type for histogram data
13+
* @constant
14+
* @type {ChartDataType}
1515
*/
1616
export const DATATYPE_HISTOGRAM = {
1717
id: 'histogram',
@@ -20,31 +20,20 @@ export const DATATYPE_HISTOGRAM = {
2020
};
2121

2222
/*
23-
Possible structure of store:
24-
/histogram
23+
Possible structure of store with histogram data:
24+
/data
2525
chartId: Object - the name of this node matches chart id
2626
{
27-
// tblHistogramData
28-
tblId: string // table id
29-
tblSource: string // source of the table
30-
isColDataReady: boolean
31-
histogramData: [[numInBin: int, min: double, max: double]*]
32-
histogramParams: {
33-
columnOrExpr: column name or column expression
34-
algorithm: 'fixedSizeBins' or 'bayesianBlocks'
35-
numBins: int - for 'fixedSizeBins' algorithm
36-
x: [log,flip] x (domain) axis options
37-
y: [log,flip] y (counts) axis options
38-
falsePositiveRate: double - for 'bayesianBlocks' algorithm (default 0.05)
39-
minCutoff: double
40-
maxCutoff: double
41-
}
27+
chartDataElements: [
28+
tblId
29+
isDataReady
30+
data: [[numInBin: int, min: double, max: double]*]
31+
meta: {tblSource}
32+
options: HistogramParams
33+
]
4234
}
4335
*/
4436

45-
46-
47-
4837
/**
4938
* @global
5039
* @public
@@ -57,44 +46,6 @@ export const DATATYPE_HISTOGRAM = {
5746
* @prop {string} [y] comma separated list of y axis options: flip,log
5847
*/
5948

60-
/**
61-
* Load histogram data.
62-
*
63-
* @param {Object} params - dispatch parameters
64-
* @param {string} params.chartId - if no chart id is specified table id is used as chart id
65-
* @param {HistogramParams} params.histogramParams - histogram options (column name, etc.)
66-
* @param {boolean} [params.markAsDefault=false] - are the options considered to be "the default" to reset to
67-
* @param {string} params.tblId - table id
68-
* @param {Function} [params.dispatcher] - only for special dispatching uses such as remote
69-
* @public
70-
* @function dispatchLoadColData
71-
* @memberof firefly.action
72-
*/
73-
export function dispatchLoadColData({chartId, histogramParams, markAsDefault=false, tblId, dispatcher=flux.process}) {
74-
// HISTOGRAM
75-
dispatchChartAdd({chartId, chartType: 'histogram', groupId: tblId,
76-
chartDataElements: [
77-
{
78-
type: 'histogram', //DATA_TYPE_HISTOGRAM.id
79-
options: histogramParams,
80-
tblId
81-
}
82-
], dispatcher});
83-
}
84-
85-
/*
86-
* Get column histogram data
87-
* @param {string} chartId - chart id
88-
* @param {boolean} isColDataReady - flags that column histogram data are available
89-
* @param {number[][]} histogramData - an array of the number arrays with npoints, binmin, binmax
90-
* @param {Object} histogramParams - histogram options (column name, etc.)
91-
const dispatchUpdateColData = function(chartId, isColDataReady, histogramData, histogramParams) {
92-
flux.process({type: UPDATE_COL_DATA, payload: {chartId,isColDataReady,histogramData,histogramParams}});
93-
};
94-
*/
95-
96-
97-
9849
function serverParamsChanged(oldParams, newParams) {
9950
if (oldParams === newParams) { return false; }
10051
if (!oldParams || !newParams) { return true; }

src/firefly/js/charts/XYPlotCntlr.js renamed to src/firefly/js/charts/ChartDataTypeXYCols.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import {serializeDecimateInfo} from '../tables/Decimate.js';
1616

1717

1818
/**
19-
* Returns chart data type based
20-
* @returns {ChartDataType}
19+
* Chart data type for XY columns
20+
* @constant
21+
* @type {ChartDataType}
2122
*/
2223
export const DATATYPE_XYCOLS = {
2324
id: 'xycols',
@@ -27,28 +28,31 @@ export const DATATYPE_XYCOLS = {
2728
};
2829

2930
/*
30-
Possible structure of store:
31-
/xyplot
32-
chartId: Object - the name of this node matches chart id
33-
{
34-
// tblXYPlotData
35-
tblId: string // table id
36-
tblSource: string // source of the table
37-
isPlotDataReady: boolean
38-
decimatedUnzoomed: boolean // tells that unzoomed data are decimated
39-
xyPlotData: {
40-
rows: [[x: string, y: string, rowIdx: string]*] ,
41-
decimateKey: string,
42-
xMin: string,
43-
xMax: string,
44-
yMin: string,
45-
yMax: string,
46-
weightMin: string,
47-
weightMax: string,
48-
idStr: string
49-
}
50-
xyPlotParams: XYPlotParams
51-
}
31+
Possible structure of store with xy data:
32+
/data
33+
chartId: Object - the name of this node matches chart id
34+
{
35+
chartDataElements: [
36+
tblId
37+
isDataReady
38+
data: {
39+
rows: [[x: string, y: string, rowIdx: string]*] ,
40+
decimateKey: string,
41+
xMin: string,
42+
xMax: string,
43+
yMin: string,
44+
yMax: string,
45+
weightMin: string,
46+
weightMax: string,
47+
idStr: string
48+
}
49+
meta: {
50+
tblSource,
51+
decimatedUnzoomed: boolean // tells that unzoomed data are decimated
52+
}
53+
options: XYPlotParams
54+
]
55+
}
5256
*/
5357

5458
/**
@@ -128,16 +132,15 @@ export function getDefaultXYPlotOptions(tbl_id) {
128132
}
129133

130134
/**
131-
* Load xy plot data Load xy plot data.
135+
* Load xy plot data Load xy plot data - left for backward compatibility
132136
*
133137
* @param {Object} params - dispatch parameters
134138
* @param {string} params.chartId - if no chart id is specified table id is used as chart id
135139
* @param {XYPlotParams} params.xyPlotParams - XY plot options (column names, etc.)
136-
* @param {boolean} [params.markAsDefault=false] - are the options considered to be "the default" to reset to
137140
* @param {string} params.tblId - table id
138141
* @param {Function} [params.dispatcher=flux.process] - only for special dispatching uses such as remote
139142
*/
140-
export function dispatchLoadPlotData({chartId, xyPlotParams, markAsDefault=false, tblId, dispatcher=flux.process}) {
143+
export function loadXYPlot({chartId, xyPlotParams, tblId, dispatcher=flux.process}) {
141144
//SCATTER
142145
dispatchChartAdd({chartId, chartType: 'scatter', groupId: tblId,
143146
chartDataElements: [
@@ -167,9 +170,6 @@ export function setXYSelection(chartId, chartDataElementId, selection) {
167170
* @param {string} chartId - chart id
168171
* @param {string} chartDataElementId - chart data element id
169172
* @param {XYBoundaries} [selection]
170-
* @public
171-
* @function dispatchZoom
172-
* @memberof firefly.action
173173
*/
174174
export function setZoom(chartId, chartDataElementId, selection=undefined) {
175175
const chartDataElement = getChartDataElement(chartId, chartDataElementId);

src/firefly/js/charts/ChartUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export function makeXYPlotParams(params) {
137137
* @global
138138
* @public
139139
* @typedef {Object} HistogramOptions - shallow object with histogram parameters
140-
* @prop {string} [sourc w332e] location of the ipac table, url or file path; ignored when histogram view is added to table
140+
* @prop {string} [source] location of the ipac table, url or file path; ignored when histogram view is added to table
141141
* @prop {string} [tbl_id] table id of the table this plot is connected to
142142
* @prop {string} [chartTitle] title of the chart
143143
* @prop {string} col column or expression to use for histogram, can contain multiple column names ex. log(col) or (col1-col2)/col3

0 commit comments

Comments
 (0)