Why does CategoricalScale extend LinearScale?

Just tried using an inspection tap tool on a bar chart to fire a custom callback with the data. Was a bit surprised that instead of a nice categorical value I got a number that ranges from 0 to the number of bars.
Is there any practical reason for this? Would it make sense for CategoricalScale to not be a subtype of LinearScale, just like with the axis types?

This is because the categorical coordinate system allows for offsets and is effectively a composite coordinate system, a discrete coordinate system with linear coordinates defined for each factor. This is implemented this way due to bokeh’s design limitations, in particular lack of support for composite coordinate systems. This will be fixed in PR #8931.

1 Like