@@ -268,46 +268,6 @@ def _append_view_filters(self, params) -> None:
268
268
params [name ] = value
269
269
270
270
271
- class _ImagePDFCommonExportOptions (_DataExportOptions ):
272
- def __init__ (self , maxage = - 1 , viz_height = None , viz_width = None ):
273
- super ().__init__ (maxage = maxage )
274
- self .viz_height = viz_height
275
- self .viz_width = viz_width
276
-
277
- @property
278
- def viz_height (self ):
279
- return self ._viz_height
280
-
281
- @viz_height .setter
282
- @property_is_int (range = (0 , sys .maxsize ), allowed = (None ,))
283
- def viz_height (self , value ):
284
- self ._viz_height = value
285
-
286
- @property
287
- def viz_width (self ):
288
- return self ._viz_width
289
-
290
- @viz_width .setter
291
- @property_is_int (range = (0 , sys .maxsize ), allowed = (None ,))
292
- def viz_width (self , value ):
293
- self ._viz_width = value
294
-
295
- def get_query_params (self ) -> dict :
296
- params = super ().get_query_params ()
297
-
298
- # XOR. Either both are None or both are not None.
299
- if (self .viz_height is None ) ^ (self .viz_width is None ):
300
- raise ValueError ("viz_height and viz_width must be specified together" )
301
-
302
- if self .viz_height is not None :
303
- params ["vizHeight" ] = self .viz_height
304
-
305
- if self .viz_width is not None :
306
- params ["vizWidth" ] = self .viz_width
307
-
308
- return params
309
-
310
-
311
271
class CSVRequestOptions (_DataExportOptions ):
312
272
"""
313
273
Options that can be used when exporting a view to CSV. Set the maxage to control the age of the data exported.
@@ -338,7 +298,7 @@ class ExcelRequestOptions(_DataExportOptions):
338
298
extension = "xlsx"
339
299
340
300
341
- class ImageRequestOptions (_ImagePDFCommonExportOptions ):
301
+ class ImageRequestOptions (_DataExportOptions ):
342
302
"""
343
303
Options that can be used when exporting a view to an image. Set the maxage to control the age of the data exported.
344
304
Filters to the underlying data can be applied using the `vf` and `parameter` methods.
@@ -354,13 +314,6 @@ class ImageRequestOptions(_ImagePDFCommonExportOptions):
354
314
maxage: int, optional
355
315
The maximum age of the data to export. Shortest possible duration is 1
356
316
minute. No upper limit. Default is -1, which means no limit.
357
-
358
- viz_height: int, optional
359
- The height of the viz in pixels. If specified, viz_width must also be specified.
360
-
361
- viz_width: int, optional
362
- The width of the viz in pixels. If specified, viz_height must also be specified.
363
-
364
317
"""
365
318
366
319
extension = "png"
@@ -369,8 +322,10 @@ class ImageRequestOptions(_ImagePDFCommonExportOptions):
369
322
class Resolution :
370
323
High = "high"
371
324
372
- def __init__ (self , imageresolution = None , maxage = - 1 , viz_height = None , viz_width = None ):
373
- super ().__init__ (maxage = maxage , viz_height = viz_height , viz_width = viz_width )
325
+ def __init__ (self , imageresolution = None , maxage = - 1 ):
326
+ super ().__init__ (
327
+ maxage = maxage ,
328
+ )
374
329
self .image_resolution = imageresolution
375
330
376
331
def get_query_params (self ):
@@ -380,7 +335,7 @@ def get_query_params(self):
380
335
return params
381
336
382
337
383
- class PDFRequestOptions (_ImagePDFCommonExportOptions ):
338
+ class PDFRequestOptions (_DataExportOptions ):
384
339
"""
385
340
Options that can be used when exporting a view to PDF. Set the maxage to control the age of the data exported.
386
341
Filters to the underlying data can be applied using the `vf` and `parameter` methods.
@@ -425,12 +380,45 @@ class Orientation:
425
380
Landscape = "landscape"
426
381
427
382
def __init__ (self , page_type = None , orientation = None , maxage = - 1 , viz_height = None , viz_width = None ):
428
- super ().__init__ (maxage = maxage , viz_height = viz_height , viz_width = viz_width )
383
+ super ().__init__ (
384
+ maxage = maxage ,
385
+ )
429
386
self .page_type = page_type
430
387
self .orientation = orientation
388
+ self .viz_height = viz_height
389
+ self .viz_width = viz_width
390
+
391
+ @property
392
+ def viz_height (self ):
393
+ return self ._viz_height
394
+
395
+ @viz_height .setter
396
+ @property_is_int (range = (0 , sys .maxsize ), allowed = (None ,))
397
+ def viz_height (self , value ):
398
+ self ._viz_height = value
399
+
400
+ @property
401
+ def viz_width (self ):
402
+ return self ._viz_width
403
+
404
+ @viz_width .setter
405
+ @property_is_int (range = (0 , sys .maxsize ), allowed = (None ,))
406
+ def viz_width (self , value ):
407
+ self ._viz_width = value
431
408
432
409
def get_query_params (self ) -> dict :
433
410
params = super ().get_query_params ()
411
+
412
+ # XOR. Either both are None or both are not None.
413
+ if (self .viz_height is None ) ^ (self .viz_width is None ):
414
+ raise ValueError ("viz_height and viz_width must be specified together" )
415
+
416
+ if self .viz_height is not None :
417
+ params ["vizHeight" ] = self .viz_height
418
+
419
+ if self .viz_width is not None :
420
+ params ["vizWidth" ] = self .viz_width
421
+
434
422
if self .page_type :
435
423
params ["type" ] = self .page_type
436
424
0 commit comments