question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

box_select for line glyphs

See original GitHub issue

This issue is to open discussion of implementing box_select for line glyphs. My proposal is to follow the example of box_select for patches and multi_polygons (see also #2325), which does two things: 1) adds a _hit_rect to the glyph that selects glyphs that are completely contained by the box_select; and 2) adds a note about the box_select behavior to the glyph documentation.

I have found that copying _hit_rect from box.ts is a simple solution and adequate for this selection behavior:

  protected _hit_rect(geometry: RectGeometry): Selection {
    return this._hit_rect_against_index(geometry)
  }

While it could be desirable to allow for partial overlap selections, this is a good place to start since it follows the pattern already established by the box, patches, and multi_polygons glyphs.

If this proposal is received favorably I can prepare a PR with the changes.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
4l1fecommented, Nov 9, 2022

As a temporary workaround while it’s not yet implemented i do as follow:

from bokeh.plotting import figure, show
from bokeh.models.tools import BoxSelectTool
from bokeh.models.widgets import DataTable, TableColumn
from bokeh.models.sources import ColumnDataSource
from bokeh.layouts import row


source = ColumnDataSource({'x': [1, 2, 3, 4, 5], 'y': [6, 7, 2, 4, 5]})

p = figure(width=400, height=400)

p.line(source=source, line_width=2, color='blue')
dot = p.dot(source=source, color='blue', name='points')

p.add_tools(BoxSelectTool(dimensions='width', renderers=[dot]))

columns = [
    TableColumn(field='x'),
    TableColumn(field='y'),
]
table = DataTable(source=source, columns=columns)

show(row(p,table))

Loos like a line only: image

Selected by BoxSelectTool: image

The idea as you see to add the dot glyphs with the same line color and select only their renderer.

I left it here as the issue is easily found in google search and it might be helpful for those who work with the line plot and similar plot type selection.

1reaction
rsprousecommented, May 22, 2020

Perhaps you are right that partial overlap is a better general solution for lines. For my use case (selecting time ranges of audio waveforms) the distinction is not very important since the time scale of a typical plot does not allow the viewer to select between individual samples anyway, and either behavior could be acceptable.

In informal testing the box.ts _hit_rect did not select partial overlaps, but I will check again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bokeh, multi_line: how to select several lines with the box ...
The MultiLine glyph defines only _hit_point (used by the tap, hover, ... For the box select tool to work, there needs to be...
Read more >
Configuring plot tools — Bokeh 2.4.3 Documentation
You can configure the box select tool to select across only one dimension by setting ... whenever a vertical line from the mouse...
Read more >
Glyphs 3 Handbook December 2021 - Glyphs App
Glyph Display, 41 ... Text View Width controls the line length of text in Edit View. ... letter) to control them with the...
Read more >
Python Tutorial: Customizing glyphs - YouTube
A " box select " tool that allows you to select points by dragging a ... and to use a horizontal line under...
Read more >
Interactive Data Visualization with Bokeh - Trenton McKinney
We can draw lines on Bokeh plots with the line() glyph function. ... you have created the figure, be sure to experiment with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found