ó
ÎYc        
   @@  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 d d d e e d d „	 Z d e f d „  ƒ  YZ d S(   s&  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.
i    (   t   absolute_import(   t   Boolt   String(   t   Range1di   (   t   create_and_buildi   (   t
   BarBuilder(   t   BoxGlyph(   t   title_from_columns(   t	   ColorAttrt   CatAttrt   categoricalt   linearc
         K@  s•   |	 r% t  |	 t ƒ r% t d ƒ ‚ n  |	 } | |
 d <| |
 d <| |
 d <| |
 d <| |
 d <| |
 d <| |
 d <| |
 d	 <| |
 d
 <t t |  |
  S(   sd	  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))

    sC   continuous_range must be an instance of bokeh.models.ranges.Range1dt   labelt   valuest   colort   groupt   xscalet   yscalet   xgridt   ygridt   y_range(   t
   isinstanceR   t
   ValueErrorR   t   BoxPlotBuilder(   t   dataR   R   R   R   R   R   R   R   t   continuous_ranget   kwR   (    (    s@   lib/python2.7/site-packages/bkcharts/builders/boxplot_builder.pyt   BoxPlot$   s    :








R   c           B@  sµ   e  Z d  Z i e ƒ  d 6e d d ƒ d 6e d d ƒ d 6e d d ƒ d 6e d d ƒ d	 6e d d ƒ d
 6e ƒ  d 6e ƒ  d 6Z e d d ƒ Z e d e	 d d ƒ Z
 e Z d „  Z RS(   s¨   Produces 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.

    R   t   defaultt   DimGreyR   t   redt   outlier_fill_colort   outlier_line_colort   blackt   whisker_colort
   line_colort   stackR   t   helpsE   
    The marker type to use (e.g., ``circle``) if outliers=True.
    s6   
    Whether to display markers for any outliers.
    c         C@  sP   |  j  d  k r! |  j j |  _  n  |  j d  k rL t |  j d j ƒ |  _ n  d  S(   NR   (   t   ylabelt   NoneR   t   selected_titlet   xlabelR   t
   attributest   columns(   t   self(    (    s@   lib/python2.7/site-packages/bkcharts/builders/boxplot_builder.pyt   setup   s    (   t   __name__t
   __module__t   __doc__R	   R   t   default_attributesR   t   markerR   t   Truet   outliersR   t   glyphR-   (    (    (    s@   lib/python2.7/site-packages/bkcharts/builders/boxplot_builder.pyR   r   s   
		N(   R0   t
   __future__R    t   bokeh.core.propertiesR   R   t   bokeh.modelsR   t   builderR   t   bar_builderR   t   glyphsR   t   utilsR   R*   R   R	   R'   t   FalseR3   R   R   (    (    (    s@   lib/python2.7/site-packages/bkcharts/builders/boxplot_builder.pyt   <module>   s   	L