Created
March 1, 2018 04:57
-
-
Save ruoyu0088/01ddf28ed041508304843f49a794d66a to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"import datetime as dt\n", | |
"from itertools import cycle, islice\n", | |
"\n", | |
"N = 24\n", | |
"start_date = dt.date(2016,1,1)\n", | |
"nbdays = int(365 / N)\n", | |
"\n", | |
"df = pd.DataFrame({'Date': [start_date + dt.timedelta(days=i*nbdays) for i in range(1,N+1)], \n", | |
" 'Rating': [(100/N)*i for i in range(1,N+1)], \n", | |
" 'Plot': list(islice(cycle(range(1, 9)), 0, N)), \n", | |
" 'Treatment': list(islice(cycle(range(1, 7)), 0, N)), \n", | |
" 'Trial': list(islice(cycle(range(1, 4)), 0, N)), \n", | |
" 'Name': list(islice(cycle(\"ABCDEF\"), 0, N)), \n", | |
" 'Target': list(islice(cycle(\"JKLMNOP\"), 0, N)), \n", | |
" 'Part': list(islice(cycle(\"WXYZ\"), 0, N)) \n", | |
" })" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" <div class=\"bk-root\">\n", | |
" <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n", | |
" <span id=\"1a23ca63-5575-44a5-a7a5-cde504468bda\">Loading BokehJS ...</span>\n", | |
" </div>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"application/javascript": [ | |
"\n", | |
"(function(root) {\n", | |
" function now() {\n", | |
" return new Date();\n", | |
" }\n", | |
"\n", | |
" var force = true;\n", | |
"\n", | |
" if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", | |
" root._bokeh_onload_callbacks = [];\n", | |
" root._bokeh_is_loading = undefined;\n", | |
" }\n", | |
"\n", | |
" var JS_MIME_TYPE = 'application/javascript';\n", | |
" var HTML_MIME_TYPE = 'text/html';\n", | |
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", | |
" var CLASS_NAME = 'output_bokeh rendered_html';\n", | |
"\n", | |
" /**\n", | |
" * Render data to the DOM node\n", | |
" */\n", | |
" function render(props, node) {\n", | |
" var script = document.createElement(\"script\");\n", | |
" node.appendChild(script);\n", | |
" }\n", | |
"\n", | |
" /**\n", | |
" * Handle when an output is cleared or removed\n", | |
" */\n", | |
" function handleClearOutput(event, handle) {\n", | |
" var cell = handle.cell;\n", | |
"\n", | |
" var id = cell.output_area._bokeh_element_id;\n", | |
" var server_id = cell.output_area._bokeh_server_id;\n", | |
" // Clean up Bokeh references\n", | |
" if (id !== undefined) {\n", | |
" Bokeh.index[id].model.document.clear();\n", | |
" delete Bokeh.index[id];\n", | |
" }\n", | |
"\n", | |
" if (server_id !== undefined) {\n", | |
" // Clean up Bokeh references\n", | |
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", | |
" cell.notebook.kernel.execute(cmd, {\n", | |
" iopub: {\n", | |
" output: function(msg) {\n", | |
" var element_id = msg.content.text.trim();\n", | |
" Bokeh.index[element_id].model.document.clear();\n", | |
" delete Bokeh.index[element_id];\n", | |
" }\n", | |
" }\n", | |
" });\n", | |
" // Destroy server and session\n", | |
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", | |
" cell.notebook.kernel.execute(cmd);\n", | |
" }\n", | |
" }\n", | |
"\n", | |
" /**\n", | |
" * Handle when a new output is added\n", | |
" */\n", | |
" function handleAddOutput(event, handle) {\n", | |
" var output_area = handle.output_area;\n", | |
" var output = handle.output;\n", | |
"\n", | |
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", | |
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", | |
" return\n", | |
" }\n", | |
"\n", | |
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", | |
"\n", | |
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", | |
" toinsert[0].firstChild.textContent = output.data[JS_MIME_TYPE];\n", | |
" // store reference to embed id on output_area\n", | |
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", | |
" }\n", | |
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", | |
" var bk_div = document.createElement(\"div\");\n", | |
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", | |
" var script_attrs = bk_div.children[0].attributes;\n", | |
" for (var i = 0; i < script_attrs.length; i++) {\n", | |
" toinsert[0].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", | |
" }\n", | |
" // store reference to server id on output_area\n", | |
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", | |
" }\n", | |
" }\n", | |
"\n", | |
" function register_renderer(events, OutputArea) {\n", | |
"\n", | |
" function append_mime(data, metadata, element) {\n", | |
" // create a DOM node to render to\n", | |
" var toinsert = this.create_output_subarea(\n", | |
" metadata,\n", | |
" CLASS_NAME,\n", | |
" EXEC_MIME_TYPE\n", | |
" );\n", | |
" this.keyboard_manager.register_events(toinsert);\n", | |
" // Render to node\n", | |
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", | |
" render(props, toinsert[0]);\n", | |
" element.append(toinsert);\n", | |
" return toinsert\n", | |
" }\n", | |
"\n", | |
" /* Handle when an output is cleared or removed */\n", | |
" events.on('clear_output.CodeCell', handleClearOutput);\n", | |
" events.on('delete.Cell', handleClearOutput);\n", | |
"\n", | |
" /* Handle when a new output is added */\n", | |
" events.on('output_added.OutputArea', handleAddOutput);\n", | |
"\n", | |
" /**\n", | |
" * Register the mime type and append_mime function with output_area\n", | |
" */\n", | |
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", | |
" /* Is output safe? */\n", | |
" safe: true,\n", | |
" /* Index of renderer in `output_area.display_order` */\n", | |
" index: 0\n", | |
" });\n", | |
" }\n", | |
"\n", | |
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n", | |
" if (root.Jupyter !== undefined) {\n", | |
" var events = require('base/js/events');\n", | |
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n", | |
"\n", | |
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", | |
" register_renderer(events, OutputArea);\n", | |
" }\n", | |
" }\n", | |
"\n", | |
" \n", | |
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", | |
" root._bokeh_timeout = Date.now() + 5000;\n", | |
" root._bokeh_failed_load = false;\n", | |
" }\n", | |
"\n", | |
" var NB_LOAD_WARNING = {'data': {'text/html':\n", | |
" \"<div style='background-color: #fdd'>\\n\"+\n", | |
" \"<p>\\n\"+\n", | |
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", | |
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", | |
" \"</p>\\n\"+\n", | |
" \"<ul>\\n\"+\n", | |
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n", | |
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n", | |
" \"</ul>\\n\"+\n", | |
" \"<code>\\n\"+\n", | |
" \"from bokeh.resources import INLINE\\n\"+\n", | |
" \"output_notebook(resources=INLINE)\\n\"+\n", | |
" \"</code>\\n\"+\n", | |
" \"</div>\"}};\n", | |
"\n", | |
" function display_loaded() {\n", | |
" var el = document.getElementById(\"1a23ca63-5575-44a5-a7a5-cde504468bda\");\n", | |
" if (el != null) {\n", | |
" el.textContent = \"BokehJS is loading...\";\n", | |
" }\n", | |
" if (root.Bokeh !== undefined) {\n", | |
" if (el != null) {\n", | |
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n", | |
" }\n", | |
" } else if (Date.now() < root._bokeh_timeout) {\n", | |
" setTimeout(display_loaded, 100)\n", | |
" }\n", | |
" }\n", | |
"\n", | |
"\n", | |
" function run_callbacks() {\n", | |
" try {\n", | |
" root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", | |
" }\n", | |
" finally {\n", | |
" delete root._bokeh_onload_callbacks\n", | |
" }\n", | |
" console.info(\"Bokeh: all callbacks have finished\");\n", | |
" }\n", | |
"\n", | |
" function load_libs(js_urls, callback) {\n", | |
" root._bokeh_onload_callbacks.push(callback);\n", | |
" if (root._bokeh_is_loading > 0) {\n", | |
" console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", | |
" return null;\n", | |
" }\n", | |
" if (js_urls == null || js_urls.length === 0) {\n", | |
" run_callbacks();\n", | |
" return null;\n", | |
" }\n", | |
" console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", | |
" root._bokeh_is_loading = js_urls.length;\n", | |
" for (var i = 0; i < js_urls.length; i++) {\n", | |
" var url = js_urls[i];\n", | |
" var s = document.createElement('script');\n", | |
" s.src = url;\n", | |
" s.async = false;\n", | |
" s.onreadystatechange = s.onload = function() {\n", | |
" root._bokeh_is_loading--;\n", | |
" if (root._bokeh_is_loading === 0) {\n", | |
" console.log(\"Bokeh: all BokehJS libraries loaded\");\n", | |
" run_callbacks()\n", | |
" }\n", | |
" };\n", | |
" s.onerror = function() {\n", | |
" console.warn(\"failed to load library \" + url);\n", | |
" };\n", | |
" console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", | |
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n", | |
" }\n", | |
" };var element = document.getElementById(\"1a23ca63-5575-44a5-a7a5-cde504468bda\");\n", | |
" if (element == null) {\n", | |
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1a23ca63-5575-44a5-a7a5-cde504468bda' but no matching script tag was found. \")\n", | |
" return false;\n", | |
" }\n", | |
"\n", | |
" var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.13.min.js\"];\n", | |
"\n", | |
" var inline_js = [\n", | |
" function(Bokeh) {\n", | |
" Bokeh.set_log_level(\"info\");\n", | |
" },\n", | |
" \n", | |
" function(Bokeh) {\n", | |
" \n", | |
" },\n", | |
" function(Bokeh) {\n", | |
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n", | |
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n", | |
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n", | |
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n", | |
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n", | |
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n", | |
" }\n", | |
" ];\n", | |
"\n", | |
" function run_inline_js() {\n", | |
" \n", | |
" if ((root.Bokeh !== undefined) || (force === true)) {\n", | |
" for (var i = 0; i < inline_js.length; i++) {\n", | |
" inline_js[i].call(root, root.Bokeh);\n", | |
" }if (force === true) {\n", | |
" display_loaded();\n", | |
" }} else if (Date.now() < root._bokeh_timeout) {\n", | |
" setTimeout(run_inline_js, 100);\n", | |
" } else if (!root._bokeh_failed_load) {\n", | |
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", | |
" root._bokeh_failed_load = true;\n", | |
" } else if (force !== true) {\n", | |
" var cell = $(document.getElementById(\"1a23ca63-5575-44a5-a7a5-cde504468bda\")).parents('.cell').data().cell;\n", | |
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", | |
" }\n", | |
"\n", | |
" }\n", | |
"\n", | |
" if (root._bokeh_is_loading === 0) {\n", | |
" console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", | |
" run_inline_js();\n", | |
" } else {\n", | |
" load_libs(js_urls, function() {\n", | |
" console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n", | |
" run_inline_js();\n", | |
" });\n", | |
" }\n", | |
"}(window));" | |
], | |
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"1a23ca63-5575-44a5-a7a5-cde504468bda\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = js_urls.length;\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var s = document.createElement('script');\n s.src = url;\n s.async = false;\n s.onreadystatechange = s.onload = function() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: all BokehJS libraries loaded\");\n run_callbacks()\n }\n };\n s.onerror = function() {\n console.warn(\"failed to load library \" + url);\n };\n console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.getElementsByTagName(\"head\")[0].appendChild(s);\n }\n };var element = document.getElementById(\"1a23ca63-5575-44a5-a7a5-cde504468bda\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1a23ca63-5575-44a5-a7a5-cde504468bda' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.13.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"1a23ca63-5575-44a5-a7a5-cde504468bda\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(js_urls, function() {\n console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"from bokeh.io import show, output_notebook\n", | |
"output_notebook()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
"<div class=\"bk-root\">\n", | |
" <div class=\"bk-plotdiv\" id=\"a9afe308-d62c-4ca3-b91c-810ce859d49d\"></div>\n", | |
"</div>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"application/javascript": [ | |
"(function(root) {\n", | |
" function embed_document(root) {\n", | |
" \n", | |
" var docs_json = {\"60b85d96-3f98-416a-a3e4-14a7b7da379f\":{\"roots\":{\"references\":[{\"attributes\":{\"source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"}},\"id\":\"318e8c4c-3459-4e41-8443-708ba141b3a0\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_color\":{\"value\":\"#e41a1c\"},\"line_color\":{\"value\":\"#e41a1c\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"706814e8-9bca-463b-b15a-a14bd1fe4a4d\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"f583e61e-2d57-442e-9b00-e61d57afcd71\",\"type\":\"BasicTicker\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"2f68ddf6-3ce6-4261-930a-9cd6930864e6\",\"type\":\"Circle\"},{\"attributes\":{\"fill_color\":{\"value\":\"#377eb8\"},\"line_color\":{\"value\":\"#377eb8\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"9afc0e3e-9b72-4e9b-a776-aacfae646820\",\"type\":\"Circle\"},{\"attributes\":{\"plot\":{\"id\":\"f8e30f51-5ded-411d-aa0f-ad2d4afa1de7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"9d0fc0e8-3d33-4a9d-9055-b547d92380c0\",\"type\":\"DatetimeTicker\"}},\"id\":\"690379a5-881d-4bf7-9790-6fd18395f4c6\",\"type\":\"Grid\"},{\"attributes\":{\"label\":{\"value\":\"Treatment 4\"},\"renderers\":[{\"id\":\"c3fd6c4b-9105-418e-806a-2f60569a5224\",\"type\":\"GlyphRenderer\"}]},\"id\":\"54276c9f-d352-4158-82c8-2e66b4ea782d\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"2d17c8c8-e76f-49e2-8ada-8fe22a7916f5\",\"type\":\"DatetimeTickFormatter\"},{\"attributes\":{\"factors\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"],\"palette\":[\"#e41a1c\",\"#377eb8\",\"#4daf4a\",\"#984ea3\",\"#ff7f00\",\"#ffff33\",\"#a65628\",\"#f781bf\",\"#999999\"]},\"id\":\"849d37d2-4c3b-48ff-bab1-d21edae41c05\",\"type\":\"CategoricalColorMapper\"},{\"attributes\":{\"data_source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"3bd4718c-a105-405f-8a9a-62f220b38872\",\"type\":\"Circle\"},\"hover_glyph\":null,\"js_property_callbacks\":{\"change:visible\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"3d61f0f1-e7e2-43c0-a688-f5821cbe974e\",\"type\":\"Circle\"},\"selection_glyph\":null,\"tags\":[\"3\"],\"view\":{\"id\":\"36c0f5e2-7f18-42dc-97ac-11798b7b895b\",\"type\":\"CDSView\"}},\"id\":\"7f048217-9418-4b38-9f5e-b89e82af28f9\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"callback\":null},\"id\":\"ed53e2c0-4c48-423b-bc40-9c29172ba902\",\"type\":\"DataRange1d\"},{\"attributes\":{\"months\":[0,4,8]},\"id\":\"24a54593-e22b-4d69-b146-45770176dbe0\",\"type\":\"MonthsTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"f8e30f51-5ded-411d-aa0f-ad2d4afa1de7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"f583e61e-2d57-442e-9b00-e61d57afcd71\",\"type\":\"BasicTicker\"}},\"id\":\"00f751cd-c229-4f80-8b96-6988826526ef\",\"type\":\"Grid\"},{\"attributes\":{\"days\":[1,15]},\"id\":\"bac53a3d-a755-48b2-9daa-261fe00f7881\",\"type\":\"DaysTicker\"},{\"attributes\":{\"children\":[{\"id\":\"e1b213c1-cb07-4a30-92f9-cd212ecad1c2\",\"type\":\"Row\"}]},\"id\":\"77369dff-743e-4a5d-a8a4-8a2e57e47dba\",\"type\":\"Column\"},{\"attributes\":{\"fill_color\":{\"value\":\"#ff7f00\"},\"line_color\":{\"value\":\"#ff7f00\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"9afe1872-5c8a-4332-a2c9-8721c00e9af9\",\"type\":\"Circle\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"3d61f0f1-e7e2-43c0-a688-f5821cbe974e\",\"type\":\"Circle\"},{\"attributes\":{\"label\":{\"value\":\"Treatment 5\"},\"renderers\":[{\"id\":\"ee6f793a-2102-408d-9cf7-f6595fcdc50f\",\"type\":\"GlyphRenderer\"}]},\"id\":\"c27a6785-fb6e-4677-aec4-04d5ba81a17c\",\"type\":\"LegendItem\"},{\"attributes\":{\"data_source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"706814e8-9bca-463b-b15a-a14bd1fe4a4d\",\"type\":\"Circle\"},\"hover_glyph\":null,\"js_property_callbacks\":{\"change:visible\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"4d440b35-e1d8-4247-823f-38d85cacef0d\",\"type\":\"Circle\"},\"selection_glyph\":null,\"tags\":[\"1\"],\"view\":{\"id\":\"155e83f4-b408-4cbc-94ae-a4cedb891883\",\"type\":\"CDSView\"}},\"id\":\"aaa2c40a-e1bb-427f-bbdd-accfb5530358\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data_source\":{\"id\":\"b0bd9cbc-8e96-4b5f-b0c7-3c793a0fe38d\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"decb2476-214c-4a81-936e-8a5681acfacd\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"fb0156c8-984e-4d76-ad1e-cee11650a911\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"bb5fb811-a187-4ecc-b5f8-bd49e285e517\",\"type\":\"CDSView\"}},\"id\":\"b55aba79-5712-470c-ab4d-69b2c77a1b0f\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"}},\"id\":\"e2599cf0-14f8-4e20-a4c3-a400eb5c0599\",\"type\":\"CDSView\"},{\"attributes\":{\"active\":[0,1,2],\"callback\":null,\"js_property_callbacks\":{\"change:active\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"labels\":[\"1\",\"2\",\"3\"],\"tags\":[\"Trial\"]},\"id\":\"448c4657-735f-4da4-a63d-2eb41962c95c\",\"type\":\"CheckboxButtonGroup\"},{\"attributes\":{\"num_minor_ticks\":5,\"tickers\":[{\"id\":\"123bc08a-0747-420a-800a-c8fa4c78ba35\",\"type\":\"AdaptiveTicker\"},{\"id\":\"55250a97-4064-406b-83f0-bbca0e3bdb78\",\"type\":\"AdaptiveTicker\"},{\"id\":\"ac240ec2-7a22-4f9f-bdc0-23979e4e9311\",\"type\":\"AdaptiveTicker\"},{\"id\":\"f49fd2f5-9fad-40a3-8d7b-65be7b9a1dee\",\"type\":\"DaysTicker\"},{\"id\":\"79ec5c44-8d6c-412f-a475-d4db008211ff\",\"type\":\"DaysTicker\"},{\"id\":\"e53e8677-5e09-4ef3-9bd9-bb9fa1ccdb5a\",\"type\":\"DaysTicker\"},{\"id\":\"bac53a3d-a755-48b2-9daa-261fe00f7881\",\"type\":\"DaysTicker\"},{\"id\":\"4729a586-d7bc-4301-8648-592660f6dda2\",\"type\":\"MonthsTicker\"},{\"id\":\"1219b0e8-4725-4da3-95a6-da20ebc2c2d7\",\"type\":\"MonthsTicker\"},{\"id\":\"24a54593-e22b-4d69-b146-45770176dbe0\",\"type\":\"MonthsTicker\"},{\"id\":\"7a5967e2-60bd-4746-8e00-6e0681b6dd60\",\"type\":\"MonthsTicker\"},{\"id\":\"adaacca1-55f9-407d-ae72-85e6bacd81a6\",\"type\":\"YearsTicker\"}]},\"id\":\"9d0fc0e8-3d33-4a9d-9055-b547d92380c0\",\"type\":\"DatetimeTicker\"},{\"attributes\":{\"source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"}},\"id\":\"d3224ef1-4e09-4c3b-ad0d-54d12e4d7d91\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"09a860b6-a9c6-4687-986d-fd9b0c714370\",\"type\":\"Circle\"},\"hover_glyph\":null,\"js_property_callbacks\":{\"change:visible\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"50334b6a-03e8-4634-ab9a-21abb40e6c12\",\"type\":\"Circle\"},\"selection_glyph\":null,\"tags\":[\"6\"],\"view\":{\"id\":\"d3224ef1-4e09-4c3b-ad0d-54d12e4d7d91\",\"type\":\"CDSView\"}},\"id\":\"a3c93c47-1a1a-4946-b60e-84700aa596d2\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"fill_color\":{\"value\":\"#984ea3\"},\"line_color\":{\"value\":\"#984ea3\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"10cece0d-621d-4488-880f-97d0286f2e24\",\"type\":\"Circle\"},{\"attributes\":{\"data_source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"9afc0e3e-9b72-4e9b-a776-aacfae646820\",\"type\":\"Circle\"},\"hover_glyph\":null,\"js_property_callbacks\":{\"change:visible\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2f68ddf6-3ce6-4261-930a-9cd6930864e6\",\"type\":\"Circle\"},\"selection_glyph\":null,\"tags\":[\"2\"],\"view\":{\"id\":\"d50a76d2-bd31-4bf6-8845-f029ce4f35f5\",\"type\":\"CDSView\"}},\"id\":\"13df2626-669b-45c8-90b4-58428d93b64a\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"194f815c-51b4-4e74-9057-7421d44a3214\",\"type\":\"Title\"},{\"attributes\":{\"label\":{\"value\":\"Treatment 1\"},\"renderers\":[{\"id\":\"aaa2c40a-e1bb-427f-bbdd-accfb5530358\",\"type\":\"GlyphRenderer\"}]},\"id\":\"b3fbd48c-58df-4f6a-8055-d693d9061780\",\"type\":\"LegendItem\"},{\"attributes\":{\"months\":[0,1,2,3,4,5,6,7,8,9,10,11]},\"id\":\"4729a586-d7bc-4301-8648-592660f6dda2\",\"type\":\"MonthsTicker\"},{\"attributes\":{\"source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"}},\"id\":\"d50a76d2-bd31-4bf6-8845-f029ce4f35f5\",\"type\":\"CDSView\"},{\"attributes\":{\"below\":[{\"id\":\"18a7f34b-e397-436f-a5c3-226422251dd2\",\"type\":\"DatetimeAxis\"}],\"left\":[{\"id\":\"ac69600f-d05e-44d5-9504-5f5a59cf5d0d\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"18a7f34b-e397-436f-a5c3-226422251dd2\",\"type\":\"DatetimeAxis\"},{\"id\":\"690379a5-881d-4bf7-9790-6fd18395f4c6\",\"type\":\"Grid\"},{\"id\":\"ac69600f-d05e-44d5-9504-5f5a59cf5d0d\",\"type\":\"LinearAxis\"},{\"id\":\"00f751cd-c229-4f80-8b96-6988826526ef\",\"type\":\"Grid\"},{\"id\":\"a903dddd-e19e-4a85-950d-f4894c94e020\",\"type\":\"Legend\"},{\"id\":\"aaa2c40a-e1bb-427f-bbdd-accfb5530358\",\"type\":\"GlyphRenderer\"},{\"id\":\"13df2626-669b-45c8-90b4-58428d93b64a\",\"type\":\"GlyphRenderer\"},{\"id\":\"7f048217-9418-4b38-9f5e-b89e82af28f9\",\"type\":\"GlyphRenderer\"},{\"id\":\"c3fd6c4b-9105-418e-806a-2f60569a5224\",\"type\":\"GlyphRenderer\"},{\"id\":\"ee6f793a-2102-408d-9cf7-f6595fcdc50f\",\"type\":\"GlyphRenderer\"},{\"id\":\"a3c93c47-1a1a-4946-b60e-84700aa596d2\",\"type\":\"GlyphRenderer\"},{\"id\":\"b55aba79-5712-470c-ab4d-69b2c77a1b0f\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"194f815c-51b4-4e74-9057-7421d44a3214\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"75714789-6779-48f2-a4b4-2061ed2f194c\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"692b6f98-d371-4946-a6a3-17bfb9c8fa2e\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"dbd93e29-0989-45dc-95e6-33dff316ff52\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"ed53e2c0-4c48-423b-bc40-9c29172ba902\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"9165a802-0310-492d-af5b-d9f08af0706c\",\"type\":\"LinearScale\"}},\"id\":\"f8e30f51-5ded-411d-aa0f-ad2d4afa1de7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"active\":[0,1,2,3,4,5],\"callback\":null,\"js_property_callbacks\":{\"change:active\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"labels\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"],\"tags\":[\"Name\"]},\"id\":\"cb482382-3ed2-42eb-8f99-f1e9d27a738f\",\"type\":\"CheckboxButtonGroup\"},{\"attributes\":{\"source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"}},\"id\":\"155e83f4-b408-4cbc-94ae-a4cedb891883\",\"type\":\"CDSView\"},{\"attributes\":{\"children\":[{\"id\":\"f8e30f51-5ded-411d-aa0f-ad2d4afa1de7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"dab6c294-01ea-42b9-9751-f6ac8fbb83f0\",\"type\":\"WidgetBox\"}]},\"id\":\"e1b213c1-cb07-4a30-92f9-cd212ecad1c2\",\"type\":\"Row\"},{\"attributes\":{\"fill_color\":{\"value\":\"#ffff33\"},\"line_color\":{\"value\":\"#ffff33\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"09a860b6-a9c6-4687-986d-fd9b0c714370\",\"type\":\"Circle\"},{\"attributes\":{\"args\":{\"source\":{\"id\":\"b0bd9cbc-8e96-4b5f-b0c7-3c793a0fe38d\",\"type\":\"ColumnDataSource\"}},\"code\":\"var cb;\\ncb = function (source) {\\n source = (source === undefined) ? source: source;\\n source.change.emit();\\n return null;\\n};\\ncb(source);\\n\"},\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"699015c1-1992-4ead-b34b-c7f90e5106af\",\"type\":\"Circle\"},{\"attributes\":{\"fill_color\":{\"value\":\"#4daf4a\"},\"line_color\":{\"value\":\"#4daf4a\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"3bd4718c-a105-405f-8a9a-62f220b38872\",\"type\":\"Circle\"},{\"attributes\":{\"label\":{\"value\":\"Treatment 3\"},\"renderers\":[{\"id\":\"7f048217-9418-4b38-9f5e-b89e82af28f9\",\"type\":\"GlyphRenderer\"}]},\"id\":\"7ce9d815-4ccc-4b1a-95e4-5bf497f9363a\",\"type\":\"LegendItem\"},{\"attributes\":{\"mantissas\":[1,2,5],\"max_interval\":500.0,\"num_minor_ticks\":0},\"id\":\"123bc08a-0747-420a-800a-c8fa4c78ba35\",\"type\":\"AdaptiveTicker\"},{\"attributes\":{\"months\":[0,6]},\"id\":\"7a5967e2-60bd-4746-8e00-6e0681b6dd60\",\"type\":\"MonthsTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"fded94a4-f0b6-420a-92e2-982b364449ae\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"f8e30f51-5ded-411d-aa0f-ad2d4afa1de7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"f583e61e-2d57-442e-9b00-e61d57afcd71\",\"type\":\"BasicTicker\"}},\"id\":\"ac69600f-d05e-44d5-9504-5f5a59cf5d0d\",\"type\":\"LinearAxis\"},{\"attributes\":{\"active\":[0,1,2,3,4,5,6,7],\"callback\":null,\"js_property_callbacks\":{\"change:active\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"labels\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\"],\"tags\":[\"Plot\"]},\"id\":\"d2d16424-859c-4566-8254-fa9d253b0684\",\"type\":\"CheckboxButtonGroup\"},{\"attributes\":{\"base\":24,\"mantissas\":[1,2,4,6,8,12],\"max_interval\":43200000.0,\"min_interval\":3600000.0,\"num_minor_ticks\":0},\"id\":\"ac240ec2-7a22-4f9f-bdc0-23979e4e9311\",\"type\":\"AdaptiveTicker\"},{\"attributes\":{\"days\":[1,4,7,10,13,16,19,22,25,28]},\"id\":\"79ec5c44-8d6c-412f-a475-d4db008211ff\",\"type\":\"DaysTicker\"},{\"attributes\":{\"click_policy\":\"hide\",\"items\":[{\"id\":\"b3fbd48c-58df-4f6a-8055-d693d9061780\",\"type\":\"LegendItem\"},{\"id\":\"2828e19b-c371-4a2f-8e1d-8c3860f8edef\",\"type\":\"LegendItem\"},{\"id\":\"7ce9d815-4ccc-4b1a-95e4-5bf497f9363a\",\"type\":\"LegendItem\"},{\"id\":\"54276c9f-d352-4158-82c8-2e66b4ea782d\",\"type\":\"LegendItem\"},{\"id\":\"c27a6785-fb6e-4677-aec4-04d5ba81a17c\",\"type\":\"LegendItem\"},{\"id\":\"43e1a222-bb95-49ac-a6e1-b40b4f12ed5b\",\"type\":\"LegendItem\"}],\"location\":\"bottom_right\",\"plot\":{\"id\":\"f8e30f51-5ded-411d-aa0f-ad2d4afa1de7\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"a903dddd-e19e-4a85-950d-f4894c94e020\",\"type\":\"Legend\"},{\"attributes\":{\"label\":{\"value\":\"Treatment 2\"},\"renderers\":[{\"id\":\"13df2626-669b-45c8-90b4-58428d93b64a\",\"type\":\"GlyphRenderer\"}]},\"id\":\"2828e19b-c371-4a2f-8e1d-8c3860f8edef\",\"type\":\"LegendItem\"},{\"attributes\":{\"callback\":null,\"formatters\":{\"Date\":\"datetime\"},\"tooltips\":[[\"Date\",\"@Date{%d/%m/%Y}\"],[\"Plot\",\"@Plot\"],[\"Trial\",\"@Trial\"],[\"Name\",\"@Name\"],[\"Target\",\"@Target\"],[\"Part\",\"@Part\"]]},\"id\":\"585b9816-368f-4574-b9a7-d6bd6188aa35\",\"type\":\"HoverTool\"},{\"attributes\":{\"active\":[0,1,2,3,4,5,6],\"callback\":null,\"js_property_callbacks\":{\"change:active\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"labels\":[\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\"],\"tags\":[\"Target\"]},\"id\":\"fd643fea-013c-499d-9252-714be73d23ec\",\"type\":\"CheckboxButtonGroup\"},{\"attributes\":{},\"id\":\"adaacca1-55f9-407d-ae72-85e6bacd81a6\",\"type\":\"YearsTicker\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[],\"y\":[]}},\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"filters\":[{\"id\":\"91ec0802-9cfb-4ef9-88d7-12308d205c64\",\"type\":\"CustomJSFilter\"}],\"source\":{\"id\":\"b0bd9cbc-8e96-4b5f-b0c7-3c793a0fe38d\",\"type\":\"ColumnDataSource\"}},\"id\":\"bb5fb811-a187-4ecc-b5f8-bd49e285e517\",\"type\":\"CDSView\"},{\"attributes\":{\"source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"}},\"id\":\"36c0f5e2-7f18-42dc-97ac-11798b7b895b\",\"type\":\"CDSView\"},{\"attributes\":{\"active\":[0,1,2,3],\"callback\":null,\"js_property_callbacks\":{\"change:active\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"labels\":[\"W\",\"X\",\"Y\",\"Z\"],\"tags\":[\"Part\"]},\"id\":\"083dcf84-0ee0-482b-9b74-e808361b554c\",\"type\":\"CheckboxButtonGroup\"},{\"attributes\":{\"days\":[1,8,15,22]},\"id\":\"e53e8677-5e09-4ef3-9bd9-bb9fa1ccdb5a\",\"type\":\"DaysTicker\"},{\"attributes\":{\"children\":[{\"id\":\"d2d16424-859c-4566-8254-fa9d253b0684\",\"type\":\"CheckboxButtonGroup\"},{\"id\":\"448c4657-735f-4da4-a63d-2eb41962c95c\",\"type\":\"CheckboxButtonGroup\"},{\"id\":\"cb482382-3ed2-42eb-8f99-f1e9d27a738f\",\"type\":\"CheckboxButtonGroup\"},{\"id\":\"fd643fea-013c-499d-9252-714be73d23ec\",\"type\":\"CheckboxButtonGroup\"},{\"id\":\"083dcf84-0ee0-482b-9b74-e808361b554c\",\"type\":\"CheckboxButtonGroup\"}]},\"id\":\"dab6c294-01ea-42b9-9751-f6ac8fbb83f0\",\"type\":\"WidgetBox\"},{\"attributes\":{},\"id\":\"dbd93e29-0989-45dc-95e6-33dff316ff52\",\"type\":\"LinearScale\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4d440b35-e1d8-4247-823f-38d85cacef0d\",\"type\":\"Circle\"},{\"attributes\":{\"formatter\":{\"id\":\"2d17c8c8-e76f-49e2-8ada-8fe22a7916f5\",\"type\":\"DatetimeTickFormatter\"},\"plot\":{\"id\":\"f8e30f51-5ded-411d-aa0f-ad2d4afa1de7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"9d0fc0e8-3d33-4a9d-9055-b547d92380c0\",\"type\":\"DatetimeTicker\"}},\"id\":\"18a7f34b-e397-436f-a5c3-226422251dd2\",\"type\":\"DatetimeAxis\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"Date\"},\"y\":{\"field\":\"Rating\"}},\"id\":\"fb0156c8-984e-4d76-ad1e-cee11650a911\",\"type\":\"Circle\"},{\"attributes\":{\"base\":60,\"mantissas\":[1,2,5,10,15,20,30],\"max_interval\":1800000.0,\"min_interval\":1000.0,\"num_minor_ticks\":0},\"id\":\"55250a97-4064-406b-83f0-bbca0e3bdb78\",\"type\":\"AdaptiveTicker\"},{\"attributes\":{\"args\":{\"legend\":{\"id\":\"a903dddd-e19e-4a85-950d-f4894c94e020\",\"type\":\"Legend\"},\"source\":{\"id\":\"b0bd9cbc-8e96-4b5f-b0c7-3c793a0fe38d\",\"type\":\"ColumnDataSource\"},\"widgets\":{\"id\":\"dab6c294-01ea-42b9-9751-f6ac8fbb83f0\",\"type\":\"WidgetBox\"}},\"code\":\"var _pyfunc_contains = function contains (a, b) { // nargs: 2\\n if (b == null) {\\n } else if (Array.isArray(b)) {\\n for (var i=0; i<b.length; i++) {if (_pyfunc_equals(a, b[i]))\\n return true;}\\n return false;\\n } else if (b.constructor === Object) {\\n for (var k in b) {if (a == k) return true;}\\n return false;\\n } else if (b.constructor == String) {\\n return b.indexOf(a) >= 0;\\n } var e = Error('Not a container: ' + b); e.name='TypeError'; throw e;\\n};\\nvar _pyfunc_dict = function (x) {\\n var t, i, keys, r={};\\n if (Array.isArray(x)) {\\n for (i=0; i<x.length; i++) {\\n t=x[i]; r[t[0]] = t[1];\\n }\\n } else {\\n keys = Object.keys(x);\\n for (i=0; i<keys.length; i++) {\\n t=keys[i]; r[t] = x[t];\\n }\\n }\\n return r;\\n};\\nvar _pyfunc_equals = function equals (a, b) { // nargs: 2\\n if (a == null || b == null) {\\n } else if (Array.isArray(a) && Array.isArray(b)) {\\n var i = 0, iseq = a.length == b.length;\\n while (iseq && i < a.length) {iseq = equals(a[i], b[i]); i+=1;}\\n return iseq;\\n } else if (a.constructor === Object && b.constructor === Object) {\\n var akeys = Object.keys(a), bkeys = Object.keys(b);\\n akeys.sort(); bkeys.sort();\\n var i=0, k, iseq = equals(akeys, bkeys);\\n while (iseq && i < akeys.length) {k=akeys[i]; iseq = equals(a[k], b[k]); i+=1;}\\n return iseq;\\n } return a == b;\\n};\\nvar _pyfunc_range = function (start, end, step) {\\nvar i, res = [];\\n var val = start;\\n var n = (end - start) / step;\\n for (i=0; i<n; i++) {\\n res.push(val);\\n val += step;\\n }\\n return res;\\n};\\nvar _pymeth_append = function (x) { // nargs: 1\\n if (!Array.isArray(this)) return this.append.apply(this, arguments);\\n this.push(x);\\n};\\nvar filter;\\nfilter = function (source, legend, widgets) {\\n var col, date, flag, i, key, res, selectors, stub1_seq, stub2_itr, stub3_seq, treatments, val, visible_treatments, widget;\\n source = (source === undefined) ? source: source;\\n legend = (legend === undefined) ? p.legend[0]: legend;\\n widgets = (widgets === undefined) ? widgets: widgets;\\n window.widgets = widgets;\\n visible_treatments = (function list_comprehenson () {var res = [];var item, iter0, i0;iter0 = legend.items;if ((typeof iter0 === \\\"object\\\") && (!Array.isArray(iter0))) {iter0 = Object.keys(iter0);}for (i0=0; i0<iter0.length; i0++) {item = iter0[i0];if (!((item.renderers[0].visible))) {continue;}{res.push(item.renderers[0].tags);}}return res;}).apply(this);\\n date = source.data[\\\"Date\\\"];\\n treatments = source.data[\\\"Treatment\\\"];\\n res = [];\\n selectors = {};\\n stub1_seq = widgets.children;\\n if ((typeof stub1_seq === \\\"object\\\") && (!Array.isArray(stub1_seq))) {\\n stub1_seq = Object.keys(stub1_seq);\\n }\\n for (stub2_itr = 0; stub2_itr < stub1_seq.length; stub2_itr += 1) {\\n widget = stub1_seq[stub2_itr];\\n col = widget.tags[0];\\n selectors[col] = _pyfunc_dict(((function list_comprehenson () {var res = [];var i, iter0, i0;iter0 = widget.active;if ((typeof iter0 === \\\"object\\\") && (!Array.isArray(iter0))) {iter0 = Object.keys(iter0);}for (i0=0; i0<iter0.length; i0++) {i = iter0[i0];{res.push([widget.labels[i], i]);}}return res;}).apply(this)));\\n }\\n for (i = 0; i < date.length; i += 1) {\\n flag = _pyfunc_contains(treatments[i], visible_treatments);\\n stub3_seq = selectors;\\n for (key in stub3_seq) {\\n if (!stub3_seq.hasOwnProperty(key)){ continue; }\\n val = stub3_seq[key];\\n if ((!_pyfunc_contains((source.data[key][i]), val))) {\\n flag = false;\\n break;\\n }\\n }\\n _pymeth_append.call(res, flag);\\n }\\n return res;\\n};\\nreturn filter(source, legend, widgets);\\n\"},\"id\":\"91ec0802-9cfb-4ef9-88d7-12308d205c64\",\"type\":\"CustomJSFilter\"},{\"attributes\":{},\"id\":\"fded94a4-f0b6-420a-92e2-982b364449ae\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"days\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]},\"id\":\"f49fd2f5-9fad-40a3-8d7b-65be7b9a1dee\",\"type\":\"DaysTicker\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"index\",\"Name\",\"Target\",\"Plot\",\"Treatment\",\"Trial\",\"Rating\",\"Part\",\"Date\"],\"data\":{\"Date\":[1452902400000.0,1454198400000.0,1455494400000.0,1456790400000.0,1458086400000.0,1459382400000.0,1460678400000.0,1461974400000.0,1463270400000.0,1464566400000.0,1465862400000.0,1467158400000.0,1468454400000.0,1469750400000.0,1471046400000.0,1472342400000.0,1473638400000.0,1474934400000.0,1476230400000.0,1477526400000.0,1478822400000.0,1480118400000.0,1481414400000.0,1482710400000.0],\"Name\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"],\"Part\":[\"W\",\"X\",\"Y\",\"Z\",\"W\",\"X\",\"Y\",\"Z\",\"W\",\"X\",\"Y\",\"Z\",\"W\",\"X\",\"Y\",\"Z\",\"W\",\"X\",\"Y\",\"Z\",\"W\",\"X\",\"Y\",\"Z\"],\"Plot\":[1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8],\"Rating\":{\"__ndarray__\":\"q6qqqqqqEECrqqqqqqogQAAAAAAAAClAq6qqqqqqMEBWVVVVVdU0QAAAAAAAADlAq6qqqqoqPUCrqqqqqqpAQAAAAAAAwEJAVlVVVVXVRECrqqqqqupGQAAAAAAAAElAVlVVVVUVS0CrqqqqqipNQAEAAAAAQE9Aq6qqqqqqUEBWVVVVVbVRQAAAAAAAwFJAq6qqqqrKU0BWVVVVVdVUQAAAAAAA4FVAq6qqqqrqVkBWVVVVVfVXQAAAAAAAAFlA\",\"dtype\":\"float64\",\"shape\":[24]},\"Target\":[\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"J\",\"K\",\"L\"],\"Treatment\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"],\"Trial\":[1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3],\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]}},\"id\":\"b0bd9cbc-8e96-4b5f-b0c7-3c793a0fe38d\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"50334b6a-03e8-4634-ab9a-21abb40e6c12\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"9165a802-0310-492d-af5b-d9f08af0706c\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null},\"id\":\"692b6f98-d371-4946-a6a3-17bfb9c8fa2e\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"ac9d0025-fb4f-46d5-92c9-6960d444bd15\",\"type\":\"Circle\"},{\"attributes\":{\"label\":{\"value\":\"Treatment 6\"},\"renderers\":[{\"id\":\"a3c93c47-1a1a-4946-b60e-84700aa596d2\",\"type\":\"GlyphRenderer\"}]},\"id\":\"43e1a222-bb95-49ac-a6e1-b40b4f12ed5b\",\"type\":\"LegendItem\"},{\"attributes\":{\"data_source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"10cece0d-621d-4488-880f-97d0286f2e24\",\"type\":\"Circle\"},\"hover_glyph\":null,\"js_property_callbacks\":{\"change:visible\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"ac9d0025-fb4f-46d5-92c9-6960d444bd15\",\"type\":\"Circle\"},\"selection_glyph\":null,\"tags\":[\"4\"],\"view\":{\"id\":\"318e8c4c-3459-4e41-8443-708ba141b3a0\",\"type\":\"CDSView\"}},\"id\":\"c3fd6c4b-9105-418e-806a-2f60569a5224\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"months\":[0,2,4,6,8,10]},\"id\":\"1219b0e8-4725-4da3-95a6-da20ebc2c2d7\",\"type\":\"MonthsTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"09854e9d-b1f5-4be1-987f-7560b460818a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"9afe1872-5c8a-4332-a2c9-8721c00e9af9\",\"type\":\"Circle\"},\"hover_glyph\":null,\"js_property_callbacks\":{\"change:visible\":[{\"id\":\"6b6bc91e-6741-4490-81ad-ead74e6a34bb\",\"type\":\"CustomJS\"}]},\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"699015c1-1992-4ead-b34b-c7f90e5106af\",\"type\":\"Circle\"},\"selection_glyph\":null,\"tags\":[\"5\"],\"view\":{\"id\":\"e2599cf0-14f8-4e20-a4c3-a400eb5c0599\",\"type\":\"CDSView\"}},\"id\":\"ee6f793a-2102-408d-9cf7-f6595fcdc50f\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"585b9816-368f-4574-b9a7-d6bd6188aa35\",\"type\":\"HoverTool\"}]},\"id\":\"75714789-6779-48f2-a4b4-2061ed2f194c\",\"type\":\"Toolbar\"},{\"attributes\":{\"fill_color\":{\"field\":\"Treatment\",\"transform\":{\"id\":\"849d37d2-4c3b-48ff-bab1-d21edae41c05\",\"type\":\"CategoricalColorMapper\"}},\"line_color\":{\"field\":\"Treatment\",\"transform\":{\"id\":\"849d37d2-4c3b-48ff-bab1-d21edae41c05\",\"type\":\"CategoricalColorMapper\"}},\"x\":{\"field\":\"Date\"},\"y\":{\"field\":\"Rating\"}},\"id\":\"decb2476-214c-4a81-936e-8a5681acfacd\",\"type\":\"Circle\"}],\"root_ids\":[\"77369dff-743e-4a5d-a8a4-8a2e57e47dba\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.13\"}};\n", | |
" var render_items = [{\"docid\":\"60b85d96-3f98-416a-a3e4-14a7b7da379f\",\"elementid\":\"a9afe308-d62c-4ca3-b91c-810ce859d49d\",\"modelid\":\"77369dff-743e-4a5d-a8a4-8a2e57e47dba\"}];\n", | |
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n", | |
"\n", | |
" }\n", | |
" if (root.Bokeh !== undefined) {\n", | |
" embed_document(root);\n", | |
" } else {\n", | |
" var attempts = 0;\n", | |
" var timer = setInterval(function(root) {\n", | |
" if (root.Bokeh !== undefined) {\n", | |
" embed_document(root);\n", | |
" clearInterval(timer);\n", | |
" }\n", | |
" attempts++;\n", | |
" if (attempts > 100) {\n", | |
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\")\n", | |
" clearInterval(timer);\n", | |
" }\n", | |
" }, 10, root)\n", | |
" }\n", | |
"})(window);" | |
], | |
"application/vnd.bokehjs_exec.v0+json": "" | |
}, | |
"metadata": { | |
"application/vnd.bokehjs_exec.v0+json": { | |
"id": "77369dff-743e-4a5d-a8a4-8a2e57e47dba" | |
} | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"from bokeh.plotting import figure\n", | |
"from bokeh.models import ColumnDataSource, CustomJS, CDSView, CustomJSFilter, HoverTool\n", | |
"from bokeh.models.widgets import CheckboxButtonGroup\n", | |
"from bokeh.io import show, output_notebook\n", | |
"from bokeh.palettes import Set1 \n", | |
"from bokeh.transform import factor_cmap\n", | |
"from bokeh.layouts import widgetbox, layout\n", | |
"\n", | |
"columns = 'Plot', 'Trial', 'Name', 'Target', 'Part'\n", | |
"unique_items = [df[col].unique() for col in columns]\n", | |
"\n", | |
"df[\"Treatment\"] = df[\"Treatment\"].astype(str)\n", | |
"\n", | |
"source = ColumnDataSource(data=df)\n", | |
"dummy_source = ColumnDataSource(data={\"x\":[], \"y\":[]})\n", | |
"\n", | |
"hover = HoverTool(tooltips=[('Date', '@Date{%d/%m/%Y}')] + [(column, '@'+column) \n", | |
" for column in columns], formatters={\n", | |
" 'Date': 'datetime', # use 'datetime' formatter for 'Date' field\n", | |
" })\n", | |
"\n", | |
"p = figure(x_axis_type=\"datetime\", tools=[hover])\n", | |
"color = factor_cmap(\"Treatment\", Set1[9], df.Treatment.unique())\n", | |
"\n", | |
"for i, label in enumerate(df.Treatment.unique()):\n", | |
" dummy_circle = p.circle(x=\"x\", y=\"y\", source=dummy_source, legend=\"Treatment {}\".format(label), color=Set1[9][i])\n", | |
" dummy_circle.tags = [label]\n", | |
"\n", | |
"p.legend.location = \"bottom_right\"\n", | |
"p.legend.click_policy = \"hide\"\n", | |
"\n", | |
"def source_change(source=source):\n", | |
" source.change.emit()\n", | |
" \n", | |
"callback_source_change = CustomJS.from_py_func(source_change)\n", | |
"\n", | |
"for item in p.legend[0].items:\n", | |
" item.renderers[0].js_on_change(\"visible\", callback_source_change)\n", | |
" \n", | |
"controls = [CheckboxButtonGroup(labels=items.astype(str).tolist(), active=list(range(len(items)))) for items in unique_items]\n", | |
"widgets = widgetbox(*controls)\n", | |
"\n", | |
"for name, control in zip(columns, controls):\n", | |
" control.tags = [name]\n", | |
"\n", | |
"def func_filter(source=source, legend=p.legend[0], widgets=widgets):\n", | |
" window.widgets = widgets\n", | |
" visible_treatments = [item.renderers[0].tags for item in legend.items if item.renderers[0].visible]\n", | |
" date = source.data['Date']\n", | |
" treatments = source.data['Treatment']\n", | |
" res = []\n", | |
" \n", | |
" selectors = {}\n", | |
" for widget in widgets.children:\n", | |
" col = widget.tags[0]\n", | |
" selectors[col] = dict([(widget.labels[i], i) for i in widget.active])\n", | |
" \n", | |
" for i in range(len(date)):\n", | |
" flag = treatments[i] in visible_treatments\n", | |
" for key, val in selectors.items():\n", | |
" if source.data[key][i] not in val:\n", | |
" flag = False\n", | |
" break\n", | |
" res.append(flag)\n", | |
" return res\n", | |
" \n", | |
"view = CDSView(source=source, filters=[CustomJSFilter.from_py_func(func_filter)])\n", | |
"p.circle(x='Date', y='Rating', source=source, view=view, line_color=color, fill_color=color) \n", | |
"\n", | |
"for control in controls:\n", | |
" control.js_on_change(\"active\", callback_source_change)\n", | |
"\n", | |
"show(layout([[p, widgets]]))" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python [default]", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment