Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bokeh: update from 2.4.3 to 3.3.2 #268

Merged
merged 5 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false # don't cancel if a job from the matrix fails
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"] # 3.12: pyfftw not yet supported

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:focal
FROM ubuntu:jammy

COPY requirements.txt requirements.txt

Expand Down
13 changes: 12 additions & 1 deletion app/plot_app/configured_plots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" This contains the list of all drawn plots on the log plotting page """

import re
from html import escape

from bokeh.layouts import column
Expand Down Expand Up @@ -92,7 +93,8 @@ def generate_plots(ulog, px4_ulog, db_data, vehicle_data, link_to_3d_page,
if np.amax(cur_dataset.data['is_vtol']) == 1:
is_vtol = True
# check if is tailsitter
is_vtol_tailsitter = np.amax(cur_dataset.data['is_vtol_tailsitter']) == 1
is_vtol_tailsitter = ('is_vtol_tailsitter' in cur_dataset.data and
np.amax(cur_dataset.data['is_vtol_tailsitter']) == 1)
# find mode after transitions (states: 1=transition, 2=FW, 3=MC)
if 'vehicle_type' in cur_dataset.data:
vehicle_type_field = 'vehicle_type'
Expand Down Expand Up @@ -1008,6 +1010,12 @@ def param_changes_button_clicked():
param_changes_button.on_click(param_changes_button_clicked)


user_agent = curdoc().session_context.request.headers.get("User-Agent", "")
is_mobile = re.search(r'Mobile|iP(hone|od|ad)|Android|BlackBerry|'
r'IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|'
r'Minimo|Opera M(obi|ini)|Blazer|Dolfin|'
r'Dolphin|Skyfire|Zune', user_agent)

jinja_plot_data = []
for i in range(len(plots)):
if plots[i] is None:
Expand All @@ -1026,6 +1034,9 @@ def param_changes_button_clicked():
'fragment': fragment,
'title': plot_title
})
if is_mobile is not None and hasattr(plots[i], 'toolbar'):
# Disable panning on mobile by default
plots[i].toolbar.active_drag = None


# changed parameters
Expand Down
4 changes: 2 additions & 2 deletions app/plot_app/downsampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, bokeh_plot, data, x_key):
self.cur_data[k] = data[k]

# first downsampling
self.downsample(self.cur_data, self.bokeh_plot.plot_width *
self.downsample(self.cur_data, self.bokeh_plot.width *
self.startup_density)
self.data_source = ColumnDataSource(data=self.cur_data)

Expand All @@ -64,7 +64,7 @@ def x_range_change_cb(self, attr, old, new):
new_range = [self.bokeh_plot.x_range.start, self.bokeh_plot.x_range.end]
if None in new_range:
return
plot_width = self.bokeh_plot.plot_width
plot_width = self.bokeh_plot.width
init_x = self.init_data[self.x_key]
cur_x = self.cur_data[self.x_key]
cur_range = [cur_x[0], cur_x[-1]]
Expand Down
67 changes: 39 additions & 28 deletions app/plot_app/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pylint: disable=line-too-long, arguments-differ, unused-import
from bokeh.models import (
ColumnDataSource, Range1d, DataRange1d, DatetimeAxis,
TickFormatter, DatetimeTickFormatter, FuncTickFormatter,
TickFormatter, DatetimeTickFormatter, CustomJSTickFormatter,
Grid, Legend, Plot, BoxAnnotation, Span, CustomJS, Rect, Circle, Line,
HoverTool, BoxZoomTool, PanTool, WheelZoomTool, ResetTool, SaveTool,
WMTSTileSource, GMapPlot, GMapOptions,
Expand All @@ -20,6 +20,7 @@
import scipy.signal
import pyfftw

from config import debug_verbose_output
from downsampling import DynamicDownsample
from helper import (
map_projection, WGS84_to_mercator, flight_modes_table, vtol_modes_table, get_lat_lon_alt_deg
Expand Down Expand Up @@ -91,7 +92,8 @@ def add_virtual_fifo_topic_data(ulog, topic_name, instance=0):
return True
except (KeyError, IndexError, ValueError) as error:
# log does not contain the value we are looking for
print(type(error), "(fifo data):", error)
if debug_verbose_output():
print(type(error), "(fifo data):", error)
return False


Expand All @@ -118,7 +120,7 @@ def plot_parameter_changes(p, plots_height, changed_parameters):
# plot as text with a fixed screen-space y offset
labels = LabelSet(x='x', y='y', text='names',
y_units='screen', level='glyph', #text_alpha=0.9, text_color='black',
source=source, render_mode='canvas', text_font_size='8pt')
source=source, text_font_size='8pt')
p.add_layout(labels)
return labels
return None
Expand Down Expand Up @@ -168,7 +170,7 @@ def plot_flight_modes_background(data_plot, flight_mode_changes, vtol_states=Non
'y': labels_y_pos, 'textcolor': labels_color})
labels = LabelSet(x='x', y='y', text='text',
y_units='screen', level='underlay',
source=source, render_mode='canvas',
source=source,
text_font_size='10pt',
text_color='textcolor', text_alpha=0.85,
background_fill_color='white',
Expand Down Expand Up @@ -223,7 +225,7 @@ def plot_set_equal_aspect_ratio(p, x, y, zoom_out_factor=1.3, min_range=5):
y_center = (y_range[0]+y_range[1])/2

# keep same aspect ratio as the plot
aspect = p.plot_width / p.plot_height
aspect = p.width / p.height
if aspect > x_diff / y_diff:
x_diff = y_diff * aspect
else:
Expand Down Expand Up @@ -281,7 +283,7 @@ def plot_map(ulog, config, map_type='plain', api_key=None, setpoints=False,

p = GMapPlot(
x_range=Range1d(), y_range=Range1d(), map_options=map_options,
api_key=api_key, plot_width=plots_width, plot_height=plots_height
api_key=api_key, width=plots_width, height=plots_height
)

pan = PanTool()
Expand All @@ -301,8 +303,8 @@ def plot_map(ulog, config, map_type='plain', api_key=None, setpoints=False,
data_source = ColumnDataSource(data={'lat': lat, 'lon': lon})

p = figure(tools=TOOLS, active_scroll=ACTIVE_SCROLL_TOOLS)
p.plot_width = plots_width
p.plot_height = plots_height
p.width = plots_width
p.height = plots_height

plot_set_equal_aspect_ratio(p, lon, lat)

Expand Down Expand Up @@ -363,8 +365,8 @@ def plot_map(ulog, config, map_type='plain', api_key=None, setpoints=False,
if bokeh_plot is None:
p = figure(tools=TOOLS, active_scroll=ACTIVE_SCROLL_TOOLS,
x_axis_label='[m]', y_axis_label='[m]')
p.plot_width = plots_width
p.plot_height = plots_height
p.width = plots_width
p.height = plots_height

plot_set_equal_aspect_ratio(p, lon, lat)
else:
Expand Down Expand Up @@ -399,7 +401,8 @@ def plot_map(ulog, config, map_type='plain', api_key=None, setpoints=False,

except (KeyError, IndexError, ValueError) as error:
# log does not contain the value we are looking for
print(type(error), "(vehicle_gps_position):", error)
if debug_verbose_output():
print(type(error), "(vehicle_gps_position):", error)
return None
p.toolbar.logo = None
# make it possible to hide graphs by clicking on the label
Expand Down Expand Up @@ -453,7 +456,8 @@ def __init__(self, data, config, data_name, x_axis_label=None,
y=y_start, size=0, alpha=0)

except (KeyError, IndexError, ValueError) as error:
print(type(error), "("+self._data_name+"):", error)
if debug_verbose_output():
print(type(error), "("+self._data_name+"):", error)
self._had_error = True

@property
Expand Down Expand Up @@ -501,7 +505,8 @@ def change_dataset(self, data_name, topic_instance=0):
self._cur_dataset = [elem for elem in self._data
if elem.name == data_name and elem.multi_id == topic_instance][0]
except (KeyError, IndexError, ValueError) as error:
print(type(error), "("+self._data_name+"):", error)
if debug_verbose_output():
print(type(error), "("+self._data_name+"):", error)
self._had_error = True
self._cur_dataset = None

Expand Down Expand Up @@ -550,7 +555,7 @@ def add_graph(self, field_names, colors, legends, use_downsample=True,
# plot as text with a fixed screen-space y offset
labels = LabelSet(x='x', y='y', text='names',
y_units='screen', level='glyph', text_color=nan_color,
source=source, render_mode='canvas')
source=source)
p.add_layout(labels)


Expand All @@ -573,7 +578,8 @@ def add_graph(self, field_names, colors, legends, use_downsample=True,
legend_label=legend, line_width=2, line_color=color)

except (KeyError, IndexError, ValueError) as error:
print(type(error), "("+self._data_name+"):", error)
if debug_verbose_output():
print(type(error), "("+self._data_name+"):", error)
self._had_error = True

def add_circle(self, field_names, colors, legends):
Expand All @@ -595,7 +601,8 @@ def add_circle(self, field_names, colors, legends):
fill_color=None)

except (KeyError, IndexError, ValueError) as error:
print(type(error), "("+self._data_name+"):", error)
if debug_verbose_output():
print(type(error), "("+self._data_name+"):", error)
self._had_error = True


Expand Down Expand Up @@ -630,7 +637,8 @@ def add_span(self, field_name, accumulator_func=np.mean,
self._p.add_layout(data_span)

except (KeyError, IndexError, ValueError) as error:
print(type(error), "("+self._data_name+"):", error)
if debug_verbose_output():
print(type(error), "("+self._data_name+"):", error)
self._had_error = True

def add_horizontal_background_boxes(self, colors, limits):
Expand Down Expand Up @@ -668,8 +676,8 @@ def _setup_plot(self):
plots_height = self.plot_height
p = self._p

p.plot_width = plots_width
p.plot_height = plots_height
p.width = plots_width
p.height = plots_height

# -> other attributes are set via theme.yaml

Expand All @@ -688,7 +696,7 @@ def _setup_plot(self):

# axis labels: format time
if self._use_time_formatter:
p.xaxis[0].formatter = FuncTickFormatter(code='''
p.xaxis[0].formatter = CustomJSTickFormatter(code='''
//func arguments: ticks, x_range
// assume us ticks
var ms = Math.round(tick / 1000);
Expand Down Expand Up @@ -717,7 +725,8 @@ def _setup_plot(self):
''', args={'x_range': p.x_range})

# make it possible to hide graphs by clicking on the label
p.legend.click_policy = "hide"
if len(p.legend) > 0:
p.legend.click_policy = "hide"


class DataPlot2D(DataPlot):
Expand All @@ -739,8 +748,8 @@ def __init__(self, data, config, data_name, x_axis_label=None,
self._equal_aspect = equal_aspect
self._is_first_graph = True

self._p.plot_width = self._config['plot_width']
self._p.plot_height = self._config['plot_height'][self._plot_height_name]
self._p.width = self._config['plot_width']
self._p.height = self._config['plot_height'][self._plot_height_name]


def add_graph(self, dataset_x, dataset_y, color, legend, check_if_all_zero=False):
Expand Down Expand Up @@ -774,7 +783,8 @@ def add_graph(self, dataset_x, dataset_y, color, legend, check_if_all_zero=False
plot_set_equal_aspect_ratio(p, x, y)

except (KeyError, IndexError, ValueError) as error:
print(type(error), "("+self._data_name+"):", error)
if debug_verbose_output():
print(type(error), "("+self._data_name+"):", error)
self._had_error = True


Expand Down Expand Up @@ -896,7 +906,8 @@ def add_graph(self, field_names, legends, window='hann', window_length=256, nove
self._p.toolbar.active_scroll = wheel_zoom

except (KeyError, IndexError, ValueError, ZeroDivisionError) as error:
print(type(error), "(" + self._data_name + "):", error)
if debug_verbose_output():
print(type(error), "(" + self._data_name + "):", error)
self._had_error = True

class DataPlotFFT(DataPlot):
Expand Down Expand Up @@ -984,7 +995,8 @@ def add_graph(self, field_names, colors, legends):
line_color=color, line_width=2, legend_label=legend)

except (KeyError, IndexError, ValueError, ZeroDivisionError) as error:
print(type(error), "(" + self._data_name + "):", error)
if debug_verbose_output():
print(type(error), "(" + self._data_name + "):", error)
self._had_error = True

def mark_frequency(self, frequency, label, y_screen_offset=0):
Expand All @@ -1002,7 +1014,6 @@ def mark_frequency(self, frequency, label, y_screen_offset=0):
# plot as text with a fixed screen-space y offset
label = Label(x=frequency, y=self.plot_height/2-10-y_screen_offset,
text=label, y_units='screen', level='glyph',
text_font_size='8pt', text_color=mark_color,
render_mode='canvas')
text_font_size='8pt', text_color=mark_color)
p.add_layout(label)

27 changes: 1 addition & 26 deletions app/plot_app/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,8 @@ h1 .name {
font-weight: 400;
}

/* navigation anchor links for plots */
a.fragment {
position: absolute;
top: -14px;
left: -16px;
z-index: 100;
}
a.fragment:not(:hover) {
color: #a8a8a8;
}

/* upload page */
table.spaced {
/* upload page */
margin: 16px 0;
width: 680px;
}
Expand Down Expand Up @@ -95,20 +84,6 @@ pre {
}


/* bokeh plots */
.bk-plot-layout {
/* spacing between plots */
margin-top: 12px;
}
.bk-grid-column {
/* adjust to changed spacing */
height: 100% !important;
}
/* bootstrap interferences */
.bk-slick-header-column {
box-sizing: content-box;
}

/* override the bokeh font with the one used in the boostrap theme
* (there's no option for that in theme.yaml)
*/
Expand Down
Binary file added app/plot_app/static/images/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions app/plot_app/statistics_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from bokeh.plotting import figure
from bokeh.palettes import viridis # alternatives: magma, inferno
from bokeh.models import (
DatetimeTickFormatter, FixedTicker, FuncTickFormatter,
DatetimeTickFormatter, FixedTicker, CustomJSTickFormatter,
HoverTool, ColumnDataSource, LabelSet #, CustomJS
)

Expand Down Expand Up @@ -549,7 +549,7 @@ def _plot_public_data_statistics(self, all_data, version_attr_name,
if area.legend:
area.legend[0].items.reverse()

area.xaxis.formatter = FuncTickFormatter(code="""
area.xaxis.formatter = CustomJSTickFormatter(code="""
var versions = """ + str(versions_spaced) + """;
return versions[Math.floor(tick)]
""")
Expand All @@ -569,8 +569,8 @@ def _setup_plot(self, p, plot_height='normal'):

plots_width = self._config['plot_width']
plots_height = self._config['plot_height'][plot_height]
p.plot_width = plots_width
p.plot_height = plots_height
p.width = plots_width
p.height = plots_height

p.xgrid.grid_line_color = 'navy'
p.xgrid.grid_line_alpha = 0.13
Expand Down
3 changes: 2 additions & 1 deletion app/plot_app/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<link href="plot_app/static/css/font-awesome.min.css" rel="stylesheet">
<link href="plot_app/static/css/animate.min.css" rel="stylesheet">
<link href="plot_app/static/css/main.css" rel="stylesheet">

<link rel="icon" type="image/x-icon" href="plot_app/static/images/favicon-32x32.png">

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""/>
Expand Down
Loading
Loading