Skip to content

Commit

Permalink
show x-axis labels in hover, closes #557
Browse files Browse the repository at this point in the history
  • Loading branch information
pld committed Jun 1, 2013
1 parent fb0e5f2 commit 256a5c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions external/bearcart/bearcart.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(self, data=None, width=750, height=400, plt_type='line',
render_vars = self.make_ticks(val)
elif att == 'hover':
render_vars = {'x_hover': 'xFormatter: function(x)'
'{return Math.floor(x / 10) * 10}'}
'{return xTicks[x]}'}
temp = self.env.get_template(att + '.js')
self.template_vars.update({att: temp.render(render_vars)})

Expand All @@ -116,7 +116,8 @@ def make_ticks(self, axis):
self.template_vars['transform'] = (
"rotateText();$('#legend').bind('click',rotateText);")
cases = ','.join(["%s:'%s'" % (i, v) for i, v in enumerate(axis)])
return {'ticks': 'tickFormat:function(x){return{%s}[x]},' % cases}
return {'xTicks': 'var xTicks = {%s};' % cases,
'ticks': 'tickFormat:function(x){return xTicks[x]},'}

def transform_data(self, data):
'''Transform Pandas Timeseries into JSON format
Expand Down
2 changes: 2 additions & 0 deletions external/bearcart/templates/x_axis_num.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ xTicks }}

var x_axis = new Rickshaw.Graph.Axis.X( {
graph: graph,
orientation: 'bottom',
Expand Down

0 comments on commit 256a5c0

Please sign in to comment.