@@ -173,8 +173,6 @@ def _empty_agg(self, element, x, y, width, height, xs, ys, agg_fn, **params):
173
173
params ['xdensity' ] = 1
174
174
if height == 0 :
175
175
params ['ydensity' ] = 1
176
- if isinstance (agg_fn , ds .by ):
177
- return ImageStack (xarray , ** params )
178
176
return self .p .element_type (xarray , ** params )
179
177
180
178
def _get_agg_params (self , element , x , y , agg_fn , bounds ):
@@ -385,6 +383,9 @@ def _process(self, element, key=None):
385
383
sel_fn = type (sel_fn )(column = rd .SpecialColumn .RowIndex )
386
384
agg_state = AggState .get_state (agg_fn , sel_fn )
387
385
386
+ if AggState .has_by (agg_state ) and self .p .element_type is Image :
387
+ self .p .element_type = ImageStack
388
+
388
389
if overlay_aggregate .applies (element , agg_fn , line_width = self .p .line_width , sel_fn = sel_fn ):
389
390
params = dict (
390
391
{p : v for p , v in self .param .values ().items () if p != 'name' },
@@ -410,8 +411,6 @@ def _process(self, element, key=None):
410
411
empty_val = 0 if isinstance (agg_fn , ds .count ) else np .nan
411
412
xarray = xr .DataArray (np .full ((height , width ), empty_val ),
412
413
dims = [y .name , x .name ], coords = {x .name : xs , y .name : ys })
413
- if AggState .has_by (agg_state ):
414
- return ImageStack (xarray , ** params )
415
414
return self .p .element_type (xarray , ** params )
416
415
417
416
cvs = ds .Canvas (plot_width = width , plot_height = height ,
@@ -444,14 +443,11 @@ def _process(self, element, key=None):
444
443
if ytype == 'datetime' :
445
444
agg [y .name ] = agg [y .name ].astype ('datetime64[ns]' )
446
445
447
- if not AggState .has_by (agg_state ):
448
- return self .p .element_type (agg , ** params )
449
- elif agg_state == AggState .AGG_BY :
446
+ if agg_state == AggState .AGG_BY :
450
447
params ['vdims' ] = list (map (str , agg .coords [agg_fn .column ].data ))
451
- return ImageStack (agg , ** params )
452
448
elif agg_state == AggState .AGG_SEL_BY :
453
449
params ['vdims' ] = [d for d in agg .data_vars if d not in agg .attrs ["selector_columns" ]]
454
- return ImageStack (agg , ** params )
450
+ return self . p . element_type (agg , ** params )
455
451
456
452
def _apply_datashader (self , dfdata , cvs_fn , agg_fn , agg_kwargs , x , y , agg_state : AggState ):
457
453
# Suppress numpy warning emitted by dask:
0 commit comments