Skip to content

DM-9343:scatter and line chart zoom changed when changing between "points" and "connected points" #321

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 3 commits into from
Mar 1, 2017
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
31 changes: 24 additions & 7 deletions src/firefly/js/charts/ui/XYPlot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,25 @@ const getZoomSelection = function(params) {
return (params.zoom ? params.zoom : {xMin:null, xMax: null, yMin:null, yMax:null});
};


const selFinite = (v1, v2) => {return Number.isFinite(v1) ? v1 : v2;};

const selFiniteMin = (v1, v2) => {
if (Number.isFinite(v1) && Number.isFinite(v2)) {
return Math.min(v1, v2);
} else {
return selFinite(v1,v2);
}
};

const selFiniteMax = (v1, v2) => {
if (Number.isFinite(v1) && Number.isFinite(v2)) {
return Math.max(v1, v2);
} else {
return selFinite(v1,v2);
}
};

/*
A symbol to represent decimated series. The size of the rectangle depends of the decimation unit
@param x lower left corner of the rectangle: ptX-options.radius
Expand Down Expand Up @@ -373,8 +390,8 @@ export class XYPlot extends React.Component {
if (!shallowequal(params.zoom, newParams.zoom) || !shallowequal(params.boundaries, newParams.boundaries)) {
const {xMin, xMax, yMin, yMax} = getZoomSelection(newParams);
const {xMin:xDataMin, xMax:xDataMax, yMin:yDataMin, yMax:yDataMax} = get(newParams, 'boundaries', {});
Object.assign(xoptions, {min: selFinite(xMin, xDataMin), max: selFinite(xMax, xDataMax)});
Object.assign(yoptions, {min: selFinite(yMin, yDataMin), max: selFinite(yMax, yDataMax)});
Object.assign(xoptions, {min: selFiniteMax(xMin, xDataMin), max: selFiniteMin(xMax, xDataMax)});
Object.assign(yoptions, {min: selFiniteMax(yMin, yDataMin), max: selFiniteMin(yMax, yDataMax)});
chart.get(MINMAX).setData([[xoptions.min, yoptions.min], [xoptions.max, yoptions.max]], false, false, false);
}
const xUpdate = Reflect.ownKeys(xoptions).length > 0;
Expand Down Expand Up @@ -793,8 +810,8 @@ export class XYPlot extends React.Component {
useHTML: Boolean((decimateKey))
},
xAxis: {
min: selFinite(xMin, xDataMin),
max: selFinite(xMax, xDataMax),
min: selFiniteMax(xMin, xDataMin),
max: selFiniteMin(xMax, xDataMax),
gridLineColor: '#e9e9e9',
gridLineWidth: xGrid ? 1 : 0,
lineColor: '#999',
Expand All @@ -805,8 +822,8 @@ export class XYPlot extends React.Component {
type: xLog ? 'logarithmic' : 'linear'
},
yAxis: {
min: selFinite(yMin,yDataMin),
max: selFinite(yMax,yDataMax),
min: selFiniteMax(yMin,yDataMin),
max: selFiniteMin(yMax,yDataMax),
gridLineColor: '#e9e9e9',
gridLineWidth: yGrid ? 1 : 0,
tickWidth: 1,
Expand All @@ -829,7 +846,7 @@ export class XYPlot extends React.Component {
name: MINMAX,
color: 'rgba(240, 240, 240, 0.1)',
marker: {radius: 1},
data: decimateKey? [[selFinite(xMin, xDataMin), selFinite(yMin,yDataMin)], [selFinite(xMax, xDataMax), selFinite(yMax,yDataMax)]]:[],
data: decimateKey? [[selFiniteMax(xMin, xDataMin), selFiniteMax(yMin,yDataMin)], [selFiniteMin(xMax, xDataMax), selFiniteMin(yMax,yDataMax)]]:[],
showInLegend: false,
enableMouseTracking: false,
states: {
Expand Down
14 changes: 11 additions & 3 deletions src/firefly/js/charts/ui/XYPlotOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ function getUnit(colValStats, colname) {
}
*/

export function resultsSuccess(callback, flds, tblId) {
export function resultsSuccess(callback, flds, optionParameters) {
const tblId = optionParameters.tblId;

const xName = get(flds, ['x.columnOrExpr']);
const yName = get(flds, ['y.columnOrExpr']);

const zoom = (xName!==optionParameters.x.columnOrExpr || yName!==optionParameters.y.columnOrExpr)? undefined:optionParameters.zoom;
const xErr = get(flds, ['x.error']);
const yErr = get(flds, ['y.error']);

Expand All @@ -78,6 +82,7 @@ export function resultsSuccess(callback, flds, tblId) {
userSetBoundaries = isEmpty(userSetBoundaries) ? undefined : userSetBoundaries;
const xyRatio = parseFloat(flds.xyRatio);


/*
const axisParamsShape = PropTypes.shape({
columnOrExpr : PropTypes.string,
Expand Down Expand Up @@ -107,7 +112,8 @@ export function resultsSuccess(callback, flds, tblId) {
shading: flds.shading || undefined,
x : { columnOrExpr : xName, error: xErr, label : xLabel, unit : xUnit, options : xOptions},
y : { columnOrExpr : yName, error: yErr, label : yLabel, unit : yUnit, options : yOptions},
tblId
tblId,
zoom,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, do not preserve zoom if X or Y column changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. When the columns change, the zoom should not be preserved. Thanks for pointing it out. I did not realize it.

}, isUndefined);

if (xErr || yErr) {
Expand Down Expand Up @@ -453,6 +459,7 @@ export class XYPlotOptions extends React.Component {
}

render() {

const { colValStats, groupKey, xyPlotParams, defaultParams, onOptionsSelected}= this.props;

const largeTable = possibleDecimatedTable(colValStats);
Expand All @@ -461,6 +468,7 @@ export class XYPlotOptions extends React.Component {
const yProps = {colValStats,params:xyPlotParams,groupKey,fldPath:'y.columnOrExpr',label:'Y',tooltip:'Y Axis',nullAllowed:false};
const xErrProps = {colValStats,params:xyPlotParams,groupKey,fldPath:'x.error',label:'X Err',tooltip:'X Error',nullAllowed:true};
const yErrProps = {colValStats,params:xyPlotParams,groupKey,fldPath:'y.error',label:'Y Err',tooltip:'Y Error',nullAllowed:true};

return (
<div style={{padding:'0 5px 7px'}}>
<FieldGroup groupKey={groupKey} validatorFunc={null} keepState={true}
Expand All @@ -469,7 +477,7 @@ export class XYPlotOptions extends React.Component {
<div style={{display: 'flex', flexDirection: 'row', padding: '5px 0 15px'}}>
<CompleteButton style={{flexGrow: 0}}
groupKey={groupKey}
onSuccess={(flds) => resultsSuccess(onOptionsSelected, flds, xyPlotParams.tblId)}
onSuccess={(flds) => resultsSuccess(onOptionsSelected, flds, xyPlotParams)}
onFail={resultsFail}
text = 'Apply'
/>
Expand Down