Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!