B
    Y              	   @   s   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ dd	lmZ dd
lmZ ddlmZmZ dddZG dd deZdS )a&  This is the Bokeh charts interface. It gives you a high level API to build
complex plot is a simple way.

This is the BoxPlot class which lets you build your BoxPlot plots just passing
the arguments to the Chart class and calling the proper functions.
It also add a new chained stacked method.
    )absolute_import)BoolString)Range1d   )create_and_build   )
BarBuilder)BoxGlyph)title_from_columns)	ColorAttrCatAttrNcategoricallinearFTc
             K   sp   |	rt |	tstd|	}||
d< ||
d< ||
d< ||
d< ||
d< ||
d< ||
d< ||
d	< ||
d
< tt| f|
S )ad	  Create a BoxPlot chart containing one or more boxes from table-like data.

    Create a boxplot chart using :class:`BoxPlotBuilder
    <bkcharts.builders.boxplot_builder.BoxPlotBuilder>` to render the
    glyphs from input data and specification. This primary use case for the
    boxplot is to depict the distribution of a variable by providing summary
    statistics for it. This boxplot is particularly useful at comparing
    distributions between categorical variables.

    This chart implements functionality for segmenting and comparing the values
    of a variable by an associated categorical variable.

    Reference: `BoxPlot on Wikipedia <https://en.wikipedia.org/wiki/Box_plot>`_

    Args:
        data (:ref:`userguide_charts_data_types`): the data source for the chart
        values (str, optional): the values to use for producing the boxplot using
            table-like input data
        label (str or list(str), optional): the categorical variable to use for creating
            separate boxes
        color (str or list(str) or bkcharts._attributes.ColorAttr, optional): the
            categorical variable or color attribute specification to use for coloring the
            boxes.
        whisker_color (str or list(str) or bkcharts._attributes.ColorAttr, optional): the
            color of the "whiskers" that show the spread of values outside the .25 and .75
            quartiles.
        marker (str or list(str) or bkcharts._attributes.MarkerAttr, optional): the
            marker glyph to use for the outliers
        outliers (bool, optional): whether to show outliers. Defaults to True.
        **kw:

    In addition to the parameters specific to this chart,
    :ref:`userguide_charts_defaults` are also accepted as keyword parameters.

    Returns:
        :class:`Chart`: includes glyph renderers that generate Boxes and Whiskers

    Examples:

    .. bokeh-plot::
        :source-position: above

        from bkcharts import BoxPlot, output_file, show
        from bokeh.layouts import row
        from bokeh.sampledata.autompg import autompg as df

        box = BoxPlot(df, values='mpg', label='cyl', title="Auto MPG Box Plot", plot_width=400)
        box2 = BoxPlot(df, values='mpg', label='cyl', color='cyl',
                       title="MPG Box Plot by Cylinder Count", plot_width=400)

        output_file('box.html')
        show(row(box, box2))

    zCcontinuous_range must be an instance of bokeh.models.ranges.Range1dlabelvaluescolorgroupxscaleyscalexgridygridy_range)
isinstancer   
ValueErrorr   BoxPlotBuilder)datar   r   r   r   r   r   r   r   Zcontinuous_rangekwr    r   @lib/python3.7/site-packages/bkcharts/builders/boxplot_builder.pyBoxPlot$   s    :r    c            	   @   sl   e Zd ZdZe eddeddeddeddedde e dZeddZe	d	d
dZ
eZdd ZdS )r   zProduces Box Glyphs for groups of data.

    Handles box plot options to produce one to many boxes,
    which are used to describe the distribution of a variable.

    ZDimGrey)defaultZredZblack)r   r   Zoutlier_fill_colorZoutlier_line_colorZwhisker_colorZ
line_colorstackr   zE
    The marker type to use (e.g., ``circle``) if outliers=True.
    )helpTz6
    Whether to display markers for any outliers.
    )r!   r#   c             C   s4   | j d kr| jj| _ | jd kr0t| jd j| _d S )Nr   )Zylabelr   Zselected_titleZxlabelr   
attributescolumns)selfr   r   r   setup   s    


zBoxPlotBuilder.setupN)__name__
__module____qualname____doc__r   r   Zdefault_attributesr   Zmarkerr   Zoutliersr
   Zglyphr'   r   r   r   r   r   r   s   
r   )	NNNNr   r   FTN)r+   Z
__future__r   Zbokeh.core.propertiesr   r   Zbokeh.modelsr   Zbuilderr   Zbar_builderr	   Zglyphsr
   Zutilsr   r$   r   r   r    r   r   r   r   r   <module>   s     
L