Example #1
0
def modify_doc(doc):
    source = ColumnDataSource(dict(x=[1, 2], y=[1, 1], val=["a", "b"]))
    plot = Plot(plot_height=400,
                plot_width=400,
                x_range=Range1d(0, 1),
                y_range=Range1d(0, 1),
                min_border=0)

    plot.add_glyph(source, Circle(x='x', y='y'))
    plot.add_tools(
        CustomAction(callback=CustomJS(args=dict(s=source),
                                       code=RECORD("data", "s.data"))))
    num_input = NumericInput(low=-1, high=100, value=4, css_classes=["foo"])

    def cb(attr, old, new):
        source.data['val'] = [old, new]

    num_input.on_change('value', cb)
    doc.add_root(column(num_input, plot))
    return doc
Example #2
0
impedimentType = Select(title='障碍类型', value='矩形障碍_设置', options=['矩形障碍_设置', '随机矩形', '随机圆', '随机矩形+随机圆'])
impedimentType.on_change('value', lambda attr, old, new: setInfo(imType=new))
# 在x情况下执行 算法 新增点
newNode = [Button(label='刷新随机', width=120, button_type="primary"),
           Button(label='► 开始', width=60, button_type="primary")]
newNode[0].on_click(reFlash)
newNode[1].on_click(buttonOnchange)
setInfo(newNode=newNode)
# goal 的半径
goalRadius = Slider(title="目标点的半径", value=1, start=1, end=max(initInfo.get('xlen'), initInfo.get('ylen')) / 10, step=1)
goalRadius.on_change('value', lambda attr, old, new: setInfo(goalRadius=new))

# input test
start_x = NumericInput(title='start_x', value=min(initInfo.get('startPoint')[0], initInfo.get('xlen') - 1), low=0,
                       high=initInfo.get('xlen') - 1, width=60)
start_x.on_change('value', pointOnchange)
start_y = NumericInput(title='start_y', value=min(initInfo.get('startPoint')[1], initInfo.get('ylen') - 1), low=0,
                       high=initInfo.get('ylen') - 1, width=60)
start_y.on_change('value', pointOnchange)
end_x = NumericInput(title='end_x', value=min(initInfo.get('endPoint')[0], initInfo.get('xlen') - 1), low=0,
                     high=initInfo.get('xlen') - 1, width=60)
end_x.on_change('value', pointOnchange)
end_y = NumericInput(title='end_y', value=min(initInfo.get('endPoint')[1], initInfo.get('ylen') - 1), low=0,
                     high=initInfo.get('ylen') - 1, width=60)
end_y.on_change('value', pointOnchange)
# 造对象 显示
initInfo['layout'] = row(
    column(method, xLenSlider, yLenSlider, impedimentType, goalRadius, row(start_x, start_y, end_x, end_y),
           row(newNode)),
    initInfo.get('p'))
curdoc().add_root(initInfo.get('layout'))