@@ -85,6 +85,22 @@ public class VisPresenter extends AbstractComponentPresenter<VisPresenter.VisVie
85
85
public static final ComponentType TYPE = new ComponentType (4 , "vis" , "Visualisation" , ComponentUse .PANEL );
86
86
private static final long UPDATE_INTERVAL = 2000 ;
87
87
88
+
89
+ private static final JavaScriptObject EMPTY_DATA ;
90
+
91
+ static {
92
+ final JSONObject dataObject = JSONUtil .getObject (JSONUtil .parse (
93
+ "{" +
94
+ "\" values\" : []," +
95
+ "\" min\" : []," +
96
+ "\" max\" : []," +
97
+ "\" sum\" : []," +
98
+ "\" types\" : []," +
99
+ "\" sortDirections\" : []" +
100
+ "}" ));
101
+ EMPTY_DATA = dataObject .getJavaScriptObject ();
102
+ }
103
+
88
104
private final VisFunctionCache visFunctionCache ;
89
105
private final ScriptCache scriptCache ;
90
106
private final RestFactory restFactory ;
@@ -292,7 +308,7 @@ public void reset() {
292
308
public void startSearch () {
293
309
nextUpdate = 0 ;
294
310
currentSettings = null ;
295
- currentData = null ;
311
+ currentData = EMPTY_DATA ;
296
312
lastData = null ;
297
313
298
314
if (!searching ) {
@@ -406,7 +422,7 @@ private void setDataInternal(final Result componentResult) {
406
422
}
407
423
408
424
private JavaScriptObject getJSONData (final VisResult visResult ) {
409
- JavaScriptObject data = null ;
425
+ JavaScriptObject data = EMPTY_DATA ;
410
426
411
427
// Turn JSON result text into an object.
412
428
final JSONObject dataObject = JSONUtil .getObject (JSONUtil .parse (visResult .getJsonData ()));
@@ -509,19 +525,19 @@ public void onChange(final VisFunction function) {
509
525
visFrame .setVisType (function .getFunctionName (), getClassName (currentPreferences .getTheme ()));
510
526
}
511
527
512
- if (currentData != null ) {
513
- update ();
514
- currentError = null ;
515
- }
528
+ currentError = null ;
529
+ update ();
516
530
517
531
} catch (final RuntimeException e ) {
518
532
currentError = e .getMessage ();
519
533
}
520
534
} else if (LoadStatus .FAILURE .equals (function .getStatus ())) {
521
535
// Try and clear the current visualisation.
522
536
try {
523
- // getView().clear() ;
537
+ currentData = EMPTY_DATA ;
524
538
currentError = null ;
539
+
540
+ update ();
525
541
} catch (final RuntimeException e ) {
526
542
// Ignore.
527
543
}
@@ -574,13 +590,6 @@ private void updateStatusMessage() {
574
590
case LOADED :
575
591
if (currentError != null ) {
576
592
getView ().showMessage (currentError );
577
- } else if (currentData == null ) {
578
- if (searching ) {
579
- getView ().hideMessage ();
580
- //getView().showMessage("Waiting for data...");
581
- } else {
582
- getView ().showMessage ("No data" );
583
- }
584
593
} else {
585
594
getView ().hideMessage ();
586
595
}
0 commit comments