Setting legend location in BokehJS

As an experiment, I’m trying to convert a figure that was originally written with the python interface to Bokeh to directly use BokehJS in the browser. While much of the conversion has been straightforward and amounts to turning keyword arguments into json objects, I cannot seem to figure out from looking at examples or consulting the source code how to set the position of the legend.

If I have a figure that I’ve defined using:

let p = plt.figure({tools: tools, x_axis_type: ‘datetime’,
plot_width: plot_width, plot_height: plot_height, sizing_mode: ‘scale_width’,
background_fill_color: bg_fill});


if I then try:

p.legend.location = ‘top_left’;


I get the error “TypeError: p.legend is undefined”. Also, what would be the javascript equivalent of the following python snippet?

p.yaxis[0].formatter = bokeh.models.NumeralTickFormatter(format="$0")