{"action":"created","issue":{"url":"https://api.github.com/repos/bokeh/bokeh/issues/3771","repository_url":"https://api.github.com/repos/bokeh/bokeh","labels_url":"https://api.github.com/repos/bokeh/bokeh/issues/3771/labels{/name}","comments_url":"https://api.github.com/repos/bokeh/bokeh/issues/3771/comments","events_url":"https://api.github.com/repos/bokeh/bokeh/issues/3771/events","html_url":"https://github.com/bokeh/bokeh/issues/3771","id":129420975,"number":3771,"title":"BokehJS - get_model_by_name() - multiple name error","user":{"login":"jeffreyjharris","id":1056149,"avatar_url":"https://avatars.githubusercontent.com/u/1056149?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffreyjharris","html_url":"https://github.com/jeffreyjharris","followers_url":"https://api.github.com/users/jeffreyjharris/followers","following_url":"https://api.github.com/users/jeffreyjharris/following{/other_user}","gists_url":"https://api.github.com/users/jeffreyjharris/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffreyjharris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffreyjharris/subscriptions","organizations_url":"https://api.github.com/users/jeffreyjharris/orgs","repos_url":"https://api.github.com/users/jeffreyjharris/repos","events_url":"https://api.github.com/users/jeffreyjharris/events{/privacy}","received_events_url":"https://api.github.com/users/jeffreyjharris/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bokeh/bokeh/labels/type:%20discussion","name":"type: discussion","color":"2659A0"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-01-28T11:15:15Z","updated_at":"2016-07-03T05:18:47Z","closed_at":"2016-07-03T05:18:47Z","body":"The 'name' property for a single named ColumnDataSource is getting added for each glyph in a plot. As a result, get_model_by_name() in javascript fails with an error.\r\n\r\n**Example**:\r\nIn Python define a single ColumnDataSource with a 'name' property as the source for 2 glyphs:\r\n```\r\nx = list(range(-20, 21))\r\ny = [abs(xx) for xx in x]\r\nsource = ColumnDataSource(data=dict(x=x, y=y),name='something')\r\np = figure(tools=TOOLS, width=300, height=300)\r\np.circle('x', 'y0', source=source)\r\np.line('x', 'y0', source=source)\r\nshow(p)\r\n```\r\n\r\nIn Javascript attempt to access the single ColumnDataSource  by name.  get_model_by_name() errors as the name appears multiple times:  \r\n```\r\n var source_name = 'something';\r\n var plot_ids = Bokeh._.keys(Bokeh.index)\r\n for (i = 0; i < plot_ids.length; i++) {\r\n    var plot = Bokeh.index[plot_ids[i]]\r\n    var d  = plot.model.document.get_model_by_name(source_name)   // error here.\r\n    if( d != null ) { \r\n        \t\tmy_data = d.attributes.data\r\n    }\r\n }\r\n```\r\n\r\nEnvironment:\r\nMac: OS X Yosemite (10.10.5)\r\nBokeh: 0.11.0\r\nBrowser: Safari (9.02)\r\nGenerating plot from spyder 2.3.8; python 3.5; conda environment.\r\n\r\nIf there is only a single glyph on the plot the above works, but fails with 2 or more glyphs referencing the same ColumnDataSource."},"comment":{"url":"https://api.github.com/repos/bokeh/bokeh/issues/comments/230136146","html_url":"https://github.com/bokeh/bokeh/issues/3771#issuecomment-230136146","issue_url":"https://api.github.com/repos/bokeh/bokeh/issues/3771","id":230136146,"user":{"login":"bryevdv","id":1078448,"avatar_url":"https://avatars.githubusercontent.com/u/1078448?v=3","gravatar_id":"","url":"https://api.github.com/users/bryevdv","html_url":"https://github.com/bryevdv","followers_url":"https://api.github.com/users/bryevdv/followers","following_url":"https://api.github.com/users/bryevdv/following{/other_user}","gists_url":"https://api.github.com/users/bryevdv/gists{/gist_id}","starred_url":"https://api.github.com/users/bryevdv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryevdv/subscriptions","organizations_url":"https://api.github.com/users/bryevdv/orgs","repos_url":"https://api.github.com/users/bryevdv/repos","events_url":"https://api.github.com/users/bryevdv/events{/privacy}","received_events_url":"https://api.github.com/users/bryevdv/received_events","type":"User","site_admin":false},"created_at":"2016-07-03T05:18:47Z","updated_at":"2016-07-03T05:18:47Z","body":"fixed at some point, this code working in `0.12`\r\n```\r\nfrom bokeh.models import ColumnDataSource\r\nfrom bokeh.plotting import figure, show\r\nx = list(range(-20, 21))\r\ny = [abs(xx) for xx in x]\r\nsource = ColumnDataSource(data=dict(x=x, y=y),name='something')\r\np = figure(tools=\"pan\", width=300, height=300)\r\np.circle('x', 'y', source=source)\r\np.line('x', 'y', source=source)\r\nshow(p)\r\n```\r\n<img width=\"307\" alt=\"screen shot 2016-07-03 at 12 17 54 am\" src=\"https://cloud.githubusercontent.com/assets/1078448/16543872/b4c0397a-40b3-11e6-97e1-a14c07e8de5c.png\">\r\n"}}
{"actor":{"display_login":"bryevdv"}}