Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
BokehJS FreehandDrawTool does not plot line when dragging mouse in canvas

In BokehJS 2.4.2 the FreehandDrawTool documentation is showing in the toolbar, but no line is drawn when dragging the mouse in the canvas.

Here is a minimal example to reproduce the problem. This example is so minimalistic it is hard to figure out what could possibly be wrong.

let plot = Bokeh.Plotting.figure({
    tools: ['freehand_draw'],
    x_range: [0, 100],
    y_range: [0, 100],
});

Output of the minimal code to reproduce the problem

Output of the minimal code to reproduce the problem

Example from the FreehandDrawTool documentation

Example from the FreehandDrawTool documentation

What could prevent the line to be drawn when dragging the mouse in the canvas?

The goal is to have a working FreehandDrawTool.

UPDATE 1

Modified example according to Python example from @mosc9575 as follows and it works! The tool should be inactive by default, it will not work when the tool is active by default. When the FreehandDrawTool is active by default you need de deactivate and activate the tool again for it to work.

let source = new Bokeh.ColumnDataSource({
    data : {
        xs: [[0,50,100]],
        ys: [[0,50,0]],
    },
});

let r = plot.multi_line({
    'xs': { field: 'xs' },
    'ys': { field: 'ys' },
    source: source,
});

let freehand_draw = new Bokeh.FreehandDrawTool({
    active: false,
    empty_value: 1,
    renderers: [r],
});

plot.add_tools(freehand_draw);

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You neew to create a renderer to make your example work. Without this renderer the draw tool has no option to add this values.

Python example

from bokeh.plotting import figure, show, output_notebook
from bokeh.models import FreehandDrawTool, ColumnDataSource
output_notebook()

plot = figure(
    x_range =  [0, 100],
    y_range =  [0, 100],
    width=400,
    height=400,
    tools = ""
)

source = ColumnDataSource(dict(xs=[[0,0]], ys=[[0,0]]))

r = plot.multi_line('xs', 'ys', source=source)
tool = FreehandDrawTool(renderers=[r], empty_value=1)
plot.add_tools(tool)
show(plot)

It looks like your are doing this in JS and not in python, therefore this copy will not work as copy'n'paste, but it ilustrates the concept.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda