Skip to content
This repository has been archived by the owner on Nov 25, 2017. It is now read-only.

Commit

Permalink
Fix for exception when hiding an axis
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza Daly committed Jan 22, 2009
1 parent aad7c0f commit fcaceb3
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions templatetags/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ def url(self):
for i, axis in enumerate(self.axes):
axis_sides.append(axis.side)
for opt in axis.options:
axis_options.setdefault(opt, []).append(axis.options[opt] % i)
try:
axis_options.setdefault(opt, []).append(axis.options[opt] % i)
except TypeError:
pass

# Turn the option lists into strings
axis_sides = smart_join(",", *axis_sides)
Expand Down Expand Up @@ -352,11 +355,6 @@ def chart_colors(*args):
def chart_bar_colors(*args):
return {"chco": smart_join("|", *args)}

#@option('chart-external')
#def chart_external(chart_name, color, item_label_list):
# chart_color_data = chart_auto_colors(color, item_label_list) + { 'chart_name' : '_%s' % chart_name }
# return chart_color_data

@option("chart-auto-colors")
def chart_auto_colors(color, item_label_list):
'''Takes a starting color and a list of labels and creates the correct number of
Expand Down Expand Up @@ -587,7 +585,7 @@ def chart_map_data(data):
"chld": smart_join("", *place_list),
"_mapdata": value_list
}

#
# {% axis %}
#
Expand Down Expand Up @@ -624,7 +622,12 @@ class AxisNode(template.Node):
def __init__(self, side, nodelist=None):
self.side = side
self.nodelist = nodelist

if not self.nodelist:
# Crazy horrible hack to stop deep runtime error
class n():
def get_nodes_by_type(x,y): return []
self.nodelist = n()

def render(self, context):
return ''

Expand All @@ -646,10 +649,10 @@ def get_axis(self, context):

class NoAxisNode(AxisNode):
def resolve(self, context):
axis = self.get_axis(context)
axis.options["chxs"] = "%s,000000,11,0,_"
axis.options["chxl"] = "%s:||"
return axis
a = self.get_axis(context)
a.options["chxs"] = "%s,000000,11,0,_"
a.options["chxl"] = "%s:||"
return a

class Axis(object):
def __init__(self, side):
Expand Down Expand Up @@ -681,7 +684,7 @@ def axis_range(start, end):
def axis_style(color, font_size=None, alignment=None):
alignment = alignments.get(alignment, alignment)
return {"chxs": smart_join(",", "%s", color, font_size, alignment)}

#
# "Metadata" nodes
#
Expand Down

0 comments on commit fcaceb3

Please sign in to comment.