prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Checkbox example is not working as expected
  The new checkbox example in master (examples/plotting/file/line_on_off.py) is not working as expected, the plotted lines are depend on how many checkbox are ticked and not on which one. The reason is that the js code is not checking for the values but for the existence of the index.
  
  I have a fix for this with a PR coming, and opening this only as an associated issue.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `examples/plotting/file/line_on_off.py`
  Content:
  ```
  1 """ Example demonstrating turning lines on and off - with JS only
  2 
  3 """
  4 
  5 import numpy as np
  6 
  7 from bokeh.io import output_file, show
  8 from bokeh.layouts import row
  9 from bokeh.palettes import Viridis3
  10 from bokeh.plotting import figure
  11 from bokeh.models import CheckboxGroup, CustomJS
  12 
  13 output_file("line_on_off.html", title="line_on_off.py example")
  14 
  15 code = """
  16     if (0 in checkbox.active) {
  17         l0.visible = true
  18     } else {
  19         l0.visible = false
  20     }
  21     if (1 in checkbox.active) {
  22         l1.visible = true
  23     } else {
  24         l1.visible = false
  25     }
  26     if (2 in checkbox.active) {
  27         l2.visible = true
  28     } else {
  29         l2.visible = false
  30     }
  31 """
  32 
  33 p = figure()
  34 props = dict(line_width=4, line_alpha=0.7)
  35 x = np.linspace(0, 4 * np.pi, 100)
  36 l0 = p.line(x, np.sin(x), color=Viridis3[0], legend="Line 0", **props)
  37 l1 = p.line(x, 4 * np.cos(x), color=Viridis3[1], legend="Line 1", **props)
  38 l2 = p.line(x, np.tan(x), color=Viridis3[2], legend="Line 2", **props)
  39 
  40 callback = CustomJS(code=code, args={})
  41 checkbox = CheckboxGroup(labels=["Line 0", "Line 1", "Line 2"], active=[0, 1, 2], callback=callback, width=100)
  42 callback.args = dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox)
  43 
  44 layout = row(checkbox, p)
  45 show(layout)
  46
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/examples/plotting/file/line_on_off.py b/examples/plotting/file/line_on_off.py
  --- a/examples/plotting/file/line_on_off.py
  +++ b/examples/plotting/file/line_on_off.py
  @@ -12,24 +12,6 @@
   
   output_file("line_on_off.html", title="line_on_off.py example")
   
  -code = """
  -    if (0 in checkbox.active) {
  -        l0.visible = true
  -    } else {
  -        l0.visible = false
  -    }
  -    if (1 in checkbox.active) {
  -        l1.visible = true
  -    } else {
  -        l1.visible = false
  -    }
  -    if (2 in checkbox.active) {
  -        l2.visible = true
  -    } else {
  -        l2.visible = false
  -    }
  -"""
  -
   p = figure()
   props = dict(line_width=4, line_alpha=0.7)
   x = np.linspace(0, 4 * np.pi, 100)
  @@ -37,9 +19,14 @@
   l1 = p.line(x, 4 * np.cos(x), color=Viridis3[1], legend="Line 1", **props)
   l2 = p.line(x, np.tan(x), color=Viridis3[2], legend="Line 2", **props)
   
  -callback = CustomJS(code=code, args={})
  -checkbox = CheckboxGroup(labels=["Line 0", "Line 1", "Line 2"], active=[0, 1, 2], callback=callback, width=100)
  -callback.args = dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox)
  +checkbox = CheckboxGroup(labels=["Line 0", "Line 1", "Line 2"],
  +                         active=[0, 1, 2], width=100)
  +checkbox.callback = CustomJS(args=dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox),
  +                             lang="coffeescript", code="""
  +l0.visible = 0 in checkbox.active;
  +l1.visible = 1 in checkbox.active;
  +l2.visible = 2 in checkbox.active;
  +""")
   
   layout = row(checkbox, p)
   show(layout)
  
verification_info: {"golden_diff": "diff --git a/examples/plotting/file/line_on_off.py b/examples/plotting/file/line_on_off.py\n--- a/examples/plotting/file/line_on_off.py\n+++ b/examples/plotting/file/line_on_off.py\n@@ -12,24 +12,6 @@\n \n output_file(\"line_on_off.html\", title=\"line_on_off.py example\")\n \n-code = \"\"\"\n-    if (0 in checkbox.active) {\n-        l0.visible = true\n-    } else {\n-        l0.visible = false\n-    }\n-    if (1 in checkbox.active) {\n-        l1.visible = true\n-    } else {\n-        l1.visible = false\n-    }\n-    if (2 in checkbox.active) {\n-        l2.visible = true\n-    } else {\n-        l2.visible = false\n-    }\n-\"\"\"\n-\n p = figure()\n props = dict(line_width=4, line_alpha=0.7)\n x = np.linspace(0, 4 * np.pi, 100)\n@@ -37,9 +19,14 @@\n l1 = p.line(x, 4 * np.cos(x), color=Viridis3[1], legend=\"Line 1\", **props)\n l2 = p.line(x, np.tan(x), color=Viridis3[2], legend=\"Line 2\", **props)\n \n-callback = CustomJS(code=code, args={})\n-checkbox = CheckboxGroup(labels=[\"Line 0\", \"Line 1\", \"Line 2\"], active=[0, 1, 2], callback=callback, width=100)\n-callback.args = dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox)\n+checkbox = CheckboxGroup(labels=[\"Line 0\", \"Line 1\", \"Line 2\"],\n+                         active=[0, 1, 2], width=100)\n+checkbox.callback = CustomJS(args=dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox),\n+                             lang=\"coffeescript\", code=\"\"\"\n+l0.visible = 0 in checkbox.active;\n+l1.visible = 1 in checkbox.active;\n+l2.visible = 2 in checkbox.active;\n+\"\"\")\n \n layout = row(checkbox, p)\n show(layout)\n", "issue": "Checkbox example is not working as expected\nThe new checkbox example in master (examples/plotting/file/line_on_off.py) is not working as expected, the plotted lines are depend on how many checkbox are ticked and not on which one. The reason is that the js code is not checking for the values but for the existence of the index.\n\nI have a fix for this with a PR coming, and opening this only as an associated issue.\n\n", "before_files": [{"content": "\"\"\" Example demonstrating turning lines on and off - with JS only\n\n\"\"\"\n\nimport numpy as np\n\nfrom bokeh.io import output_file, show\nfrom bokeh.layouts import row\nfrom bokeh.palettes import Viridis3\nfrom bokeh.plotting import figure\nfrom bokeh.models import CheckboxGroup, CustomJS\n\noutput_file(\"line_on_off.html\", title=\"line_on_off.py example\")\n\ncode = \"\"\"\n    if (0 in checkbox.active) {\n        l0.visible = true\n    } else {\n        l0.visible = false\n    }\n    if (1 in checkbox.active) {\n        l1.visible = true\n    } else {\n        l1.visible = false\n    }\n    if (2 in checkbox.active) {\n        l2.visible = true\n    } else {\n        l2.visible = false\n    }\n\"\"\"\n\np = figure()\nprops = dict(line_width=4, line_alpha=0.7)\nx = np.linspace(0, 4 * np.pi, 100)\nl0 = p.line(x, np.sin(x), color=Viridis3[0], legend=\"Line 0\", **props)\nl1 = p.line(x, 4 * np.cos(x), color=Viridis3[1], legend=\"Line 1\", **props)\nl2 = p.line(x, np.tan(x), color=Viridis3[2], legend=\"Line 2\", **props)\n\ncallback = CustomJS(code=code, args={})\ncheckbox = CheckboxGroup(labels=[\"Line 0\", \"Line 1\", \"Line 2\"], active=[0, 1, 2], callback=callback, width=100)\ncallback.args = dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox)\n\nlayout = row(checkbox, p)\nshow(layout)\n", "path": "examples/plotting/file/line_on_off.py"}], "after_files": [{"content": "\"\"\" Example demonstrating turning lines on and off - with JS only\n\n\"\"\"\n\nimport numpy as np\n\nfrom bokeh.io import output_file, show\nfrom bokeh.layouts import row\nfrom bokeh.palettes import Viridis3\nfrom bokeh.plotting import figure\nfrom bokeh.models import CheckboxGroup, CustomJS\n\noutput_file(\"line_on_off.html\", title=\"line_on_off.py example\")\n\np = figure()\nprops = dict(line_width=4, line_alpha=0.7)\nx = np.linspace(0, 4 * np.pi, 100)\nl0 = p.line(x, np.sin(x), color=Viridis3[0], legend=\"Line 0\", **props)\nl1 = p.line(x, 4 * np.cos(x), color=Viridis3[1], legend=\"Line 1\", **props)\nl2 = p.line(x, np.tan(x), color=Viridis3[2], legend=\"Line 2\", **props)\n\ncheckbox = CheckboxGroup(labels=[\"Line 0\", \"Line 1\", \"Line 2\"],\n                         active=[0, 1, 2], width=100)\ncheckbox.callback = CustomJS(args=dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox),\n                             lang=\"coffeescript\", code=\"\"\"\nl0.visible = 0 in checkbox.active;\nl1.visible = 1 in checkbox.active;\nl2.visible = 2 in checkbox.active;\n\"\"\")\n\nlayout = row(checkbox, p)\nshow(layout)\n", "path": "examples/plotting/file/line_on_off.py"}]}