B
    Y                 @   sf   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddd	ZG d
d deZdS )zThis is the Bokeh charts interface. It gives you a high level API
to build complex plot is a simple way.

This is the Scatter class which lets you build your Scatter charts
just passing the arguments to the Chart class and calling the proper
functions.
    )absolute_import)create_and_build	XYBuilder)
PointGlyph)
MarkerAttr	ColorAttr)add_tooltips_columnsNc             K   s   ||d< ||d< t t| f|S )a,   Create a scatter chart using :class:`ScatterBuilder <bkcharts.builders.scatter_builder.ScatterBuilder>`
    to render the geometry from values.

    Args:
        data (:ref:`userguide_charts_data_types`): table-like data
        x (str or list(str), optional): the column label to use for the x dimension
        y (str or list(str), optional): the column label to use for the y dimension

    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 the scatter points

    Examples:

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

        from bokeh.sampledata.autompg import autompg as df
        from bkcharts import Scatter, output_file, show

        scatter = Scatter(df, x='mpg', y='hp', color='cyl', marker='origin',
                          title="Auto MPG", xlabel="Miles Per Gallon",
                          ylabel="Horsepower")

        output_file('scatter.html')
        show(scatter)

    xy)r   ScatterBuilder)datar	   r
   Zkws r   @lib/python3.7/site-packages/bkcharts/builders/scatter_builder.pyScatter    s    r   c               @   s&   e Zd ZdZe e dZdd ZdS )r   a  This is the Scatter class and it is in charge of plotting
    Scatter charts in an easy and intuitive way.

    Essentially, we provide a way to ingest the data, make the proper
    calculations and push the references into a source object.
    We additionally make calculations for the ranges. And finally add
    the needed glyphs (markers) taking the references from the source.

    )colormarkerc          	   c   s   x| j jf | jD ]p}t|j|| jj|| jj|d |d |d d}| 	|| x(|j
D ]}| jrxt|| j|}|V  q`W qW dS )zUse the marker glyphs to display the points.

        Takes reference points from data loaded at the ColumnDataSource.
        r   r   )labelr	   r
   Z
line_colorZ
fill_colorr   N)_datagroupbyZ
attributesr   r   Z
get_valuesr	   Z	selectionr
   Z	add_glyphZ	renderersZtooltipsr   )selfgroupZglyphZrendererr   r   r   yield_renderersR   s    zScatterBuilder.yield_renderersN)__name__
__module____qualname____doc__r   r   Zdefault_attributesr   r   r   r   r   r   D   s   	
r   )NNN)r   Z
__future__r   Zbkcharts.builderr   r   Zbkcharts.glyphsr   Zbkcharts.attributesr   r   Zbkcharts.utilsr   r   r   r   r   r   r   <module>   s   
$