figure() %>% ly_points(1:10) %>%
tool_lasso_select()
Created
June 30, 2016 05:53
-
-
Save hafen/ba9090f1ece15f6fa8f265f712f21781 to your computer and use it in GitHub Desktop.
adding non-default tools (e.g. lasso select)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: none | |
height: 520 | |
scrolling: no | |
border: yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdn.pydata.org/bokeh/release/bokeh-0.11.1.min.js"></script> | |
<link href="https://cdn.pydata.org/bokeh/release/bokeh-0.11.1.min.css" rel="stylesheet"> | |
</head> | |
<body> | |
<div id="09a4ff67004a582766a4c8b0c78e30ec" class="plotdiv"></div> | |
<script type="text/javascript"> | |
Bokeh.$(function() { | |
var modelid = "49350757fbe538139f43ebc4df2fc7b8"; | |
var elementid = "09a4ff67004a582766a4c8b0c78e30ec"; | |
var docid = "202c198e14dc75fde91ed68036026438"; | |
var docs_json = {"202c198e14dc75fde91ed68036026438":{"version":"0.11.1","title":"Bokeh Figure","roots":{"root_ids":["49350757fbe538139f43ebc4df2fc7b8"],"references":[{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","attributes":{"title":null,"id":"49350757fbe538139f43ebc4df2fc7b8","plot_width":470,"plot_height":474,"x_range":{"type":"Range1d","id":"d293857398381a1e56049b3fa79624b4"},"y_range":{"type":"Range1d","id":"045127c8d9e22e40f07b59459322f232"},"left":[{"type":"LinearAxis","id":"0deb3ca1a44c0358ebd44dcc3b2169a7"}],"below":[{"type":"LinearAxis","id":"459c769281a86b4bf95db0b36b47631a"}],"right":[],"above":[],"renderers":[{"type":"BoxAnnotation","id":"83eae8f617a07ca3b7eb0caad992364b"},{"type":"GlyphRenderer","id":"91d65a78e910298bf7d67a95d0197ea8"},{"type":"PolyAnnotation","id":"32df957db7316e635f1c15f3b6df8dba"},{"type":"LinearAxis","id":"459c769281a86b4bf95db0b36b47631a"},{"type":"Grid","id":"9af24b5fc2387b2afd76b342876c52af"},{"type":"LinearAxis","id":"0deb3ca1a44c0358ebd44dcc3b2169a7"},{"type":"Grid","id":"42437f13d4fe12e452aef7725df9f891"}],"tools":[{"type":"PanTool","id":"6082a6983bc638c0883d1bd76b072d29"},{"type":"WheelZoomTool","id":"b22b3e2fb014b6cb09bccca0e7e22057"},{"type":"BoxZoomTool","id":"184c4700715682a75c4c195eb476183d"},{"type":"ResizeTool","id":"01819048c59d36db1005a446a6c5a746"},{"type":"ResetTool","id":"02003bbc67a534d101ec46bc12e8f125"},{"type":"PreviewSaveTool","id":"45e45f6b0718cfb8a88c27afdd488b62"},{"type":"HelpTool","id":"ad6ad019a4b163d5f2756f0d85ab7a1a"},{"type":"LassoSelectTool","id":"f4914c336dd850e579f30728f1ec3e70"}],"tool_events":{"type":"ToolEvents","id":"94bef67ca1ddaa0e94823f027490f72f"},"extra_y_ranges":{},"extra_x_ranges":{},"tags":[],"doc":null,"min_border_left":4,"min_border_right":4,"min_border_top":4,"min_border_bottom":4,"lod_threshold":null},"subtype":"Figure"},{"type":"PanTool","id":"6082a6983bc638c0883d1bd76b072d29","attributes":{"id":"6082a6983bc638c0883d1bd76b072d29","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"dimensions":["width","height"]}},{"type":"ToolEvents","id":"94bef67ca1ddaa0e94823f027490f72f","attributes":{"id":"94bef67ca1ddaa0e94823f027490f72f","tags":[],"doc":null},"geometries":[]},{"type":"WheelZoomTool","id":"b22b3e2fb014b6cb09bccca0e7e22057","attributes":{"id":"b22b3e2fb014b6cb09bccca0e7e22057","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"dimensions":["width","height"]}},{"type":"BoxAnnotation","id":"83eae8f617a07ca3b7eb0caad992364b","attributes":{"id":"83eae8f617a07ca3b7eb0caad992364b","tags":[],"doc":null,"line_color":{"units":"data","value":"black"},"line_alpha":{"units":"data","value":1},"fill_color":{"units":"data","value":"lightgrey"},"fill_alpha":{"units":"data","value":0.5},"line_dash":[4,4],"line_width":{"units":"data","value":2},"level":"overlay","top_units":"screen","bottom_units":"screen","left_units":"screen","right_units":"screen","render_mode":"css"}},{"type":"BoxZoomTool","id":"184c4700715682a75c4c195eb476183d","attributes":{"id":"184c4700715682a75c4c195eb476183d","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"overlay":{"type":"BoxAnnotation","id":"83eae8f617a07ca3b7eb0caad992364b"}}},{"type":"ResizeTool","id":"01819048c59d36db1005a446a6c5a746","attributes":{"id":"01819048c59d36db1005a446a6c5a746","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"}}},{"type":"ResetTool","id":"02003bbc67a534d101ec46bc12e8f125","attributes":{"id":"02003bbc67a534d101ec46bc12e8f125","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"}}},{"type":"PreviewSaveTool","id":"45e45f6b0718cfb8a88c27afdd488b62","attributes":{"id":"45e45f6b0718cfb8a88c27afdd488b62","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"}}},{"type":"HelpTool","id":"ad6ad019a4b163d5f2756f0d85ab7a1a","attributes":{"id":"ad6ad019a4b163d5f2756f0d85ab7a1a","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"redirect":["http://hafen.github.io/rbokeh"],"help_tooltip":["Click to learn more about rbokeh."]}},{"type":"ColumnDataSource","id":"e4cdb865df74948a3abd7055ea4fd42e","attributes":{"id":"e4cdb865df74948a3abd7055ea4fd42e","tags":[],"doc":null,"column_names":["x","y"],"selected":[],"discrete_ranges":{},"cont_ranges":{},"data":{"x":[1,2,3,4,5,6,7,8,9,10],"y":[1,2,3,4,5,6,7,8,9,10]}}},{"type":"Circle","id":"6f0ce7ae831e9104893e62a950cfdc41","attributes":{"id":"6f0ce7ae831e9104893e62a950cfdc41","tags":[],"doc":null,"size":{"units":"screen","value":10},"visible":true,"line_color":{"units":"data","value":"#1F77B4"},"fill_color":{"units":"data","value":"#1F77B4"},"line_alpha":{"units":"data","value":1},"fill_alpha":{"units":"data","value":0.5},"x":{"units":"data","field":"x"},"y":{"units":"data","field":"y"}}},{"type":"Circle","id":"5ff7bc3bbda234e888e7edfdd35efd15","attributes":{"id":"5ff7bc3bbda234e888e7edfdd35efd15","tags":[],"doc":null,"size":{"units":"screen","value":10},"visible":true,"line_color":{"units":"data","value":"#e1e1e1"},"fill_color":{"units":"data","value":"#e1e1e1"},"line_alpha":{"units":"data","value":1},"fill_alpha":{"units":"data","value":0.5},"x":{"units":"data","field":"x"},"y":{"units":"data","field":"y"}}},{"type":"Circle","id":"224e392fda1c94d5f134a55e72adadad","attributes":{"id":"224e392fda1c94d5f134a55e72adadad","tags":[],"doc":null,"size":{"units":"screen","value":10},"visible":true,"line_color":{"units":"data","value":"#1F77B4"},"fill_color":{"units":"data","value":"#1F77B4"},"line_alpha":{"units":"data","value":1},"fill_alpha":{"units":"data","value":1},"x":{"units":"data","field":"x"},"y":{"units":"data","field":"y"}}},{"type":"GlyphRenderer","id":"91d65a78e910298bf7d67a95d0197ea8","attributes":{"id":"91d65a78e910298bf7d67a95d0197ea8","tags":[],"doc":null,"selection_glyph":null,"nonselection_glyph":{"type":"Circle","id":"5ff7bc3bbda234e888e7edfdd35efd15"},"hover_glyph":{"type":"Circle","id":"224e392fda1c94d5f134a55e72adadad"},"server_data_source":null,"name":null,"data_source":{"type":"ColumnDataSource","id":"e4cdb865df74948a3abd7055ea4fd42e"},"glyph":{"type":"Circle","id":"6f0ce7ae831e9104893e62a950cfdc41"}}},{"type":"PolyAnnotation","id":"32df957db7316e635f1c15f3b6df8dba","attributes":{"id":"32df957db7316e635f1c15f3b6df8dba","tags":[],"doc":null,"line_color":{"units":"data","value":"black"},"line_alpha":{"units":"data","value":1},"fill_color":{"units":"data","value":"lightgrey"},"fill_alpha":{"units":"data","value":0.5},"line_dash":[4,4],"line_width":{"units":"data","value":2},"level":"overlay","xs_units":"screen","ys_units":"screen"}},{"type":"LassoSelectTool","id":"f4914c336dd850e579f30728f1ec3e70","attributes":{"id":"f4914c336dd850e579f30728f1ec3e70","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"overlay":{"type":"PolyAnnotation","id":"32df957db7316e635f1c15f3b6df8dba"}}},{"type":"Range1d","id":"d293857398381a1e56049b3fa79624b4","attributes":{"id":"d293857398381a1e56049b3fa79624b4","tags":[],"doc":null,"start":0.37,"end":10.63}},{"type":"Range1d","id":"045127c8d9e22e40f07b59459322f232","attributes":{"id":"045127c8d9e22e40f07b59459322f232","tags":[],"doc":null,"start":0.37,"end":10.63}},{"type":"LinearAxis","id":"459c769281a86b4bf95db0b36b47631a","attributes":{"id":"459c769281a86b4bf95db0b36b47631a","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"axis_label":"index","formatter":{"type":"BasicTickFormatter","id":"bf923b405a07e2f045b2a169a356a126"},"ticker":{"type":"BasicTicker","id":"d1235a9416b6ff58e569e09063b702bb"},"visible":true,"axis_label_text_font_size":"12pt"}},{"type":"BasicTickFormatter","id":"bf923b405a07e2f045b2a169a356a126","attributes":{"id":"bf923b405a07e2f045b2a169a356a126","tags":[],"doc":null}},{"type":"BasicTicker","id":"d1235a9416b6ff58e569e09063b702bb","attributes":{"id":"d1235a9416b6ff58e569e09063b702bb","tags":[],"doc":null,"num_minor_ticks":5}},{"type":"Grid","id":"9af24b5fc2387b2afd76b342876c52af","attributes":{"id":"9af24b5fc2387b2afd76b342876c52af","tags":[],"doc":null,"dimension":0,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"ticker":{"type":"BasicTicker","id":"d1235a9416b6ff58e569e09063b702bb"}}},{"type":"LinearAxis","id":"0deb3ca1a44c0358ebd44dcc3b2169a7","attributes":{"id":"0deb3ca1a44c0358ebd44dcc3b2169a7","tags":[],"doc":null,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"axis_label":"1:10","formatter":{"type":"BasicTickFormatter","id":"3eb9627dfca756b112fd87a43bc83ce0"},"ticker":{"type":"BasicTicker","id":"a2ee28d187a532305a614e303638496a"},"visible":true,"axis_label_text_font_size":"12pt"}},{"type":"BasicTickFormatter","id":"3eb9627dfca756b112fd87a43bc83ce0","attributes":{"id":"3eb9627dfca756b112fd87a43bc83ce0","tags":[],"doc":null}},{"type":"BasicTicker","id":"a2ee28d187a532305a614e303638496a","attributes":{"id":"a2ee28d187a532305a614e303638496a","tags":[],"doc":null,"num_minor_ticks":5}},{"type":"Grid","id":"42437f13d4fe12e452aef7725df9f891","attributes":{"id":"42437f13d4fe12e452aef7725df9f891","tags":[],"doc":null,"dimension":1,"plot":{"type":"Plot","id":"49350757fbe538139f43ebc4df2fc7b8","subtype":"Figure"},"ticker":{"type":"BasicTicker","id":"a2ee28d187a532305a614e303638496a"}}}]}}}; | |
var refkey = Object.keys(docs_json)[0] | |
var refs = docs_json[refkey].roots.references | |
function traverseObject(obj) { | |
for(var key in obj) { | |
if(obj[key].constructor === Object) { | |
traverseObject(obj[key]); | |
} else if(obj[key].constructor === Array) { | |
for (var i = 0; i < obj[key].length; i++) { | |
if(obj[key][i] === null) | |
obj[key][i] = NaN; | |
}; | |
} | |
}; | |
} | |
for(var i = 0; i < refs.length; i++) { | |
if(refs[i].type === "ColumnDataSource") | |
traverseObject(refs[i].attributes.data); | |
}; | |
var render_items = [{ | |
"docid": docid, | |
"elementid": elementid, | |
"modelid": modelid | |
}]; | |
Bokeh.set_log_level('info'); | |
Bokeh.embed.embed_items(docs_json, render_items); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment