ó
Î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 m Z m Z d d 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 Dot class which lets you build your Dot 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   Float(   t   Range1di   (   t   create_and_buildi   (   t
   BarBuilder(   t   DotGlyph(   t	   ColorAttrt   CatAttrt
   MarkerAttrt   sumt   categoricalt   linearc         K@  ső   | r% t  | t  r% t d   n  | d k	 rq | d k rq t | d <| d k s_ | d k rq d } | } qq n  | } | | d <| | d <| | d <| | d	 <| | d
 <| | d <| | d <| | d <|	 | d <|
 | d <| | d <t t |  |  S(   s¨	   Create a Dot chart using
    :class:`DotBuilder <bkcharts.builders.dot_builder.DotBuilder>` to render the
    geometry from the inputs.

    Args:
        data (:ref:`userguide_charts_data_types`): the data
            source for the chart.
        label (list(str) or str, optional): list of string representing the categories.
            (Defaults to None)
        values (str, optional): iterable 2d representing the data series
            values matrix.
        color (str or list(str) or `~bkcharts._attributes.ColorAttr`): string color,
            string column name, list of string columns or a custom `ColorAttr`,
            which replaces the default `ColorAttr` for the builder.
        stack (list(str) or str, optional): columns to use for stacking.
            (Defaults to False, so grouping is assumed)
        group (list(str) or str, optional): columns to use for grouping.
        agg (str): how to aggregate the `values`. (Defaults to 'sum', or only label is
            provided, then performs a `count`)
        continuous_range(Range1d, optional): Custom continuous_range to be
            used. (Defaults to None)

    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 dots

    Examples:

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

            from bkcharts import Dot, output_file, show
            from bokeh.layouts import row

            # best support is with data in a format that is table-like
            data = {
                'sample': ['1st', '2nd', '1st', '2nd', '1st', '2nd'],
                'interpreter': ['python', 'python', 'pypy', 'pypy', 'jython', 'jython'],
                'timing': [-2, 5, 12, 40, 22, 30]
            }

            # x-axis labels pulled from the interpreter column, stacking labels from sample column
            dot = Dot(data, values='timing', label='interpreter', stack='sample', agg='mean',
                      title="Python Interpreter Sampling", legend='top_right', plot_width=400)

            # table-like data results in reconfiguration of the chart with no data manipulation
            dot2 = Dot(data, values='timing', label=['interpreter', 'sample'],
                       agg='mean', title="Python Interpreters", plot_width=400)

            output_file("Dot.html")
            show(row(dot, dot2))

    sC   continuous_range must be an instance of bokeh.models.ranges.Range1dt
   label_onlyR
   t   meant   countt   labelt   valuest   colort   stackt   groupt   aggt   xscalet   yscalet   xgridt   ygridt   y_rangeN(   t
   isinstanceR   t
   ValueErrort   Nonet   TrueR   t
   DotBuilder(   t   dataR   R   R   R   R   R   R   R   R   R   t   continuous_ranget   kwR   (    (    s<   lib/python2.7/site-packages/bkcharts/builders/dot_builder.pyt   Dot#   s*    :











R   c           B@  sw   e  Z d  Z e d d  Z i e   d 6e   d 6e   d 6e   d 6e   d 6e   d 6Z e	 e
 d	 d
 Z e Z RS(   s°   Produces Dot Glyphs for groups of data.

    Handles dot plot options to produce one to many dots,
    which are used to describe the values of aggregated groups of data.

    t   defaultg      đ?R   R   t
   line_colorR   R   t   markert   helps:   
    Whether to draw a stem from each do to the axis.
    (   t   __name__t
   __module__t   __doc__R   t
   line_alphaR   R   R	   t   default_attributesR   t   Falset   stemR   t   glyph(    (    (    s<   lib/python2.7/site-packages/bkcharts/builders/dot_builder.pyR   y   s   



		N(   R*   t
   __future__R    t   bokeh.core.propertiesR   R   t   bokeh.modelsR   t   builderR   t   bar_builderR   t   glyphsR   t
   attributesR   R   R	   R   R-   R   R#   R   (    (    (    s<   lib/python2.7/site-packages/bkcharts/builders/dot_builder.pyt   <module>   s   T