Repository: bokeh/bokeh

Issue:
Expand elements example with tooltip
# READ AND FOLLOW THESE INSTRUCTIONS CAREFULLY

For feature requests, please provide a detailed description or proposal of the new capability or behavior.

type: feature

tag: examples

status: ready


The elements example shows atomic elements code, weight, density, and melting point. It can be enhanced by a tooltip which shows these values numerically, and also gives the full name for each element. Example:
![screenshot_2018-02-07_10-14-52 new_bokeh](https://user-images.githubusercontent.com/11770594/35908010-cdd0e320-0bef-11e8-8e3b-97e8923255b1.png)

No test, as this is just an example. Screenshot shows that it works.

> DO follow our coding style.
 
Googling bokeh coding style did not yield results. Where is that written down? (some pylint messages were fixed in [the branch](https://github.com/serv-inc/bokeh/tree/patch-1))

Expand elements example with tooltip
# READ AND FOLLOW THESE INSTRUCTIONS CAREFULLY

For feature requests, please provide a detailed description or proposal of the new capability or behavior.

type: feature

tag: examples

status: ready


The elements example shows atomic elements code, weight, density, and melting point. It can be enhanced by a tooltip which shows these values numerically, and also gives the full name for each element. Example:
![screenshot_2018-02-07_10-14-52 new_bokeh](https://user-images.githubusercontent.com/11770594/35908010-cdd0e320-0bef-11e8-8e3b-97e8923255b1.png)

No test, as this is just an example. Screenshot shows that it works.

> DO follow our coding style.
 
Googling bokeh coding style did not yield results. Where is that written down? (some pylint messages were fixed in [the branch](https://github.com/serv-inc/bokeh/tree/patch-1))



Discussion:

Resolving patch:
diff --git a/examples/plotting/file/elements.py b/examples/plotting/file/elements.py
--- a/examples/plotting/file/elements.py
+++ b/examples/plotting/file/elements.py
@@ -1,6 +1,6 @@
 import pandas as pd
 
-from bokeh.models import ColumnDataSource, LabelSet
+from bokeh.models import ColumnDataSource, LabelSet, HoverTool
 from bokeh.plotting import figure, show, output_file
 from bokeh.sampledata.periodic_table import elements
 
@@ -15,18 +15,26 @@
 
 melting_points = elements["melting point"]
 low = min(melting_points)
-high= max(melting_points)
+high = max(melting_points)
 melting_point_inds = [int(10*(x-low)/(high-low)) for x in melting_points] #gives items in colors a value from 0-10
 elements['melting_colors'] = [palette[i] for i in melting_point_inds]
 
-TOOLS = "pan,wheel_zoom,box_zoom,reset,save"
 TITLE = "Density vs Atomic Weight of Elements (colored by melting point)"
-
-p = figure(tools=TOOLS, toolbar_location="above", logo="grey", plot_width=1200, title=TITLE)
-p.background_fill_color= "#dddddd"
-p.xaxis.axis_label="atomic weight (amu)"
-p.yaxis.axis_label="density (g/cm^3)"
-p.grid.grid_line_color="white"
+tools = "pan,wheel_zoom,box_zoom,reset,save".split(',')
+hover = HoverTool(tooltips=[
+    ("name", "@name"),
+    ("symbol:", "@symbol"),
+    ("density", "@density"),
+    ("atomic weight", "@{atomic mass}"),
+    ("melting point", "@{melting point}")
+])
+tools.append(hover)
+
+p = figure(tools=tools, toolbar_location="above", logo="grey", plot_width=1200, title=TITLE)
+p.background_fill_color = "#dddddd"
+p.xaxis.axis_label = "atomic weight (amu)"
+p.yaxis.axis_label = "density (g/cm^3)"
+p.grid.grid_line_color = "white"
 
 source = ColumnDataSource(elements)
 


Test patch: