Skip to content

DM-6908 Add filter editor to the chart toolbar #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,51 +134,51 @@ else if (name.equalsIgnoreCase(PRESERVE_EMPTY_BIN) ){
*/
public DataGroup createHistogramTable(double[] columnData) throws DataAccessException {

DataType[] tblcolumns = columns;
DataGroup HistogramTable;

/*if (!scale.equalsIgnoreCase(LINEAR_SCALE)){
columnData = scaleData(columnData);
}*/

//calculate three arrays, numInBin, binMix and binMax
Object[] obj;
if (algorithm != null && algorithm.equalsIgnoreCase(FIXED_SIZE_ALGORITHM)) {
obj = calculateFixedBinSizeDataArray(columnData);
} else {
obj = calculateVariableBinSizeDataArray(columnData);

}

int[] numPointsInBin = (int[]) obj[0];
double[] binMin = (double[]) obj[1];
double[] binMax = (double[]) obj[2];
int nPoints = numPointsInBin.length;
if (columnData.length > 0) {
//calculate three arrays, numInBin, binMix and binMax
Object[] obj;
if (algorithm != null && algorithm.equalsIgnoreCase(FIXED_SIZE_ALGORITHM)) {
obj = calculateFixedBinSizeDataArray(columnData);
} else {
obj = calculateVariableBinSizeDataArray(columnData);

DataType[] tblcolumns = columns;
}

if (nPoints>1) {
double firstBinRange = binMax[0]-binMin[0];
int firstSigDigitPos = (int)Math.floor(Math.log10(Math.abs(firstBinRange)))+1;
if (firstSigDigitPos < -2) {
// increase precision
DataType.FormatInfo fi = DataType.FormatInfo.createFloatFormat(20, 3-firstSigDigitPos);
tblcolumns = new DataType[]{
int[] numPointsInBin = (int[]) obj[0];
double[] binMin = (double[]) obj[1];
double[] binMax = (double[]) obj[2];
int nPoints = numPointsInBin.length;

if (nPoints > 1) {
double firstBinRange = binMax[0] - binMin[0];
int firstSigDigitPos = (int) Math.floor(Math.log10(Math.abs(firstBinRange))) + 1;
if (firstSigDigitPos < -2) {
// increase precision
DataType.FormatInfo fi = DataType.FormatInfo.createFloatFormat(20, 3 - firstSigDigitPos);
tblcolumns = new DataType[]{
new DataType("numInBin", Integer.class),
new DataType("binMin", Double.class),
new DataType("binMax", Double.class)
};
tblcolumns[1].setFormatInfo(fi);
tblcolumns[2].setFormatInfo(fi);
};
tblcolumns[1].setFormatInfo(fi);
tblcolumns[2].setFormatInfo(fi);
}
}
}

//add each row to the DataGroup
DataGroup HistogramTable = new DataGroup("histogramTable", tblcolumns);
for (int i = 0; i < nPoints; i++) {
DataObject row = new DataObject(HistogramTable);
row.setDataElement(tblcolumns[0], numPointsInBin[i]);
row.setDataElement(tblcolumns[1], binMin[i]);
row.setDataElement(tblcolumns[2], binMax[i]);
HistogramTable.add(row);
//add each row to the DataGroup
HistogramTable = new DataGroup("histogramTable", tblcolumns);
for (int i = 0; i < nPoints; i++) {
DataObject row = new DataObject(HistogramTable);
row.setDataElement(tblcolumns[0], numPointsInBin[i]);
row.setDataElement(tblcolumns[1], binMin[i]);
row.setDataElement(tblcolumns[2], binMax[i]);
HistogramTable.add(row);
}
} else {
HistogramTable = new DataGroup("histogramTable", tblcolumns);
}
return HistogramTable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,12 @@ public static DataGroup doDecimation(DataGroup dg, DecimateInfo decimateInfo) {
}
}

retval.addAttribute(DecimateInfo.DECIMATE_TAG + ".X-MAX", String.valueOf(xMax));
retval.addAttribute(DecimateInfo.DECIMATE_TAG + ".X-MIN", String.valueOf(xMin));
retval.addAttribute(DecimateInfo.DECIMATE_TAG + ".Y-MAX", String.valueOf(yMax));
retval.addAttribute(DecimateInfo.DECIMATE_TAG + ".Y-MIN", String.valueOf(yMin));
if (Double.isFinite(xMax)) {
retval.addAttribute(DecimateInfo.DECIMATE_TAG + ".X-MAX", String.valueOf(xMax));
retval.addAttribute(DecimateInfo.DECIMATE_TAG + ".X-MIN", String.valueOf(xMin));
retval.addAttribute(DecimateInfo.DECIMATE_TAG + ".Y-MAX", String.valueOf(yMax));
retval.addAttribute(DecimateInfo.DECIMATE_TAG + ".Y-MIN", String.valueOf(yMin));
}

if (doDecimation) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -121,15 +120,17 @@ void start() throws IOException {
rowIdx = row.getRowIdx();
rowIdx = rowIdx < 0 ? cRowNum : rowIdx;
}

if (needToWriteHeader) {
needToWriteHeader = false;
DataGroupWriter.writeStatus(writer, DataGroupPart.State.INPROGRESS);
IpacTableUtil.writeAttributes(writer, attributes, DataGroupPart.LOADING_STATUS);
IpacTableUtil.writeHeader(writer, headers);
}

if (CollectionUtil.matches(rowIdx, row, filters)) {
row.setRowIdx(rowIdx);

if (needToWriteHeader) {
needToWriteHeader = false;
DataGroupWriter.writeStatus(writer, DataGroupPart.State.INPROGRESS);
IpacTableUtil.writeAttributes(writer, attributes, DataGroupPart.LOADING_STATUS);
IpacTableUtil.writeHeader(writer, headers);
}
IpacTableUtil.writeRow(writer, headers, row);
if (++rowsFound == prefetchSize) {
processInBackground(dg);
Expand Down
19 changes: 10 additions & 9 deletions src/firefly/js/charts/HistogramCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function fetchColData(dispatch, tblId, histogramParams, chartId) {

doFetchTable(req).then(
(tableModel) => {
let histogramData = [];
if (tableModel.tableData && tableModel.tableData.data) {
// if logarithmic values were requested, convert the returned exponents back
var toNumber = histogramParams.x.includes('log') ?
Expand All @@ -229,20 +230,20 @@ function fetchColData(dispatch, tblId, histogramParams, chartId) {
return Math.pow(10,Number(val));
}
} : (val)=>Number(val);
const histogramData = tableModel.tableData.data.reduce((data, arow) => {
histogramData = tableModel.tableData.data.reduce((data, arow) => {
data.push(arow.map(toNumber));
return data;
}, []);

dispatch(updateColData(
{
chartId,
isColDataReady : true,
tblSource,
histogramParams,
histogramData
}));
}
dispatch(updateColData(
{
chartId,
isColDataReady : true,
tblSource,
histogramParams,
histogramData
}));
}
).catch(
(reason) => {
Expand Down
29 changes: 16 additions & 13 deletions src/firefly/js/charts/XYPlotCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,17 @@ function fetchPlotData(dispatch, tblId, xyPlotParams, chartId) {
//'inclCols' : `${xyPlotParams.x.columnOrExpr},${xyPlotParams.y.columnOrExpr}`, // ignored if 'decimate' is present
'decimate' : serializeDecimateInfo(...getServerCallParameters(xyPlotParams))
});

req.tbl_id = `xy-${chartId}`;

doFetchTable(req).then(
(tableModel) => {
let xyPlotData = {rows: []};
// when zoomed, we don't know if the unzoomed data are decimated or not
let decimatedUnzoomed = xyPlotParams.zoom ? undefined : false;

if (tableModel.tableData && tableModel.tableData.data) {
const {tableMeta} = tableModel;
const xyPlotData = omitBy({
xyPlotData = omitBy({
rows: tableModel.tableData.data,
decimateKey: tableMeta['decimate_key'],
xMin: tableMeta['decimate.X-MIN'],
Expand All @@ -339,18 +342,18 @@ function fetchPlotData(dispatch, tblId, xyPlotParams, chartId) {
if (isString(val) && isFinite(val)) { xyPlotData[prop] = Number(val); }
});

dispatch(updatePlotData(
{
isPlotDataReady : true,
tblSource,
// when zoomed, we don't know if the unzoomed data are decimated or not
decimatedUnzoomed: Boolean(tableMeta['decimate_key']) || (xyPlotParams.zoom ? undefined : false),
xyPlotParams,
xyPlotData,
chartId,
newParams: getUpdatedParams(xyPlotParams, tableModel)
}));
decimatedUnzoomed = Boolean(tableMeta['decimate_key']) || decimatedUnzoomed;
}
dispatch(updatePlotData(
{
isPlotDataReady : true,
tblSource,
decimatedUnzoomed,
xyPlotParams,
xyPlotData,
chartId,
newParams: getUpdatedParams(xyPlotParams, tableModel)
}));
}
).catch(
(reason) => {
Expand Down
Loading