当前位置: 首页>>代码示例>>Python>>正文


Python Select.callback方法代码示例

本文整理汇总了Python中bokeh.models.Select.callback方法的典型用法代码示例。如果您正苦于以下问题:Python Select.callback方法的具体用法?Python Select.callback怎么用?Python Select.callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.models.Select的用法示例。


在下文中一共展示了Select.callback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plotDayOfWeekTimeline

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import callback [as 别名]
def plotDayOfWeekTimeline(fileName, initData, bokehPlaceholderId='bokehContent'):    

    source = ColumnDataSource(data=initData)
    selectDOW = Select(title="Days:", value="Monday", options=["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"])
    selectUT = Select(title="User Type:", value="All", options=["All", "Subscriber", "Customer"])
    model = dict(source=source, select_dow = selectDOW, select_ut = selectUT)
    plot = Figure(plot_width=1200, plot_height=400, x_axis_type="datetime")
    plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)
    
    callback = CustomJS(args=model, code="""
          var dayOfWeek = select_dow.get('value')
            var userType = select_ut.get('value')
            var xmlhttp;
            xmlhttp = new XMLHttpRequest();
            
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == XMLHttpRequest.DONE ) {
                    if(xmlhttp.status == 200){
                        var data = source.get('data');
                        var result = JSON.parse(xmlhttp.responseText);
                        var temp=[];
                        
                        for(var date in result.x) {
                            temp.push(new Date(result.x[date]));
                        }
                        
                        data['x'] = temp;
                        data['y'] = result.y;
                        source.trigger('change');
                    }
                    else if(xmlhttp.status == 400) {
                        alert(400);
                    }
                    else {
                        alert(xmlhttp.status);
                    }
                }
            };
        var params = {dow:dayOfWeek, ut:userType};
        url = "/select?" + jQuery.param( params );
        xmlhttp.open("GET", url, true);
        xmlhttp.send();
        """)
        
    selectDOW.callback = callback
    selectUT.callback = callback
    layout = vform(selectDOW, selectUT, plot)
    script, div = components(layout)
    html = readHtmlFile(fileName)
    html = insertScriptIntoHeader(html, script)
    html = appendElementContent(html, div, "div", "bokehContent")

    return html
    
    
开发者ID:YDnepr,项目名称:practicalcourse,代码行数:55,代码来源:gui.py

示例2: test_callback_property_executes

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import callback [as 别名]
    def test_callback_property_executes(self, bokeh_model_page):
        select = Select(options=["Option 1", "Option 2", "Option 3"], css_classes=["foo"])
        select.callback = CustomJS(code=RECORD("value", "cb_obj.value"))

        page = bokeh_model_page(select)

        el = page.driver.find_element_by_css_selector('.foo select')
        el.click()

        el = page.driver.find_element_by_css_selector('.foo select option[value="Option 3"]')
        el.click()

        results = page.results
        assert results['value'] == 'Option 3'

        assert page.has_no_console_errors()
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:18,代码来源:test_select.py


注:本文中的bokeh.models.Select.callback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。