B
    ÎYm  ã               @   sZ   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ee	edœZ
d	d	d	efd
d„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 TimeSeries chart, which provides a convenient interface for
generating different charts using series-like data by transforming the data
to a consistent format and producing renderers.
é    )Úabsolute_importé   )Úcreate_and_buildé   )ÚLineBuilderÚPointSeriesBuilder)ÚStepBuilder)ÚlineÚstepZpointNc             K   s*   t  ||¡}||d< ||d< t|| f|ŽS )ab	   Create a timeseries chart using :class:`LineBuilder
    <bkcharts.builder.line_builder.LineBuilder>` to produce the renderers from
    the inputs. The timeseries chart acts as a switchboard to produce charts
    for timeseries data with different glyph representations.

    Args:
        data (list(list), numpy.ndarray, pandas.DataFrame, list(pd.Series)): a 2d data
            source with columns of data for each stepped line.
        x (str or list(str), optional): specifies variable(s) to use for x axis
        y (str or list(str), optional): specifies variable(s) to use for y axis
        builder_type (str or `Builder`, optional): the type of builder to use to produce
            the renderers. Supported options are 'line', 'step', or 'point'.

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

    Returns:
        a new :class:`Chart <bkcharts.Chart>`

    Examples:

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

        import pandas as pd

        from bkcharts import TimeSeries, show, output_file
        from bokeh.layouts import column

        # read in some stock data from the Yahoo Finance API
        AAPL = pd.read_csv(
            "http://ichart.yahoo.com/table.csv?s=AAPL&a=0&b=1&c=2000&d=0&e=1&f=2010",
            parse_dates=['Date'])
        MSFT = pd.read_csv(
            "http://ichart.yahoo.com/table.csv?s=MSFT&a=0&b=1&c=2000&d=0&e=1&f=2010",
            parse_dates=['Date'])
        IBM = pd.read_csv(
            "http://ichart.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2000&d=0&e=1&f=2010",
            parse_dates=['Date'])

        data = dict(
            AAPL=AAPL['Adj Close'],
            Date=AAPL['Date'],
            MSFT=MSFT['Adj Close'],
            IBM=IBM['Adj Close'],
        )

        tsline = TimeSeries(data,
            x='Date', y=['IBM', 'MSFT', 'AAPL'],
            color=['IBM', 'MSFT', 'AAPL'], dash=['IBM', 'MSFT', 'AAPL'],
            title="Timeseries", ylabel='Stock Prices', legend=True)

        tspoint = TimeSeries(data,
            x='Date', y=['IBM', 'MSFT', 'AAPL'],
            color=['IBM', 'MSFT', 'AAPL'], dash=['IBM', 'MSFT', 'AAPL'],
            builder_type='point', title="Timeseries Points",
            ylabel='Stock Prices', legend=True)

        output_file("timeseries.html")

        show(column(tsline, tspoint))

    ÚxÚy)ÚBUILDER_TYPESÚgetr   )Údatar   r   Zbuilder_typeZkws© r   úClib/python3.7/site-packages/bkcharts/builders/timeseries_builder.pyÚ
TimeSeries$   s    Ar   )Ú__doc__Z
__future__r   Zbuilderr   Zline_builderr   r   Zstep_builderr   r   r   r   r   r   r   Ú<module>   s   