@@ -219,20 +219,19 @@ function serverParamsChanged(oldParams, newParams, chartDataElement) {
219
219
} else {
220
220
// 'x', 'y', 'sortBy', 'xErr', 'xErrLow', 'xErrHigh', 'yErr', 'yErrLow', 'yErrHigh'
221
221
// server call parameters are present in the data
222
- const newOpts = omitBy ( {
223
- sortBy : newParams . sortColOrExpr ,
224
- x : newParams . x . columnOrExpr ,
225
- xErr : newParams . x . error ,
226
- xErrLow : newParams . x . errorLow ,
227
- xErrHigh : newParams . x . errorHigh ,
228
- y : newParams . y . columnOrExpr ,
229
- yErr : newParams . y . error ,
230
- yErrLow : newParams . y . errorLow ,
231
- yErrHigh : newParams . y . errorHigh
232
- } , isUndefined ) ;
233
- return Object . keys ( newOpts ) . some ( ( o ) => {
234
- return newOpts [ o ] !== data [ o ] ;
235
- } ) ;
222
+ const newOpts = getServerCallParameters ( newParams , false ) ;
223
+ if ( data ) {
224
+ // if data available, see if the new parameters are different from those used to obtain the data
225
+ return Object . keys ( newOpts ) . some ( ( o ) => {
226
+ return newOpts [ o ] !== data [ o ] ;
227
+ } ) ;
228
+ } else {
229
+ // if data are not available, compare with the old parameters
230
+ const oldOpts = getServerCallParameters ( oldParams , false ) ;
231
+ return Object . keys ( newOpts ) . some ( ( o ) => {
232
+ return newOpts [ o ] !== oldOpts [ o ] ;
233
+ } ) ;
234
+ }
236
235
}
237
236
}
238
237
@@ -249,22 +248,39 @@ function isLargeTable(tblId) {
249
248
// xyPlotParams.x.errorHigh || xyPlotParams.y.errorHigh);
250
249
//}
251
250
252
- function getServerCallParameters ( xyPlotParams ) {
253
- if ( ! xyPlotParams ) { return [ ] ; }
251
+ function getServerCallParameters ( xyPlotParams , isLargeTable = true ) {
252
+ if ( isLargeTable ) {
253
+ if ( ! xyPlotParams ) {
254
+ return [ ] ;
255
+ }
254
256
255
- if ( xyPlotParams . zoom ) {
256
- var { xMin, xMax, yMin, yMax} = xyPlotParams . zoom ;
257
- }
257
+ if ( xyPlotParams . zoom ) {
258
+ var { xMin, xMax, yMin, yMax} = xyPlotParams . zoom ;
259
+ }
258
260
259
- let maxBins = 10000 ;
260
- let xyRatio = xyPlotParams . xyRatio || 1.0 ;
261
- if ( xyPlotParams . nbins ) {
262
- const { x, y} = xyPlotParams . nbins ;
263
- maxBins = x * y ;
264
- xyRatio = x / y ;
261
+ let maxBins = 10000 ;
262
+ let xyRatio = xyPlotParams . xyRatio || 1.0 ;
263
+ if ( xyPlotParams . nbins ) {
264
+ const { x, y} = xyPlotParams . nbins ;
265
+ maxBins = x * y ;
266
+ xyRatio = x / y ;
267
+ }
268
+ // order should match the order of the parameters in serializeDecimateInfo
269
+ return [ xyPlotParams . x . columnOrExpr , xyPlotParams . y . columnOrExpr , maxBins , xyRatio , xMin , xMax , yMin , yMax ] ;
270
+ } else {
271
+ // smaller (not decimated) table
272
+ return omitBy ( {
273
+ sortBy : xyPlotParams . sortColOrExpr ,
274
+ x : xyPlotParams . x . columnOrExpr ,
275
+ xErr : xyPlotParams . x . error ,
276
+ xErrLow : xyPlotParams . x . errorLow ,
277
+ xErrHigh : xyPlotParams . x . errorHigh ,
278
+ y : xyPlotParams . y . columnOrExpr ,
279
+ yErr : xyPlotParams . y . error ,
280
+ yErrLow : xyPlotParams . y . errorLow ,
281
+ yErrHigh : xyPlotParams . y . errorHigh
282
+ } , isUndefined ) ;
265
283
}
266
- // order should match the order of the parameters in serializeDecimateInfo
267
- return [ xyPlotParams . x . columnOrExpr , xyPlotParams . y . columnOrExpr , maxBins , xyRatio , xMin , xMax , yMin , yMax ] ;
268
284
}
269
285
270
286
export function getDataBoundaries ( xyPlotData ) {
@@ -574,12 +590,20 @@ function fetchXYWithErrorsOrSort(dispatch, chartId, chartDataElementId) {
574
590
function dispatchError ( dispatch , chartId , chartDataElementId , reason ) {
575
591
const message = 'Failed to fetch XY plot data' ;
576
592
logError ( `${ message } : ${ reason } ` ) ;
593
+ let reasonStr = `${ reason } ` . toLowerCase ( ) ;
594
+ if ( reasonStr . match ( / n o t s u p p o r t e d / ) ) {
595
+ reasonStr = 'Unsupported feature requested. Please choose valid options.' ;
596
+ } else if ( reasonStr . match ( / i n v a l i d c o l u m n / ) ) {
597
+ reasonStr = 'Invalid column or expression. Please choose valid X and Y.' ;
598
+ } else {
599
+ reasonStr = 'Please check console for more information.' ;
600
+ }
577
601
dispatch ( chartDataUpdate (
578
602
{
579
603
chartId,
580
604
chartDataElementId,
581
605
isDataReady : true ,
582
- error : { message, reason} ,
606
+ error : { message, reason : reasonStr } ,
583
607
data : undefined
584
608
} ) ) ;
585
609
}
0 commit comments