Plotting the user input in the plot.

Hi,

I have been trying to get the user input from the user and trying to put it into the plot with a button click or so but I am not able to do that. Also I want to update the point values in the plot with the user given values. I tried various things like CustomJS and callback but it did not worked for me. Can anyone help me with this?

I will be really thankful. :slight_smile:

Many Thanks,

Sandy

Hi Sandy,

This is pretty general and non-specific, it's hard to give any concrete guidance. Can you provide more details, e.g. what sort of data is to be input, what kind of user interaction you are looking to have, and what exactly you have tried so far?

Thanks,

Bryan

···

On Mar 16, 2016, at 5:28 PM, alphasandy <[email protected]> wrote:

Hi,

I have been trying to get the user input from the user and trying to put it into the plot with a button click or so but I am not able to do that. Also I want to update the point values in the plot with the user given values. I tried various things like CustomJS and callback but it did not worked for me. Can anyone help me with this?
I will be really thankful. :slight_smile:

Many Thanks,
Sandy

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Bryan,

I have a plot for parameters say x and y with few other parameters a,b and c. I want the user to input values for all the parameters on a browser and with a click of a button it should plot the newly added point in the plot on the browser itself. I used TextInput to get the input from the user and also made a button to update the plot but I am not able to achieve it. I need assistance on this one. Tell me if you want more specific explanation.

Many Thanks,

Sandy

···

On Thu, Mar 17, 2016 at 6:59 PM, Bryan Van de Ven [email protected] wrote:

Hi Sandy,

This is pretty general and non-specific, it’s hard to give any concrete guidance. Can you provide more details, e.g. what sort of data is to be input, what kind of user interaction you are looking to have, and what exactly you have tried so far?

Thanks,

Bryan

On Mar 16, 2016, at 5:28 PM, alphasandy [email protected] wrote:

Hi,

I have been trying to get the user input from the user and trying to put it into the plot with a button click or so but I am not able to do that. Also I want to update the point values in the plot with the user given values. I tried various things like CustomJS and callback but it did not worked for me. Can anyone help me with this?

I will be really thankful. :slight_smile:

Many Thanks,

Sandy

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

I didn’t got any response from anyone regarding my issue. Here is the pastebin for the piece of code in which I am facing problem ( http://pastebin.com/sEUqSgzD ). I will be really thankful for your help.

Sandy.

···

On Thu, Mar 17, 2016 at 10:13 PM, Sandeep Bharti [email protected] wrote:

Hi Bryan,

I have a plot for parameters say x and y with few other parameters a,b and c. I want the user to input values for all the parameters on a browser and with a click of a button it should plot the newly added point in the plot on the browser itself. I used TextInput to get the input from the user and also made a button to update the plot but I am not able to achieve it. I need assistance on this one. Tell me if you want more specific explanation.

Many Thanks,

Sandy

On Thu, Mar 17, 2016 at 6:59 PM, Bryan Van de Ven [email protected] wrote:

Hi Sandy,

This is pretty general and non-specific, it’s hard to give any concrete guidance. Can you provide more details, e.g. what sort of data is to be input, what kind of user interaction you are looking to have, and what exactly you have tried so far?

Thanks,

Bryan

On Mar 16, 2016, at 5:28 PM, alphasandy [email protected] wrote:

Hi,

I have been trying to get the user input from the user and trying to put it into the plot with a button click or so but I am not able to do that. Also I want to update the point values in the plot with the user given values. I tried various things like CustomJS and callback but it did not worked for me. Can anyone help me with this?

I will be really thankful. :slight_smile:

Many Thanks,

Sandy

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Sandy,

I'm not sure exactly what you're trying to achieve here.
Anyway, here is a working exemple. I hope it helps.
- you need to add your textinput and button to the plot to display it
- callback written with CustomJS
- added an initial x_range and y_range to the plot
- s2 ColumnDataSource is initially empty

Jean

···

----------------------------------------------------------------------

from bokeh.models import CustomJS, Range1d
from bokeh.models.sources import ColumnDataSource
from bokeh.models.tools import HoverTool, PanTool, BoxSelectTool, WheelZoomTool, BoxZoomTool, ResetTool
from bokeh.models.widgets import TextInput, Button
from bokeh.plotting import figure, show, output_file, vplot, hplot

output_file("adding_points.html")

s2= ColumnDataSource( #the data is fetched and manipulated from a csv file
         data=dict(
             plsr1=,
             rw_prf1=,
             pd1=,
             pd_der1=,
         )
     )

plsri = TextInput(value=" ", title="Puls:") #takes the input
rw_prfi= TextInput(value=" ", title="Prof:")
pdi = TextInput(value=" ", title="Pd:")
pd_deri = TextInput(value=" ", title="Pd Derv:")

callback = CustomJS(args=dict(source=s2,
                               plsr=plsri,
                               rw_prf=rw_prfi,
                               pd=pdi,
                               pd_der=pd_deri),
                     code="""
                     var data = source.get('data');
                     data['plsr1'].push(plsr.get('value'))
                     data['rw_prf1'].push(rw_prf.get('value'))
                     data['pd1'].push(pd.get('value'))
                     data['pd_der1'].push(pd_der.get('value'))
                     source.trigger('change');
                     """)

hover1 = HoverTool(tooltips=[
             ("Pulsar", "@plsr1"),
             ("Raw Profiles", "@rw_prf1"),
             ("Period","@pd1"),
             ("Period Derivative","@pd_der1"),
]
)
tool1=[PanTool(),BoxSelectTool(),hover1,WheelZoomTool(),BoxZoomTool(),ResetTool()]

p5= figure(plot_width=800, plot_height=500,tools=tool1, title="Point Plot",
            x_range=Range1d(-10,10, bounds=None), y_range=Range1d(-10,10, bounds=None))
p5.circle('pd1', 'pd_der1', size=15, color='green', line_color='blue', source=s2)
p5.xaxis.axis_label ="Period"
p5.yaxis.axis_label ="Period Derivative"
p5.background_fill_color='black'
p5.xaxis.major_label_text_color = "green"
p5.yaxis.major_label_text_color = "green"

toggle = Button(label="Add Point", type="success", callback=callback)
inputs = vplot(plsri, rw_prfi, pdi, pd_deri, toggle)
display= hplot(p5, inputs)

show(display)

Le 19/03/2016 23:59, Sandeep Bharti a écrit :

Hi,

I didn't got any response from anyone regarding my issue. Here is the
pastebin for the piece of code in which I am facing problem
( http://pastebin.com/sEUqSgzD ). I will be really thankful for your help.

Sandy.

On Thu, Mar 17, 2016 at 10:13 PM, Sandeep Bharti > <[email protected] <mailto:[email protected]>> wrote:

    Hi Bryan,

    I have a plot for parameters say x and y with few other parameters
      a,b and c. I want the user to input values for all the parameters
    on a browser and with a click of a button it should plot the newly
    added point in the plot on the browser itself. I used TextInput to
    get the input from the user and also made a button to update the
    plot but I am not able to achieve it. I need assistance on this one.
    Tell me if you want more specific explanation.

    Many Thanks,
    Sandy

    On Thu, Mar 17, 2016 at 6:59 PM, Bryan Van de Ven > <[email protected] <mailto:[email protected]>> wrote:

        Hi Sandy,

        This is pretty general and non-specific, it's hard to give any
        concrete guidance. Can you provide more details, e.g. what sort
        of data is to be input, what kind of user interaction you are
        looking to have, and what exactly you have tried so far?

        Thanks,

        Bryan

         > On Mar 16, 2016, at 5:28 PM, alphasandy > <[email protected] <mailto:[email protected]>> wrote:
         >
         > Hi,
         >
         > I have been trying to get the user input from the user and
        trying to put it into the plot with a button click or so but I
        am not able to do that. Also I want to update the point values
        in the plot with the user given values. I tried various things
        like CustomJS and callback but it did not worked for me. Can
        anyone help me with this?
         > I will be really thankful. :slight_smile:
         >
         > Many Thanks,
         > Sandy
         >
         > --
         > You received this message because you are subscribed to the
        Google Groups "Bokeh Discussion - Public" group.
         > To unsubscribe from this group and stop receiving emails from
        it, send an email to [email protected]
        <mailto:bokeh%[email protected]>.
         > To post to this group, send email to [email protected]
        <mailto:[email protected]>.
         > To view this discussion on the web visit
        https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io\.
         > For more options, visit
        https://groups.google.com/a/continuum.io/d/optout\.

        --
        You received this message because you are subscribed to the
        Google Groups "Bokeh Discussion - Public" group.
        To unsubscribe from this group and stop receiving emails from
        it, send an email to [email protected]
        <mailto:bokeh%[email protected]>.
        To post to this group, send email to [email protected]
        <mailto:[email protected]>.
        To view this discussion on the web visit
        https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io\.
        For more options, visit
        https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google
Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Jean,

Thanks for your time, I appreciate your help. :slight_smile:

I am exactly trying to do what you have written in the code but unfortunately the point that is being added from the inputs is not permanent, it gets vanished after page gets refreshed. Is there any way to put the input permanently in the plot?

Also I will be really thankful if you can tell me whether is it possible to delete points and modify the parameters of a point from the plot by writing CustomJs for Taptool?

Really Thanks for your help.

Sandy

···

On Mon, Mar 21, 2016 at 3:20 PM, Jean Felder [email protected] wrote:

Hi Sandy,

I’m not sure exactly what you’re trying to achieve here.

Anyway, here is a working exemple. I hope it helps.

  • you need to add your textinput and button to the plot to display it

  • callback written with CustomJS

  • added an initial x_range and y_range to the plot

  • s2 ColumnDataSource is initially empty

Jean


from bokeh.models import CustomJS, Range1d

from bokeh.models.sources import ColumnDataSource

from bokeh.models.tools import HoverTool, PanTool, BoxSelectTool, WheelZoomTool, BoxZoomTool, ResetTool

from bokeh.models.widgets import TextInput, Button

from bokeh.plotting import figure, show, output_file, vplot, hplot

output_file(“adding_points.html”)

s2= ColumnDataSource( #the data is fetched and manipulated from a csv file

    data=dict(

        plsr1=[],

        rw_prf1=[],

        pd1=[],

        pd_der1=[],

    )

)

plsri = TextInput(value=" ", title=“Puls:”) #takes the input

rw_prfi= TextInput(value=" ", title=“Prof:”)

pdi = TextInput(value=" ", title=“Pd:”)

pd_deri = TextInput(value=" ", title=“Pd Derv:”)

callback = CustomJS(args=dict(source=s2,

                          plsr=plsri,

                          rw_prf=rw_prfi,

                          pd=pdi,

                          pd_der=pd_deri),

                code="""

                var data = source.get('data');

                data['plsr1'].push(plsr.get('value'))

                data['rw_prf1'].push(rw_prf.get('value'))

                data['pd1'].push(pd.get('value'))

                data['pd_der1'].push(pd_der.get('value'))

                source.trigger('change');

                """)

hover1 = HoverTool(tooltips=[

        ("Pulsar", "@plsr1"),

        ("Raw Profiles", "@rw_prf1"),

        ("Period","@pd1"),

        ("Period Derivative","@pd_der1"),

]

)

tool1=[PanTool(),BoxSelectTool(),hover1,WheelZoomTool(),BoxZoomTool(),ResetTool()]

p5= figure(plot_width=800, plot_height=500,tools=tool1, title=“Point Plot”,

       x_range=Range1d(-10,10, bounds=None), y_range=Range1d(-10,10, bounds=None))

p5.circle(‘pd1’, ‘pd_der1’, size=15, color=‘green’, line_color=‘blue’, source=s2)

p5.xaxis.axis_label =“Period”

p5.yaxis.axis_label =“Period Derivative”

p5.background_fill_color=‘black’

p5.xaxis.major_label_text_color = “green”

p5.yaxis.major_label_text_color = “green”

toggle = Button(label=“Add Point”, type=“success”, callback=callback)

inputs = vplot(plsri, rw_prfi, pdi, pd_deri, toggle)

display= hplot(p5, inputs)

show(display)

Le 19/03/2016 23:59, Sandeep Bharti a écrit :

Hi,

I didn’t got any response from anyone regarding my issue. Here is the

pastebin for the piece of code in which I am facing problem

( http://pastebin.com/sEUqSgzD ). I will be really thankful for your help.

Sandy.

On Thu, Mar 17, 2016 at 10:13 PM, Sandeep Bharti

<[email protected] mailto:[email protected]> wrote:

Hi Bryan,



I have a plot for parameters say x and y with few other parameters

  a,b and c. I want the user to input values for all the parameters

on a browser and with a click of a button it should plot the newly

added point in the plot on the browser itself. I used TextInput to

get the input from the user and also made a button to update the

plot but I am not able to achieve it. I need assistance on this one.

Tell me if you want more specific explanation.



Many Thanks,

Sandy



On Thu, Mar 17, 2016 at 6:59 PM, Bryan Van de Ven

<[email protected] <mailto:[email protected]>> wrote:



    Hi Sandy,



    This is pretty general and non-specific, it's hard to give any

    concrete guidance. Can you provide more details, e.g. what sort

    of data is to be input, what kind of user interaction you are

    looking to have, and what exactly you have tried so far?



    Thanks,



    Bryan





     > On Mar 16, 2016, at 5:28 PM, alphasandy

    <[email protected] <mailto:[email protected]>> wrote:

     >

     > Hi,

     >

     > I have been trying to get the user input from the user and

    trying to put it into the plot with a button click or so but I

    am not able to do that. Also I want to update the point values

    in the plot with the user given values. I tried various things

    like CustomJS and callback but it did not worked for me. Can

    anyone help me with this?

     > I will be really thankful. :)

     >

     > Many Thanks,

     > Sandy

     >

     > --

     > You received this message because you are subscribed to the

    Google Groups "Bokeh Discussion - Public" group.

     > To unsubscribe from this group and stop receiving emails from

    it, send an email to [email protected]

    <mailto:bokeh%[email protected]>.

     > To post to this group, send email to [email protected]

    <mailto:[email protected]>.

     > To view this discussion on the web visit

    [https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io).

     > For more options, visit

    [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).



    --

    You received this message because you are subscribed to the

    Google Groups "Bokeh Discussion - Public" group.

    To unsubscribe from this group and stop receiving emails from

    it, send an email to [email protected]

    <mailto:bokeh%[email protected]>.

    To post to this group, send email to [email protected]

    <mailto:[email protected]>.

    To view this discussion on the web visit

    [https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io).

    For more options, visit

    [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).

You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected]

mailto:[email protected].

To post to this group, send email to [email protected]

mailto:[email protected].

To view this discussion on the web visit

https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com

<https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/56EFC3E4.2070604%40gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

There is not really any way to persist information like that in a static web page.

If you want something like this, you will have to take steps to make sure the data is persisted elsewhere (and also re-used by the plot). There are a couple of possibilities I can think of:

* use the JS callback to send data to some server that has a REST API that can store the data in a database or whatever, and probably use AjaxDataSource to pull the current most up to date data from the REST API when the plot is loaded.

* Use a Bokeh server, and have the python Bokeh Application code store things in a database or whatever (you would not use JS callback in this case, you'd use python server callbacks). This approach could range from fairly simple if there is no concept of "users" or different states/data for each user, to very complex, if you need to deal with users, authentication, having different views depending on the user, etc. You can find a more in depth example involving those sorts of things here, for reference:

  https://github.com/bokeh/bokeh-demos/tree/master/happiness

It occurs to me there might be a third possibility:

* use the JS callback to store data in a cookie. I'm not sure if this is a good or bad idea, or really how to go about it (maybe others do). Also there's not currently any "on load" lifecycle hook for a Bokeh plot, so it would probably also involve writing a custom extension to Bokeh to accomplish, as well.

Thanks,

Bryan

···

On Mar 21, 2016, at 5:43 AM, Sandeep Bharti <[email protected]> wrote:

Hi Jean,

Thanks for your time, I appreciate your help. :slight_smile:
I am exactly trying to do what you have written in the code but unfortunately the point that is being added from the inputs is not permanent, it gets vanished after page gets refreshed. Is there any way to put the input permanently in the plot?
Also I will be really thankful if you can tell me whether is it possible to delete points and modify the parameters of a point from the plot by writing CustomJs for Taptool?

Really Thanks for your help.

Sandy

On Mon, Mar 21, 2016 at 3:20 PM, Jean Felder <[email protected]> wrote:
Hi Sandy,

I'm not sure exactly what you're trying to achieve here.
Anyway, here is a working exemple. I hope it helps.
- you need to add your textinput and button to the plot to display it
- callback written with CustomJS
- added an initial x_range and y_range to the plot
- s2 ColumnDataSource is initially empty

Jean

----------------------------------------------------------------------

from bokeh.models import CustomJS, Range1d
from bokeh.models.sources import ColumnDataSource
from bokeh.models.tools import HoverTool, PanTool, BoxSelectTool, WheelZoomTool, BoxZoomTool, ResetTool
from bokeh.models.widgets import TextInput, Button
from bokeh.plotting import figure, show, output_file, vplot, hplot

output_file("adding_points.html")

s2= ColumnDataSource( #the data is fetched and manipulated from a csv file
        data=dict(
            plsr1=,
            rw_prf1=,
            pd1=,
            pd_der1=,
        )
    )

plsri = TextInput(value=" ", title="Puls:") #takes the input
rw_prfi= TextInput(value=" ", title="Prof:")
pdi = TextInput(value=" ", title="Pd:")
pd_deri = TextInput(value=" ", title="Pd Derv:")

callback = CustomJS(args=dict(source=s2,
                              plsr=plsri,
                              rw_prf=rw_prfi,
                              pd=pdi,
                              pd_der=pd_deri),
                    code="""
                    var data = source.get('data');
                    data['plsr1'].push(plsr.get('value'))
                    data['rw_prf1'].push(rw_prf.get('value'))
                    data['pd1'].push(pd.get('value'))
                    data['pd_der1'].push(pd_der.get('value'))
                    source.trigger('change');
                    """)

hover1 = HoverTool(tooltips=[
            ("Pulsar", "@plsr1"),
            ("Raw Profiles", "@rw_prf1"),
            ("Period","@pd1"),
            ("Period Derivative","@pd_der1"),
]
)
tool1=[PanTool(),BoxSelectTool(),hover1,WheelZoomTool(),BoxZoomTool(),ResetTool()]

p5= figure(plot_width=800, plot_height=500,tools=tool1, title="Point Plot",
           x_range=Range1d(-10,10, bounds=None), y_range=Range1d(-10,10, bounds=None))
p5.circle('pd1', 'pd_der1', size=15, color='green', line_color='blue', source=s2)
p5.xaxis.axis_label ="Period"
p5.yaxis.axis_label ="Period Derivative"
p5.background_fill_color='black'
p5.xaxis.major_label_text_color = "green"
p5.yaxis.major_label_text_color = "green"

toggle = Button(label="Add Point", type="success", callback=callback)
inputs = vplot(plsri, rw_prfi, pdi, pd_deri, toggle)
display= hplot(p5, inputs)

show(display)

Le 19/03/2016 23:59, Sandeep Bharti a écrit :
Hi,

I didn't got any response from anyone regarding my issue. Here is the
pastebin for the piece of code in which I am facing problem
( http://pastebin.com/sEUqSgzD ). I will be really thankful for your help.

Sandy.

On Thu, Mar 17, 2016 at 10:13 PM, Sandeep Bharti > <[email protected] <mailto:[email protected]>> wrote:

    Hi Bryan,

    I have a plot for parameters say x and y with few other parameters
      a,b and c. I want the user to input values for all the parameters
    on a browser and with a click of a button it should plot the newly
    added point in the plot on the browser itself. I used TextInput to
    get the input from the user and also made a button to update the
    plot but I am not able to achieve it. I need assistance on this one.
    Tell me if you want more specific explanation.

    Many Thanks,
    Sandy

    On Thu, Mar 17, 2016 at 6:59 PM, Bryan Van de Ven > <[email protected] <mailto:[email protected]>> wrote:

        Hi Sandy,

        This is pretty general and non-specific, it's hard to give any
        concrete guidance. Can you provide more details, e.g. what sort
        of data is to be input, what kind of user interaction you are
        looking to have, and what exactly you have tried so far?

        Thanks,

        Bryan

         > On Mar 16, 2016, at 5:28 PM, alphasandy > <[email protected] <mailto:[email protected]>> wrote:
         >
         > Hi,
         >
         > I have been trying to get the user input from the user and
        trying to put it into the plot with a button click or so but I
        am not able to do that. Also I want to update the point values
        in the plot with the user given values. I tried various things
        like CustomJS and callback but it did not worked for me. Can
        anyone help me with this?
         > I will be really thankful. :slight_smile:
         >
         > Many Thanks,
         > Sandy
         >
         > --
         > You received this message because you are subscribed to the
        Google Groups "Bokeh Discussion - Public" group.
         > To unsubscribe from this group and stop receiving emails from
        it, send an email to [email protected]
        <mailto:bokeh%[email protected]>.
         > To post to this group, send email to [email protected]
        <mailto:[email protected]>.
         > To view this discussion on the web visit
        https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io\.
         > For more options, visit
        https://groups.google.com/a/continuum.io/d/optout\.

        --
        You received this message because you are subscribed to the
        Google Groups "Bokeh Discussion - Public" group.
        To unsubscribe from this group and stop receiving emails from
        it, send an email to [email protected]
        <mailto:bokeh%[email protected]>.
        To post to this group, send email to [email protected]
        <mailto:[email protected]>.
        To view this discussion on the web visit
        https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io\.
        For more options, visit
        https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google
Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/56EFC3E4.2070604%40gmail.com\.

For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMyT0pSF4JDq%2BL4qorgbd-QbcYCDdWpuxX%2BXBVBHVf3exA%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Sandy,

As Bryan already replied, data are not keep if you refresh a static web page.

However, if you want to delete a point with to delete a point with TapTool, you can add something like that (it's dirty but it works...), and then add "tap" to your plot

Jean

···

------------------------------------------------------------------------
tap_callback = CustomJS(args=dict(source=s2),
                     code="""
                     var data = source.get('data');
                     var index = cb_obj.get('selected')['1d'].indices[0];
                     for (var prop in data) {
                     data[prop].splice(index, 1);
                     }
                     cb_obj.set('selected', );
                     source.trigger('change');
                     """)

tap = TapTool(callback=tap_callback)

Le 21/03/2016 14:19, Bryan Van de Ven a écrit :

There is not really any way to persist information like that in a static web page.

If you want something like this, you will have to take steps to make sure the data is persisted elsewhere (and also re-used by the plot). There are a couple of possibilities I can think of:

* use the JS callback to send data to some server that has a REST API that can store the data in a database or whatever, and probably use AjaxDataSource to pull the current most up to date data from the REST API when the plot is loaded.

* Use a Bokeh server, and have the python Bokeh Application code store things in a database or whatever (you would not use JS callback in this case, you'd use python server callbacks). This approach could range from fairly simple if there is no concept of "users" or different states/data for each user, to very complex, if you need to deal with users, authentication, having different views depending on the user, etc. You can find a more in depth example involving those sorts of things here, for reference:

  https://github.com/bokeh/bokeh-demos/tree/master/happiness

It occurs to me there might be a third possibility:

* use the JS callback to store data in a cookie. I'm not sure if this is a good or bad idea, or really how to go about it (maybe others do). Also there's not currently any "on load" lifecycle hook for a Bokeh plot, so it would probably also involve writing a custom extension to Bokeh to accomplish, as well.

Thanks,

Bryan

On Mar 21, 2016, at 5:43 AM, Sandeep Bharti <[email protected]> wrote:

Hi Jean,

Thanks for your time, I appreciate your help. :slight_smile:
  I am exactly trying to do what you have written in the code but unfortunately the point that is being added from the inputs is not permanent, it gets vanished after page gets refreshed. Is there any way to put the input permanently in the plot?
Also I will be really thankful if you can tell me whether is it possible to delete points and modify the parameters of a point from the plot by writing CustomJs for Taptool?

Really Thanks for your help.

Sandy

On Mon, Mar 21, 2016 at 3:20 PM, Jean Felder <[email protected]> wrote:
Hi Sandy,

I'm not sure exactly what you're trying to achieve here.
Anyway, here is a working exemple. I hope it helps.
- you need to add your textinput and button to the plot to display it
- callback written with CustomJS
- added an initial x_range and y_range to the plot
- s2 ColumnDataSource is initially empty

Jean

----------------------------------------------------------------------

from bokeh.models import CustomJS, Range1d
from bokeh.models.sources import ColumnDataSource
from bokeh.models.tools import HoverTool, PanTool, BoxSelectTool, WheelZoomTool, BoxZoomTool, ResetTool
from bokeh.models.widgets import TextInput, Button
from bokeh.plotting import figure, show, output_file, vplot, hplot

output_file("adding_points.html")

s2= ColumnDataSource( #the data is fetched and manipulated from a csv file
         data=dict(
             plsr1=,
             rw_prf1=,
             pd1=,
             pd_der1=,
         )
     )

plsri = TextInput(value=" ", title="Puls:") #takes the input
rw_prfi= TextInput(value=" ", title="Prof:")
pdi = TextInput(value=" ", title="Pd:")
pd_deri = TextInput(value=" ", title="Pd Derv:")

callback = CustomJS(args=dict(source=s2,
                               plsr=plsri,
                               rw_prf=rw_prfi,
                               pd=pdi,
                               pd_der=pd_deri),
                     code="""
                     var data = source.get('data');
                     data['plsr1'].push(plsr.get('value'))
                     data['rw_prf1'].push(rw_prf.get('value'))
                     data['pd1'].push(pd.get('value'))
                     data['pd_der1'].push(pd_der.get('value'))
                     source.trigger('change');
                     """)

hover1 = HoverTool(tooltips=[
             ("Pulsar", "@plsr1"),
             ("Raw Profiles", "@rw_prf1"),
             ("Period","@pd1"),
             ("Period Derivative","@pd_der1"),
]
)
tool1=[PanTool(),BoxSelectTool(),hover1,WheelZoomTool(),BoxZoomTool(),ResetTool()]

p5= figure(plot_width=800, plot_height=500,tools=tool1, title="Point Plot",
            x_range=Range1d(-10,10, bounds=None), y_range=Range1d(-10,10, bounds=None))
p5.circle('pd1', 'pd_der1', size=15, color='green', line_color='blue', source=s2)
p5.xaxis.axis_label ="Period"
p5.yaxis.axis_label ="Period Derivative"
p5.background_fill_color='black'
p5.xaxis.major_label_text_color = "green"
p5.yaxis.major_label_text_color = "green"

toggle = Button(label="Add Point", type="success", callback=callback)
inputs = vplot(plsri, rw_prfi, pdi, pd_deri, toggle)
display= hplot(p5, inputs)

show(display)

Le 19/03/2016 23:59, Sandeep Bharti a écrit :
Hi,

I didn't got any response from anyone regarding my issue. Here is the
pastebin for the piece of code in which I am facing problem
( http://pastebin.com/sEUqSgzD ). I will be really thankful for your help.

Sandy.

On Thu, Mar 17, 2016 at 10:13 PM, Sandeep Bharti >> <[email protected] <mailto:[email protected]>> wrote:

     Hi Bryan,

     I have a plot for parameters say x and y with few other parameters
       a,b and c. I want the user to input values for all the parameters
     on a browser and with a click of a button it should plot the newly
     added point in the plot on the browser itself. I used TextInput to
     get the input from the user and also made a button to update the
     plot but I am not able to achieve it. I need assistance on this one.
     Tell me if you want more specific explanation.

     Many Thanks,
     Sandy

     On Thu, Mar 17, 2016 at 6:59 PM, Bryan Van de Ven >> <[email protected] <mailto:[email protected]>> wrote:

         Hi Sandy,

         This is pretty general and non-specific, it's hard to give any
         concrete guidance. Can you provide more details, e.g. what sort
         of data is to be input, what kind of user interaction you are
         looking to have, and what exactly you have tried so far?

         Thanks,

         Bryan

          > On Mar 16, 2016, at 5:28 PM, alphasandy >> <[email protected] <mailto:[email protected]>> wrote:
          >
          > Hi,
          >
          > I have been trying to get the user input from the user and
         trying to put it into the plot with a button click or so but I
         am not able to do that. Also I want to update the point values
         in the plot with the user given values. I tried various things
         like CustomJS and callback but it did not worked for me. Can
         anyone help me with this?
          > I will be really thankful. :slight_smile:
          >
          > Many Thanks,
          > Sandy
          >
          > --
          > You received this message because you are subscribed to the
         Google Groups "Bokeh Discussion - Public" group.
          > To unsubscribe from this group and stop receiving emails from
         it, send an email to [email protected]
         <mailto:bokeh%[email protected]>.
          > To post to this group, send email to [email protected]
         <mailto:[email protected]>.
          > To view this discussion on the web visit
         https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io\.
          > For more options, visit
         https://groups.google.com/a/continuum.io/d/optout\.

         --
         You received this message because you are subscribed to the
         Google Groups "Bokeh Discussion - Public" group.
         To unsubscribe from this group and stop receiving emails from
         it, send an email to [email protected]
         <mailto:bokeh%[email protected]>.
         To post to this group, send email to [email protected]
         <mailto:[email protected]>.
         To view this discussion on the web visit
         https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io\.
         For more options, visit
         https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google
Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/56EFC3E4.2070604%40gmail.com\.

For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMyT0pSF4JDq%2BL4qorgbd-QbcYCDdWpuxX%2BXBVBHVf3exA%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.