This PR adds some sensible defaults for scales used in BarRenderer.bar_value so that they can be omitted by the user. If min or max arguments of a DateScale, LinearScale or LogScale are omitted, they are determined from the data in the corresponding column. An example from some of the example notebooks is that the previous use of
The calculations occur in the DataGrid constructor on the Python side.
Also, bar_value now accepts None and will create either a DateScale or LinearScale depending on the data type of the corresponding column. bar_value already has a default of 0.0 and we cannot change this default without causing a backwards incompatibility, hence the use of None.
This new functionality is not supported in default_renderer, header_renderer, or corner_renderer as they are not attached to a particular data column.
Testing performed
Manual testing locally.
New python test test_bar_renderer_defaults added.
Playwright tests include notebook changes to demonstrate the new functionality in the frontend.
Possible future work
This work could be extended to cover other Renderer classes, and renderers that refer to multiple columns (e.g. default_renderer.
Describe your changes
This PR adds some sensible defaults for scales used in
BarRenderer.bar_value
so that they can be omitted by the user. Ifmin
ormax
arguments of aDateScale
,LinearScale
orLogScale
are omitted, they are determined from the data in the corresponding column. An example from some of the example notebooks is that the previous use ofcan be replaced by
The calculations occur in the
DataGrid
constructor on the Python side.Also,
bar_value
now acceptsNone
and will create either aDateScale
orLinearScale
depending on the data type of the corresponding column.bar_value
already has a default of0.0
and we cannot change this default without causing a backwards incompatibility, hence the use ofNone
.This new functionality is not supported in
default_renderer
,header_renderer
, orcorner_renderer
as they are not attached to a particular data column.Testing performed
test_bar_renderer_defaults
added.Possible future work
This work could be extended to cover other
Renderer
classes, and renderers that refer to multiple columns (e.g.default_renderer
.