Permalink
Browse files

Nicer tooltips above measures

  • Loading branch information...
1 parent c361f0d commit e5fae2328d433839b929dd2f815f6fb47389757f @reinout reinout committed Apr 13, 2012
@@ -14,6 +14,7 @@ TRIANGLE_COLOR = "#E78B00"
SQUARE_COLOR = "#122F64"
graphTimer = ''
+hasTooltip = ''
toggleMeasure = (measure_id) ->
@@ -213,15 +214,15 @@ Backbone.history.start()
#
# initialize: ->
-showTooltip = (x, y, contents) ->
- $("""<div id="tooltip">#{contents}</div>""").css(
- position: "absolute"
- display: "none"
+showTooltip = (x, y, name, type_name) ->
+ $("""<div id="tooltip" class="popover top">
+ <div class="popover-inner">
+ <div class="popover-title"><h3>#{name}</h3></div>
+ <div class="popover-content">Type: #{type_name}</div>
+ </div>
+ </div>""").css(
top: y - 35
left: x + 5
- border: "1px solid #fdd"
- padding: "2px"
- background: "#fee"
).appendTo("body").fadeIn 200
@@ -301,7 +302,7 @@ setPlaceholderTop = (json_data) ->
setPlaceholderControl = (control_data) ->
- measures = ([num.km_from, num.type_index, num.measure_graph_name, num.short_name] for num in control_data)
+ measures = ([num.km_from, num.type_index, num.name, num.short_name, num.measure_type] for num in control_data)
d4 = undefined
d5 = undefined
@@ -386,14 +387,16 @@ setPlaceholderControl = (control_data) ->
$("#placeholder_control").bind "plothover", (event, pos, item) ->
- if item
- $('#tooltip').remove()
+ if item and not hasTooltip
showTooltip(
item.pageX,
item.pageY,
item.series.data[item.dataIndex][2]
+ item.series.data[item.dataIndex][4]
)
+ hasTooltip = 'yep'
else
+ hasTooltip = ''
$('#tooltip').remove()
options =

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -47,6 +47,7 @@ def selected_measures(self):
result.append(measure)
return result
+
def reference_json(request):
"""Fetch the reference and target values for all rivers and JSON them.
"""
@@ -140,8 +141,6 @@ def list_measures_json(request):
selected = measure['short_name'] in selected_measures
measure['selected'] = selected
measure['type_index'] = all_types.index(measure['measure_type'])
- measure['measure_graph_name'] = '%s (%s)' % (
- measure['name'], measure['measure_type'])
response = HttpResponse(mimetype='application/json')
json.dump(list(measures), response)
return response

0 comments on commit e5fae23

Please sign in to comment.