Here are the examples of the python api bokeh.core.properties.field taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
Source : test_annotations.py
with MIT License
from rthorst
with MIT License
from rthorst
def test_legend_item_with_field_label_and_different_data_sources_raises_a_validation_error():
legend_item = LegendItem()
gr_1 = GlyphRenderer(data_source=ColumnDataSource(data={'label': [1]}))
gr_2 = GlyphRenderer(data_source=ColumnDataSource(data={'label': [1]}))
legend_item.label = field('label')
legend_item.renderers = [gr_1, gr_2]
with mock.patch('bokeh.core.validation.check.log') as mock_logger:
check_integrity([legend_item])
assert mock_logger.error.call_count == 1
def test_legend_item_with_value_label_and_different_data_sources_does_not_raise_a_validation_error():
0
Source : test_annotations.py
with MIT License
from rthorst
with MIT License
from rthorst
def test_legend_item_with_field_label_raises_error_if_field_not_in_cds():
legend_item = LegendItem()
gr_1 = GlyphRenderer(data_source=ColumnDataSource())
legend_item.label = field('label')
legend_item.renderers = [gr_1]
with mock.patch('bokeh.core.validation.check.log') as mock_logger:
check_integrity([legend_item])
assert mock_logger.error.call_count == 1
#-----------------------------------------------------------------------------
# Dev API
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Private API
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
0
Source : plot.py
with Apache License 2.0
from spotify
with Apache License 2.0
from spotify
def bar(self,
data_frame,
categorical_columns,
numeric_column,
color_column=None,
color_order=None,
categorical_order_by='values',
categorical_order_ascending=False):
"""Bar chart.
Note:
To change the orientation set x_axis_type or y_axis_type
argument of the Chart object.
Args:
data_frame (pandas.DataFrame): Data source for the plot.
categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis.
color_column (str, optional): Column name to group by on
the color dimension.
color_order (list, optional): List of values within the
'color_column' for specific color sort.
categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default 'values'.
- 'values': Order categorical axis by the numerical
axis values. Default.
- 'labels': Order categorical axis by the categorical labels.
- array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
categorical_order_ascending (bool, optional): Sort order of the
categorical axis. Default False.
"""
vertical = self._chart.axes._vertical
source, factors, _ = self._construct_source(
data_frame,
categorical_columns,
numeric_column,
categorical_order_by=categorical_order_by,
categorical_order_ascending=categorical_order_ascending,
color_column=color_column)
colors, color_values = self._get_color_and_order(
data_frame, color_column, color_order, categorical_columns)
if color_column is None:
colors = colors[0]
self._set_categorical_axis_default_factors(vertical, factors)
self._set_categorical_axis_default_range(vertical, data_frame,
numeric_column)
bar_width = self._get_bar_width(factors)
if color_column:
legend = bokeh.core.properties.field('color_column')
legend = 'color_column'
else:
legend = None
if vertical:
self._plot_with_legend(
self._chart.figure.vbar,
legend_group=legend,
x='factors',
width=bar_width,
top=numeric_column,
bottom=0,
line_color='white',
source=source,
fill_color=colors,
)
else:
self._plot_with_legend(
self._chart.figure.hbar,
legend_group=legend,
y='factors',
height=bar_width,
right=numeric_column,
left=0,
line_color='white',
source=source,
fill_color=colors,
)
# Set legend defaults if there are multiple series.
if color_column is not None:
self._chart.style._apply_settings('legend')
return self._chart
def interval(self,