Skip to content

A simple wrapper for embedding bokeh plots in vue components

Notifications You must be signed in to change notification settings

hemma/vue-bokeh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This code is very old and the example is broken. I will keep the repository as it might still help someone..

Simple wrapper for embedding Bokehplot in a vue-component.

Installation

npm i vue-bokeh --save-dev

Include:

<link href="http://cdn.pydata.org/bokeh/release/bokeh-0.12.2.min.css" rel="stylesheet" type="text/css">
<script src="http://cdn.pydata.org/bokeh/release/bokeh-0.12.2.min.js"></script>

Might be easier to just copy the code from BokehPlot.vue. Its very small and then you will have one less dependency.

Usage

<template>
  <bokeh-plot :plot="plot"></bokeh-plot>
</template>

<script>
import { fetchPlot } from '../vuex/actions'
import BokehPlot from 'vue-bokeh'

export default {
  components: {
    'bokeh-plot': BokehPlot
  },
  vuex: {
    getters: {
      plot: ({ plot }) => plot
    },
    actions: {
      fetchPlot
    }
  },
  ready () {
    this.fetchPlot()
  }
}
</script>

<style>
  
</style>
from flask import Flask, jsonify
from flask_cors import cross_origin
from bokeh.plotting import figure
from bokeh.embed import components

app = Flask(__name__)


@app.route("/get-plot")
@cross_origin()
def get_plot():

    plot = figure(plot_height=250, responsive = True)
    plot.circle([1, 2], [3, 4])
    script, div = components(plot, wrap_script=False)
    return jsonify({'div': div, 'script': script})

app.run(debug=True)

About

A simple wrapper for embedding bokeh plots in vue components

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published