You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expand on the BokehJS Minimal Example by adding the following to the end of the script, after the two calls to addPoint(); :
function addTitle() {
// add [new title]
console.log(plot.title)
plot.title = plot.title+'1';
console.log(plot.title)
// notify the [plot object] of "in-place" changes
// after initial failures, tried calling plot.change.emit() thinking to mimic
// the source.change.emit() used for updating ColumnDataSource
plot.change.emit()
}
var addDataButton2 = document.createElement("Button");
addDataButton2.appendChild(document.createTextNode("Add Some Text!!!"));
document.currentScript.parentElement.appendChild(addDataButton2);
addDataButton2.addEventListener("click", addTitle);
Plot titles are objects, not simple strings. You have to change plot.title.text = "new title" (in fact this is exactly what was demonstrated in the links above). As a gentle suggestion, please consider visiting the community support forums first in cases where it is not 100% certain something is a bug. If something is determined to be a bug we will recommend opening an issue with details.
The title certainly behaves as an object in Python, where I can change plot.title.text = "new title" without issue. However, I'm trying to do this with BokehJS alone, where I get that var plot = Bokeh.Plotting.figure(title="some title") yields:
@oviquezr evidently the JS side handles plain string init differently from the python side. You will need to initialize with a title object. This works for me in the fiddle:
title: new Bokeh.Title({text:"A test line plot"}),
including an update in a callback with p.title.text = ...
As this is really a usage question I ask that any further discussion happen on the discourse, and not here on the tracker.
Version info
bokeh-*-2.2.3.js, including bokeh-api
Description of expected behavior and the observed behavior
plot.title = "new title"
fails to update rendered titleplot.title_location
doesn't move title as expected (see caveat)A caveat to these two behaviors:
plot.width = <new width>
to resize the plot.Self-contained example code
Relates to:
Expand on the BokehJS Minimal Example by adding the following to the end of the script, after the two calls to
addPoint();
:Stack traceback and/or browser JavaScript console output
Pressing the button to change the title logs the following to console:
The text was updated successfully, but these errors were encountered: