Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>Complete Example</title>
- <script
- type="text/javascript"
- src="https://cdn.pydata.org/bokeh/release/bokeh-1.3.4.min.js"
- ></script>
- <script
- type="text/javascript"
- src="https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.3.4.min.js"
- ></script>
- <script
- type="text/javascript"
- src="https://cdn.pydata.org/bokeh/release/bokeh-tables-1.3.4.min.js"
- ></script>
- <script
- type="text/javascript"
- src="https://cdn.pydata.org/bokeh/release/bokeh-gl-1.3.4.min.js"
- ></script>
- <script
- type="text/javascript"
- src="https://cdn.pydata.org/bokeh/release/bokeh-api-1.3.4.min.js"
- ></script>
- <script>
- //The order of CSS and JS imports above is important.
- </script>
- <script>
- // arrays to hold data
- const source = new Bokeh.ColumnDataSource({
- data: { x: [1, 2, 3], y: [1, 2, 1] }
- });
- // make the plot and add some tools
- const tools = "pan,crosshair,wheel_zoom,box_zoom,reset,save";
- const plot = Bokeh.Plotting.figure({
- title: "Example of Random data",
- tools: tools,
- height: 300,
- width: 300
- });
- const scatterData = plot.line(
- { field: "x" },
- { field: "y" },
- {
- source: source,
- line_width: 2
- }
- );
- // Show the plot, appending it to the end of the current
- // section of the document we are in.
- Bokeh.Plotting.show(plot);
- function addPoint() {
- // The data can be added, but generally all fields must be the
- // same length.
- source.data.x.push(Math.random());
- source.data.y.push(Math.random());
- // Also, the DataSource object must be notified when it has changed.
- source.change.emit();
- }
- const addDataButton = document.createElement("Button");
- addDataButton.appendChild(document.createTextNode("Add Some Data!!!"));
- document.currentScript.parentElement.appendChild(addDataButton);
- addDataButton.addEventListener("click", addPoint);
- </script>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement