[BUG] Impossible to change FactorRange to a lower dimension with different number of factors
See original GitHub issueInitially reported at https://discourse.bokeh.org/t/y-ticks-y-range-error-while-changing-from-2-dimensional-x-range-factors-to-1-dimensional/5106
ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)
Bokeh 2.0.1
Description of expected behavior and the observed behavior
It should be possible to switch between factors
of a FactorRange
without any issues.
Complete, minimal, self-contained example code that reproduces the issue
from bokeh.io import show
from bokeh.layouts import column
from bokeh.models import Button, CustomJS, ColumnDataSource, FactorRange
from bokeh.plotting import figure
fig = figure(x_range=FactorRange(factors=[('a', 'b'), ('b', 'c')]))
ds = ColumnDataSource(data=dict(x=[['a', 'b'], ['b', 'c']], y=[1, 2]))
fig.vbar(x='x', top='y', source=ds)
b = Button(label="Switch to single level")
b.js_on_click(CustomJS(args=dict(fig=fig, ds=ds),
code="""\
fig.x_range.factors = ['a'];
ds.data = {x: ['a'], y: [1]};
ds.change.emit();
"""))
show(column(b, fig))
At least one of the causes is that FactorRange.tops
is not updated if we switch to 1D factors from 2D or 3D factors: https://github.com/bokeh/bokeh/blob/cd74b12ed245c3d53c8bf21420de0f14979aebd0/bokehjs/src/lib/models/ranges/factor_range.ts#L240
There seems to be at least one other issue because the error that you see may depend on the order of the instructions within the CustomJS.code
above. Seems like a race condition.
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (12 by maintainers)
Top Results From Across the Web
ranges — Bokeh 2.4.0 Documentation
Models for describing different kinds of ranges of values in different kinds of spaces (e.g., continuous or categorical) and with options for “auto...
Read more >Dimensional Factor - an overview | ScienceDirect Topics
The dimensional stability of materials depends on several factors such as density and ... Using Eq. (4.14) it is possible to modify the...
Read more >Comparison of dimension reduction techniques in the analysis ...
Online analysis with mass spectrometers produces complex data sets, consisting of mass spectra with a large number of chemical compounds ...
Read more >11 Dimensionality reduction techniques you should know in ...
Dimensionality reduction is very useful for factor analysis — This is a useful ... Both methods reduce the number of dimensions but in...
Read more >Using Horn's Parallel Analysis Method in Exploratory Factor ...
In this study, the number of factors obtained from parallel analysis, ... The exploratory aim of factor analysis defines lower dimensions of measuring....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In bokeh this:
and in bokehjs:
are equivalent to:
when it comes to client-server updates (signals/events are a separate concern). If you look at the implementation, you will see a simple for loop distributing over changed properties in both cases. Those for loops need to be folded to allow pushing multiple changes in one protocol-level change event.
Additionally it would be nice to allow to synchronize a block of code like this:
so that one isn’t forced to use
setv()
orupdate()
. I already implemented this locally and it will be part of bokeh 3.0. In bokehjs one will write:and in bokeh there will be a context manager (as a substitute for multiline lambdas).
Yes, I mean that we should take existing APIs and improve them. Especially since
Document
is the correct place for these kind of synchronizations, notPlot
(there may not be a plot at all, or changes that span multiple Plots). AFAICT there is an obvious place forunhold
to generate a single protocol message instead of looping at the end.