spotify/chartify

Outside_bottom legend breaks with Bokeh 1.2

cphalpert opened this issue · 5 comments

Bokeh 1.2.0:

/usr/local/lib/python3.6/dist-packages/confidence/analysis/base.py in _summary_plot(self, level_name, level_df, remaining_groups, groupby)
    233 
    234             ch = self._ordinal_summary_plot(level_name, level_df,
--> 235                                             remaining_groups, groupby)
    236         else:
    237             ch = self._categorical_summary_plot(level_name, level_df,
/usr/local/lib/python3.6/dist-packages/confidence/analysis/base.py in _ordinal_summary_plot(self, level_name, level_df, remaining_groups, groupby)
    249         return self._ordinal_plot('point_estimate', df, groupby, level_name,
    250                                   remaining_groups, absolute=True,
--> 251                                   title=title, y_axis_label=y_axis_label)
    252 
    253     def _ordinal_plot(self, center_name, df, groupby, level_name,
/usr/local/lib/python3.6/dist-packages/confidence/analysis/base.py in _ordinal_plot(self, center_name, df, groupby, level_name, remaining_groups, absolute, title, y_axis_label)
    278         ch.set_title(title)
    279         if colors:
--> 280             ch.set_legend_location('outside_bottom')
    281         return ch
    282 
/usr/local/lib/python3.6/dist-packages/chartify/_core/chart.py in set_legend_location(self, location, orientation)
    332                 self._subtitle_glyph.text)
    333         elif location == 'outside_bottom':
--> 334             add_outside_legend('bottom_center', 'below')
    335         elif location == 'outside_right':
    336             add_outside_legend('top_left', 'right')
/usr/local/lib/python3.6/dist-packages/chartify/_core/chart.py in add_outside_legend(legend_location, layout_location)
    320                 return self
    321             new_legend = self.figure.legend[0]
--> 322             new_legend.plot = None
    323             new_legend.orientation = orientation
    324             self.figure.add_layout(new_legend, layout_location)
/usr/local/lib/python3.6/dist-packages/bokeh/core/has_props.py in __setattr__(self, name, value)
    286 
    287             raise AttributeError("unexpected attribute '%s' to %s, %s attributes are %s" %
--> 288                 (name, self.__class__.__name__, text, nice_join(matches)))
    289 
    290     def __str__(self):
AttributeError: unexpected attribute 'plot' to Legend, possible ```

I don't think Chartify should have ever been setting new_legend.plot = None in the first place, I would suggest just removing that line.

This change makes chartify incompatible with older versions of bokeh, e.g. 1.0.4. (didn't test extensively to find the exact version, though >=1.2 might suffice).

We should add a lower bound to the bokeh requirements

@cphalpert Does this mean adding the new_legend.plot = None back but with some condition based on version <=1.2?

I would personally advise against that, and suggest that as a downstream library you are free to be opinionated about what minimum versions you support. Just make sure to put a minimum Bokeh version in the next release and update as appropriate in future releases. You might also want to put an upper bound < next major version as well (Bokeh 2.0 is on the near horizon)

Added a proper bokeh minimum version in #98