diff --git a/README.md b/README.md index 7145fe4..9cdd4cb 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ # flask-chartist-example Learning more about flask and javascript -This app is currently running on [heroku](http://still-beyond-87368.herokuapp.com/chartist) - - This project will create a flask dashboard with a javascript library, and the charts will update without refreshing the page. The charts will not be polished or excitin, this is just to explore how to create a working dashboard in python with minimal javascript to refresh the data. ## Inspiration diff --git a/app/app.py b/app/app.py index 40e0d11..855785b 100644 --- a/app/app.py +++ b/app/app.py @@ -14,8 +14,6 @@ from matplotlib.pyplot import rcParams from flask_wtf import FlaskForm from wtforms import StringField, SelectField -from bokeh.plotting import figure -from bokeh.embed import components df = pd.read_csv(os.path.join(settings.data_dir, 'pop_by_country_long_form.csv')) df['Year'] = df['Year'].str[4:].astype(int) @@ -87,14 +85,6 @@ def matplotlib_plot(): scripts = render_template('matplotlib.js') return render_template('home.html',head_scripts=head_scripts, body=body, scripts=scripts) -@app.route('/bokeh', methods=['GET', 'POST']) -def bokeh_plot(): - form = MyForm() - head_scripts = render_template('bokeh_head_scripts.html') - body = render_template('bokeh.html', form=form) - scripts = render_template('bokeh.js') - return render_template('home.html',head_scripts=head_scripts, body=body, scripts=scripts) - @app.route('/chartist', methods=['GET', 'POST']) def chartist(): form = MyForm() @@ -103,14 +93,6 @@ def chartist(): scripts = render_template('chartist.js') return render_template('home.html', head_scripts=head_scripts, body=body, scripts=scripts) -@app.route('/c3', methods=['GET', 'POST']) -def c3_route(): - form = MyForm() - head_scripts = render_template('c3_head_scripts.html') - body = render_template('c3.html', form=form) - scripts = render_template('c3_update.js') - return render_template('home.html', head_scripts=head_scripts, body=body, scripts=scripts) - @app.route('/chartist1', methods=['GET', 'POST']) def chartist1(): form = MyForm() @@ -129,23 +111,6 @@ def mpl(nation): hide_spines(ax) return jsonify({'src': fig_to_html(ax.figure)}) -@app.route('/pybokeh/') -def pybokeh(nation): - p = figure(title=nation, logo=None, tools="box_zoom,pan,wheel_zoom,reset",) - p.line(x=df2[nation].index, y=df2[nation].values) - script, div = components(p) - return jsonify({'script': script, - 'div': div}) - -@app.route('/c3data/') -def c3_daata_route(nation): - - data = {'columns':[[nation] + df2[nation].astype(float).tolist(), ['x'] + df2.index.astype(float).tolist()], - 'colors': {nation: '#4286f4'}, - 'unload': "",} - return jsonify(data) - - if __name__ == '__main__': port = int(os.environ.get("PORT", 5000)) - app.run(host='0.0.0.0', port=port, debug=True) \ No newline at end of file + app.run(host='0.0.0.0', port=port) \ No newline at end of file diff --git a/app/templates/bokeh.html b/app/templates/bokeh.html deleted file mode 100644 index ea7b2c4..0000000 --- a/app/templates/bokeh.html +++ /dev/null @@ -1,22 +0,0 @@ -{% from "_render_field.html" import render_field %} - -

Population by Nation


-data from -data.world -

-Created with Flask and python bokeh. -Using the pure python causes the whole chart to be refreshed. -It would be possible to update the data only to avoid the chart completely redrawing on update. - - - - -
- World Population -{{ render_field(form.nation) }} - - -
-
- - \ No newline at end of file diff --git a/app/templates/bokeh.js b/app/templates/bokeh.js deleted file mode 100644 index b5df28c..0000000 --- a/app/templates/bokeh.js +++ /dev/null @@ -1,19 +0,0 @@ -function updateChart(){ -console.log('updated div/scripts') - var nation = $("#nation option:selected").text() - var updatedData = $.get('/pybokeh/'.concat(nation)); - - updatedData.done(function(results){ - - $("#bokeh-pop-plot").html(results.div); - $("#bokeh-pop-script").html(results.script); - - - }); - - -} - -$( document ).ready(updateChart) -$('#update').on('click', updateChart) -$('#nation').on('change', updateChart) \ No newline at end of file diff --git a/app/templates/bokeh_head_scripts.html b/app/templates/bokeh_head_scripts.html deleted file mode 100644 index 9571176..0000000 --- a/app/templates/bokeh_head_scripts.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - diff --git a/app/templates/c3.html b/app/templates/c3.html deleted file mode 100644 index 2735329..0000000 --- a/app/templates/c3.html +++ /dev/null @@ -1,18 +0,0 @@ -{% from "_render_field.html" import render_field %} - - -

Population by Nation


-data from -data.world -

-Created with Flask and python c3 - - - - -
- World Population -{{ render_field(form.nation) }} - - -
diff --git a/app/templates/c3_head_scripts.html b/app/templates/c3_head_scripts.html deleted file mode 100644 index d65a2f0..0000000 --- a/app/templates/c3_head_scripts.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/templates/c3_update.js b/app/templates/c3_update.js deleted file mode 100644 index d252a5a..0000000 --- a/app/templates/c3_update.js +++ /dev/null @@ -1,154 +0,0 @@ -var data = { - 'size': { - 'height': 300 - }, - 'data': { - 'x': 'x', - 'type': 'line', - 'axes': { - 'Australia': 'y', - 'x': 'y' - }, - 'columns': [ - [ - 'Australia', - '14.6159', - '14.92326', - '15.16178', - '15.34807', - '15.51048', - '15.69524', - '15.90042', - '16.13672', - '16.40073', - '16.6806', - '16.95624', - '17.20212', - '17.41893', - '17.6078', - '17.78109', - '17.97563', - '18.19585', - '18.41526', - '18.62084', - '18.83025', - '19.05319', - '19.29426', - '19.53494', - '19.76654', - '19.99508', - '20.23235', - '20.48947', - '20.74963', - '21.00731', - '21.26264', - '21.51575' - ], - [ - 'x', - '1980', - '1981', - '1982', - '1983', - '1984', - '1985', - '1986', - '1987', - '1988', - '1989', - '1990', - '1991', - '1992', - '1993', - '1994', - '1995', - '1996', - '1997', - '1998', - '1999', - '2000', - '2001', - '2002', - '2003', - '2004', - '2005', - '2006', - '2007', - '2008', - '2009', - '2010' - ] - ] - }, - 'subchart': { - 'show': false - }, - 'point': { - 'show': false - }, - 'grid': { - 'x': { - 'show': false - }, - 'y': { - 'show': false - } - }, - 'axis': { - 'x': { - 'tick': { - 'count': 10 - } - }, - 'y': { - 'tick': { - 'format': '' - } - }, - 'y2': { - 'tick': {} - } - }, - 'zoom': {} -}; -data['axis']['y']['tick']['format'] = d3.format('') -data['axis']['y2']['tick']['format'] = d3.format('') -data['bindto']='#chart' -var chart = c3.generate(data); - -function load_data(country) { - var xhr = new XMLHttpRequest(); - - xhr.open('GET', 'http://127.0.0.1:5000/' + country); - xhr.send(null); - results = JSON.parse(xhr.responseText.result) - document.getElement - return data - -} - - - -function updateChart(){ - var nation = $("#nation option:selected").text() - - var updatedData = $.get('/c3data/'.concat(nation)); - updatedData.done(function(results){ - - var data = { - labels: results.labels, - series: [ - results.results - ] - }; - - chart.load(updatedData.responseJSON) - }); - -} - - - -$( document ).ready(updateChart) -// $('#update').on('click', updateChart) -$('#nation').on('change', updateChart) \ No newline at end of file diff --git a/app/templates/home.html b/app/templates/home.html index 2deaad1..570e927 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -34,15 +34,13 @@ body {margin:0;} -{{ body | safe }} +{{ body | safe}} diff --git a/app/templates/matplotlib.js b/app/templates/matplotlib.js index d4b1370..8d1ce03 100644 --- a/app/templates/matplotlib.js +++ b/app/templates/matplotlib.js @@ -7,5 +7,5 @@ function updateChartSrc(){ } -$( document ).ready(updateChartSrc) + $("#nation").on('change', updateChartSrc); diff --git a/notebooks/data exploration.ipynb b/notebooks/data exploration.ipynb index 8c79fde..3d5d5be 100644 --- a/notebooks/data exploration.ipynb +++ b/notebooks/data exploration.ipynb @@ -10,7 +10,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 21, "metadata": { "collapsed": true, "scrolled": true @@ -26,7 +26,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -99,7 +99,7 @@ "4 Georgia 1980 --" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -112,7 +112,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 28, "metadata": { "scrolled": true }, @@ -174,7 +174,7 @@ " 'Estonia'], dtype=object)" ] }, - "execution_count": 3, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -185,7 +185,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 78, "metadata": {}, "outputs": [ { @@ -216,68 +216,16 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 97, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "'labels:[1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010]\\nseries: [227.22468, 229.46571, 231.66446, 233.79199, 235.8249, 237.9238, 240.13289, 242.28892, 244.49898, 246.81923, 249.62281, 252.98094, 256.51422, 259.91859, 263.12582, 266.27839, 269.39428, 272.64693, 275.8541, 279.04017, 282.17196, 285.08156, 287.80391, 290.32642, 293.04574, 295.75315, 298.59321, 301.5799, 304.37485, 307.00655, 310.23286]'" ] }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2[[nation]].rename(columns={'United States':'Series', 'Year':'Values'}).to_json" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'labels:[1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010], series: [[227.22468, 229.46571, 231.66446, 233.79199, 235.8249, 237.9238, 240.13289, 242.28892, 244.49898, 246.81923, 249.62281, 252.98094, 256.51422, 259.91859, 263.12582, 266.27839, 269.39428, 272.64693, 275.8541, 279.04017, 282.17196, 285.08156, 287.80391, 290.32642, 293.04574, 295.75315, 298.59321, 301.5799, 304.37485, 307.00655, 310.23286]]'" - ] - }, - "execution_count": 6, + "execution_count": 97, "metadata": {}, "output_type": "execute_result" } @@ -288,10 +236,8 @@ }, { "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": true - }, + "execution_count": 4, + "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv(os.path.join(settings.data_dir, 'pop_by_country_long_form.csv'))\n", @@ -303,7 +249,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 33, "metadata": { "collapsed": true }, @@ -314,14 +260,14 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAECCAYAAADq7fyyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl0VdXB/vHvZkgYQ5iCDAmBAIGAhCEMolWwIBZxrlBn\nsS1Y6q+1vg6lqKiIQ62CQ0FRBKvSWgWRQlEmURSUyjyFDCQBIgQCZJ7v3b8/Et8XLUqmm3PvyfNZ\ni7WSm3vvefaC+7Bzzj7nGGstIiLiHg2cDiAiIrVLxS4i4jIqdhERl1Gxi4i4jIpdRMRlVOwiIi6j\nYhcRcRkVu4iIy6jYRURcppGvN9CuXTsbGRnp682IiLjK1q1bM6217avzWp8Xe2RkJF9//bWvNyMi\n4irGmLTqvla7YkREXEbFLiLiMip2ERGXUbGLiLiMil1ExGVU7CIiLqNiFxFxGZ+vYxcRkcorKfMy\nb0Nyjd5DxS4i4id2Hs7iwSW7iD+WW6P30a4YERGHFZZ4ePLf+7l27hdkFZTy+m1xNXo/zdhFRBy0\nOfkk05buIvVkATcOjWDauN6ENGlco/dUsYuIOCCnqJSnV8Wz+KtDdG3bjMW/HsaIqHa18t4qdhGR\nOrY+PoM/Ld3D8dwifv2Tbtw7JpqmQQ1r7f1V7CIideRkXjGPr9jHhzu+IbpDS165dTADwkNrfTsq\ndhERH7PW8q9dR3l0+V5yi0q5Z3RPpo7sQVAj36xfUbGLiPhQRk4R0z/Yw9r9GcSGh/Ln6/sTfV5L\nn25TxS4i4gPWWt77+ggzV+6jpMzL9HF9uPOibjRsYHy+bRW7iEgtO3K6gGlLd7MxMZOh3drwzPX9\n6daueZ1tX8UuIlJLvF7LO1+l8fSqeCww8+q+3DysKw3qYJZ+JhW7iEgtSMnM58Elu9iScoqf9GzH\nk9eeT3ibZo5kqXaxG2MaAp2stYdrMY+ISEDxeC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ell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": true - }, + "execution_count": 29, + "metadata": {}, "outputs": [], "source": [ "items = ['mpl/' + nation for nation in df2.columns]" @@ -346,7 +290,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -587,7 +531,7 @@ " ('mpl/Zimbabwe', 'mpl/Zimbabwe')]" ] }, - "execution_count": 11, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -596,547 +540,6 @@ "list(zip(items, items))" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [], - "source": [ - "from bokeh.charts import Line, show\n", - "from bokeh.plotting import figure" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [], - "source": [ - "from bokeh.io import output_notebook" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
\n", - " \n", - " Loading BokehJS ...\n", - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "\n", - "(function(global) {\n", - " function now() {\n", - " return new Date();\n", - " }\n", - "\n", - " var force = true;\n", - "\n", - " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", - " window._bokeh_onload_callbacks = [];\n", - " window._bokeh_is_loading = undefined;\n", - " }\n", - "\n", - "\n", - " \n", - " if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n", - " window._bokeh_timeout = Date.now() + 5000;\n", - " window._bokeh_failed_load = false;\n", - " }\n", - "\n", - " var NB_LOAD_WARNING = {'data': {'text/html':\n", - " \"
\\n\"+\n", - " \"

\\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", - " \"

\\n\"+\n", - " \"
    \\n\"+\n", - " \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n", - " \"
  • use INLINE resources instead, as so:
  • \\n\"+\n", - " \"
\\n\"+\n", - " \"\\n\"+\n", - " \"from bokeh.resources import INLINE\\n\"+\n", - " \"output_notebook(resources=INLINE)\\n\"+\n", - " \"\\n\"+\n", - " \"
\"}};\n", - "\n", - " function display_loaded() {\n", - " if (window.Bokeh !== undefined) {\n", - " var el = document.getElementById(\"aa65fd43-0e8c-4886-87fb-20b38db331b8\");\n", - " el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n", - " } else if (Date.now() < window._bokeh_timeout) {\n", - " setTimeout(display_loaded, 100)\n", - " }\n", - " }\n", - "\n", - " function run_callbacks() {\n", - " window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", - " delete window._bokeh_onload_callbacks\n", - " console.info(\"Bokeh: all callbacks have finished\");\n", - " }\n", - "\n", - " function load_libs(js_urls, callback) {\n", - " window._bokeh_onload_callbacks.push(callback);\n", - " if (window._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", - " window._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", - " window._bokeh_is_loading--;\n", - " if (window._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(\"aa65fd43-0e8c-4886-87fb-20b38db331b8\");\n", - " if (element == null) {\n", - " console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'aa65fd43-0e8c-4886-87fb-20b38db331b8' 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.5.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.js\"];\n", - "\n", - " var inline_js = [\n", - " function(Bokeh) {\n", - " Bokeh.set_log_level(\"info\");\n", - " },\n", - " \n", - " function(Bokeh) {\n", - " \n", - " },\n", - " \n", - " function(Bokeh) {\n", - " \n", - " document.getElementById(\"aa65fd43-0e8c-4886-87fb-20b38db331b8\").textContent = \"BokehJS is loading...\";\n", - " },\n", - " function(Bokeh) {\n", - " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n", - " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n", - " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n", - " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n", - " }\n", - " ];\n", - "\n", - " function run_inline_js() {\n", - " \n", - " if ((window.Bokeh !== undefined) || (force === true)) {\n", - " for (var i = 0; i < inline_js.length; i++) {\n", - " inline_js[i](window.Bokeh);\n", - " }if (force === true) {\n", - " display_loaded();\n", - " }} else if (Date.now() < window._bokeh_timeout) {\n", - " setTimeout(run_inline_js, 100);\n", - " } else if (!window._bokeh_failed_load) {\n", - " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", - " window._bokeh_failed_load = true;\n", - " } else if (force !== true) {\n", - " var cell = $(document.getElementById(\"aa65fd43-0e8c-4886-87fb-20b38db331b8\")).parents('.cell').data().cell;\n", - " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", - " }\n", - "\n", - " }\n", - "\n", - " if (window._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", - "}(this));" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "output_notebook()" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n", - "
\n", - "
\n", - "
\n", - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "p = figure(title=nations[1], logo=None, tools=\"box_zoom,pan,wheel_zoom,reset\",)\n", - "p.line(x=df2[nations[1]].index, y=df2[nations[1]].values)\n", - "# p.title(nations[1])\n", - "show(p)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "from bokeh.embed import components" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "script, div = components(line)" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n" - ] - } - ], - "source": [ - "print(script)" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "
\n", - "
\n", - "
\n" - ] - } - ], - "source": [ - "print(div)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import json" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "id_pos = script.find('elementid\":\"') + 12\n", - "divid = script[id_pos:id_pos+36]\n", - "script = script.replace(divid, 'bokeh-line')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(script)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "x_start = script.find('\"x_values\":') + 11\n", - "x_end = script.find(',\"y_values\":')\n", - "y_start = script.find('\"y_values\":') + 11\n", - "y_end = script[y_start:].find('}}') + y_start\n", - "\n", - "script = script.replace(script[x_start:x_end], 'newXvalues')\n", - "script = script.replace(script[y_start:y_end], 'newYvalues')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "len('\"y_values\":')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "script[y_start:].find('}}') + y_start" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import bokeh" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'0.12.5'" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "bokeh.__version__" - ] - }, { "cell_type": "code", "execution_count": null, diff --git a/requirements.txt b/requirements.txt index 0be0e38..16bd862 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # Requirements automatically generated by pigar. # https://github.com/Damnever/pigar -bokeh +Python == 3.6.1 # app.py: 5 Flask == 0.12