@@ -685,6 +685,11 @@ SIREPO.app.factory('plotting', function(appState, frameCache, panelState, utilit
685685 return json . aspectRatio || defaultRatio || 1.0 ;
686686 } ,
687687
688+ hasFocusPoint : function ( plot ) {
689+ // a "band" plot has no single focus value
690+ return ! plot || plot . style !== 'band' ;
691+ } ,
692+
688693 initialHeight : function ( scope ) {
689694 return scope . isAnimation ? 1 : INITIAL_HEIGHT ;
690695 } ,
@@ -1167,6 +1172,7 @@ SIREPO.app.service('plot2dService', function(appState, layoutService, panelState
11671172 $ . extend ( $scope , attrs ) ;
11681173 $scope . width = $scope . height = 0 ;
11691174 $scope . dataCleared = true ;
1175+ $scope . hasFocusPoint = plotting . hasFocusPoint ;
11701176 $scope . axes = {
11711177 x : layoutService . plotAxis ( $scope . margin , 'x' , 'bottom' , refresh ) ,
11721178 y : layoutService . plotAxis ( $scope . margin , 'y' , 'left' , refresh ) ,
@@ -2000,6 +2006,9 @@ SIREPO.app.directive('interactiveOverlay', function(focusPointService, keypressS
20002006 if ( fpIndex === 0 ) {
20012007 fmtText = fmtText + fpt . xText + '\n' ;
20022008 }
2009+ if ( ! plotting . hasFocusPoint ( plotScope . plots && plotScope . plots [ fpIndex ] ) ) {
2010+ return ;
2011+ }
20032012 fmtText = fmtText + fpt . yText ;
20042013 if ( fpt . fwhmText ) {
20052014 fmtText = fmtText + ', ' + fpt . fwhmText ;
@@ -2259,11 +2268,12 @@ SIREPO.app.directive('popupReport', function(focusPointService, plotting) {
22592268 <div style="padding: 4px; white-space: nowrap">
22602269 <div style="height: 20px"><span data-text-with-math="focusPoints[0].config.xAxis.label"
22612270 data-is-dynamic="1"></span> = {{ pointText(0, true) }} {{ focusPoints[0].config.xAxis.units }}</div>
2262- <div data-ng-style="{ opacity: opacity($index) }" style="height: 20px"
2263- data-ng-repeat="p in plots track by p._label + $index">
2264- <div style="display:inline" data-color-circle="p"></div>
2265- <span data-text-with-math="p._label"></span> = {{ pointText($index) }}
2266- <span data-text-with-math="p._units"></span>
2271+ <div data-ng-repeat="p in plots track by p._label + $index">
2272+ <div data-ng-if="hasFocusPoint(p)" data-ng-style="{ opacity: opacity($index) }" style="height: 20px">
2273+ <div style="display:inline" data-color-circle="p"></div>
2274+ <span data-text-with-math="p._label"></span> = {{ pointText($index) }}
2275+ <span data-text-with-math="p._units"></span>
2276+ </div>
22672277 </div>
22682278 </div>
22692279 </div>
@@ -2274,6 +2284,7 @@ SIREPO.app.directive('popupReport', function(focusPointService, plotting) {
22742284
22752285 // prevent memory leak?
22762286 $scope . focusPoints . allowClone = true ;
2287+ $scope . hasFocusPoint = plotting . hasFocusPoint ;
22772288
22782289 function adjustBounds ( bound , dim ) {
22792290 if ( bound < 1 ) {
@@ -3720,10 +3731,22 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
37203731 function setupPlots ( json ) {
37213732 const viewport = $scope . select ( '.plot-viewport' ) ;
37223733 viewport . selectAll ( '.line' ) . remove ( ) ;
3734+ viewport . selectAll ( '.band' ) . remove ( ) ;
37233735 viewport . selectAll ( 'g.param-plot' ) . remove ( ) ;
37243736 json . plots . forEach ( function ( plot , ip ) {
37253737 plot . strokeWidth = plot . strokeWidth || 2.0 ;
3726- if ( plot . style === 'scatter' ) {
3738+ if ( plot . style === 'band' ) {
3739+ // a shaded region between plot.pointsLower and plot.pointsUpper,
3740+ // e.g. a confidence/uncertainty interval
3741+ viewport . append ( 'path' )
3742+ . attr ( 'class' , 'param-plot band' )
3743+ . attr ( 'data-sr-index' , ip )
3744+ . style ( 'fill' , plot . color )
3745+ . style ( 'stroke' , 'none' )
3746+ . style ( 'opacity' , plot . opacity || 0.25 )
3747+ . datum ( plot . pointsUpper ) ;
3748+ }
3749+ else if ( plot . style === 'scatter' ) {
37273750 let clusterInfo ;
37283751 let circleRadius = plot . circleRadius || 2 ;
37293752 if ( json . clusters ) {
@@ -3896,6 +3919,24 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
38963919 return yaxis . scale ( scaleFunction ? scaleFunction ( d ) : d ) ;
38973920 } ) ;
38983921 } ;
3922+ // area generator for a "band" plot, filling between pointsLower and pointsUpper
3923+ $scope . plotGraphArea = function ( plotIndex ) {
3924+ const p = ( $scope . plots || [ ] ) [ plotIndex ] || { } ;
3925+ const xPoints = p . x_points || $scope . axes . x . points ;
3926+ const yaxis = p . _yaxis == 'right' ? $scope . axes . y2 : $scope . axes . y ;
3927+ return d3 . svg . area ( )
3928+ . x ( function ( d , i ) {
3929+ return $scope . axes . x . scale ( xPoints [ i ] ) ;
3930+ } )
3931+ . y0 ( function ( d , i ) {
3932+ const v = p . pointsLower [ i ] ;
3933+ return yaxis . scale ( scaleFunction ? scaleFunction ( v ) : v ) ;
3934+ } )
3935+ . y1 ( function ( d , i ) {
3936+ const v = p . pointsUpper [ i ] ;
3937+ return yaxis . scale ( scaleFunction ? scaleFunction ( v ) : v ) ;
3938+ } ) ;
3939+ } ;
38993940 $scope . graphLine = d3 . svg . line ( )
39003941 . x ( function ( d , i ) {
39013942 return $scope . axes . x . scale ( $scope . axes . x . points [ i ] ) ;
@@ -3951,19 +3992,22 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
39513992 continue ;
39523993 }
39533994 for ( const p of plots ) {
3954- const y = p . points [ i ] ;
3995+ // a "band" plot has no single points[i] value -- use both edges
3996+ const ys = p . style === 'band' ? [ p . pointsLower [ i ] , p . pointsUpper [ i ] ] : [ p . points [ i ] ] ;
39553997 const ia = p . _yaxis == 'left' ? 0 : 1 ;
3956- if ( ydom [ ia ] ) {
3957- if ( y < ydom [ ia ] [ 0 ] ) {
3958- ydom [ ia ] [ 0 ] = y ;
3998+ for ( const y of ys ) {
3999+ if ( ydom [ ia ] ) {
4000+ if ( y < ydom [ ia ] [ 0 ] ) {
4001+ ydom [ ia ] [ 0 ] = y ;
4002+ }
4003+ else if ( y > ydom [ ia ] [ 1 ] ) {
4004+ ydom [ ia ] [ 1 ] = y ;
4005+ }
39594006 }
3960- else if ( y > ydom [ ia ] [ 1 ] ) {
3961- ydom [ ia ] [ 1 ] = y ;
4007+ else {
4008+ ydom [ ia ] = [ y , y ] ;
39624009 }
39634010 }
3964- else {
3965- ydom [ ia ] = [ y , y ] ;
3966- }
39674011 }
39684012 }
39694013 [ 'left' , 'right' ] . forEach ( ( v , i ) => {
@@ -4003,6 +4047,12 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
40034047 d3 . select ( this ) . attr ( 'd' , $scope . plotGraphLine ( ip ) ) ;
40044048 } ) ;
40054049
4050+ $scope . select ( '.plot-viewport' ) . selectAll ( '.band' )
4051+ . each ( function ( d ) {
4052+ var ip = parseInt ( d3 . select ( this ) . attr ( 'data-sr-index' ) ) ;
4053+ d3 . select ( this ) . attr ( 'd' , $scope . plotGraphArea ( ip ) ) ;
4054+ } ) ;
4055+
40064056 $scope . select ( '.plot-viewport' ) . selectAll ( 'g.param-plot' )
40074057 . each ( function ( d , ip ) {
40084058 var sp = d3 . select ( this ) . selectAll ( '.scatter-point' ) ;
0 commit comments