示例#1
0
def population_plot(title="Default", year="2015", location="World"):
    """About page."""
    login_form = LoginForm(request.form)
    id = bkutil.session_id.generate_session_id(signed=True)
    session = bkclient.pull_session(session_id=id,
                                    url=bokeh_app_url('population'))
    print("Session id is: {}".format(session.id))
    app_param = session.document.get_model_by_name("app_param")
    # as soon we change data from app_param the plot is updated
    app_param.data['year'] = [year]
    app_param.data['location'] = [location]
    html = """
           <div id="population-plot">
               {F}
           </div>
     """.format(F=bkembed.autoload_server(
        model=None, session_id=session.id, url=bokeh_app_url('population')))
    plot = {"plot1": html}
    df = load_population()
    years = [str(x) for x in sorted(df.Year.unique())]
    locations = sorted(df.Location.unique())
    return render_template('public/population_plot.html',
                           form=login_form,
                           plot=plot,
                           subnav=PLOTS_SUBNAV(),
                           session_id=id,
                           years=years,
                           default_year=year,
                           locations=locations,
                           default_location=location)
示例#2
0
文件: slideshow.py 项目: chakas/bokeh
    def __init__(self, document):
        self.document = document

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())

        # just render at the initialization
        self._render()
示例#3
0
    def __init__(self, document):
        self.document = document

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())

        # just render at the initialization
        self._render()
示例#4
0
    def __init__(self):
        from bokeh.document import Document
        from bokeh.client import push_session
        from bokeh.models import ColumnDataSource
        from bokeh.sampledata.population import load_population

        self.document = Document()
        self.session = push_session(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())
示例#5
0
    def __init__(self):
        from bokeh.document import Document
        from bokeh.client import push_session
        from bokeh.models import ColumnDataSource
        from bokeh.sampledata.population import load_population

        self.document = Document()
        self.session = push_session(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())
示例#6
0
    def __init__(self):
        from bokeh.objects import ColumnDataSource
        from bokeh.document import Document
        from bokeh.session import Session
        from bokeh.sampledata.population import load_population

        self.document = Document()
        self.session = Session()
        self.session.use_doc('population_reveal')
        self.session.load_document(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())
示例#7
0
    def __init__(self):
        from bokeh.document import Document
        from bokeh.session import Session
        from bokeh.models import ColumnDataSource
        from bokeh.sampledata.population import load_population

        self.document = Document()
        self.session = Session()
        self.session.use_doc('population')
        self.session.load_document(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())
示例#8
0
    def __init__(self):
        from bokeh.models import ColumnDataSource
        from bokeh.document import Document
        from bokeh.session import Session
        from bokeh.sampledata.population import load_population

        self.document = Document()
        self.session = Session()
        self.session.use_doc('population_reveal')
        self.session.load_document(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())

        # just render at the initialization
        self._render()
示例#9
0
    def __init__(self):
        from bokeh.models import ColumnDataSource
        from bokeh.document import Document
        # from bokeh.session import Session
        from bokeh.sampledata.population import load_population

        self.document = curdoc()  #Document()
        self.session = session
        # self.session = Session()
        # self.session.use_doc('population_reveal')
        # self.session.load_document(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())

        # just render at the initialization
        self._render()
示例#10
0
    def __init__(self, *args, **kwargs):
        self._df = load_population()
        self._revision = 2012

        self._year = 2010
        self._location = "World"

        self._years = [str(x) for x in sorted(self._df.Year.unique())]
        self._locations = sorted(self._df.Location.unique())

        self._source_pyramid = ColumnDataSource(data=dict())
        self._source_known = ColumnDataSource(data=dict(x=[], y=[]))
        self._source_predicted = ColumnDataSource(data=dict(x=[], y=[]))
        #self._pyramid_plot = PyramidPlot(source=self._source_pyramid,name='bk-pyramid')
        self.update_data()

        kwargs["children"] = [self.layout()]
        #kwargs["children"] = list()
        #kwargs["children"] = list(self.layout)
        super(Population, self).__init__()
        self.children.append(self.layout())
示例#11
0
from bokeh.client import push_session
from bokeh.document import Document
from bokeh.models.glyphs import Line, Quad
from bokeh.models import (
    Plot, ColumnDataSource, DataRange1d, FactorRange,
    LinearAxis, CategoricalAxis, Grid, Legend,
    SingleIntervalTicker
)
from bokeh.sampledata.population import load_population
from bokeh.models.widgets import Select
from bokeh.models.layouts import WidgetBox, Column

document = Document()
session = push_session(document)

df = load_population()
revision = 2012

year = 2010
location = "World"

years = [str(x) for x in sorted(df.Year.unique())]
locations = sorted(df.Location.unique())

source_pyramid = ColumnDataSource(data=dict())

def pyramid():
    xdr = DataRange1d()
    ydr = DataRange1d()

    plot = Plot(title=None, x_range=xdr, y_range=ydr, plot_width=600, plot_height=600, toolbar_location=None)
示例#12
0
from numpy import pi

from bokeh.client import push_session
from bokeh.document import Document
from bokeh.embed import autoload_server
from bokeh.layouts import row, column
from bokeh.models import (Plot, DataRange1d, LinearAxis, CategoricalAxis,
                          Legend, ColumnDataSource, Grid, Line,
                          SingleIntervalTicker, Quad, Select, FactorRange)
from bokeh.sampledata.population import load_population

document = Document()

session = push_session(document)

df = load_population()
revision = 2012

year = 2010
location = "World"

years = [str(x) for x in sorted(df.Year.unique())]
locations = sorted(df.Location.unique())

source_pyramid = ColumnDataSource(data=dict())


def pyramid():
    xdr = DataRange1d()
    ydr = DataRange1d()