Skip to content
Browse files

Merge commit 'palewire/master'

Conflicts:

	templatetags/charts.py
  • Loading branch information...
2 parents 5cc53b8 + bd58fc1 commit b1ef2060efaf553fa2c060aa17509b37466685c6 @chrisdrackett chrisdrackett committed
Showing with 41 additions and 2 deletions.
  1. +41 −2 templatetags/charts.py
View
43 templatetags/charts.py
@@ -340,10 +340,17 @@ def chart_type(arg):
}
return {"cht": types.get(arg, arg)}
+@option("chart-data-scale", multi=",")
+def chart_data_scale(*args):
+ return {"chds": smart_join(",", *args)}
+
@option("chart-colors", multi=",")
def chart_colors(*args):
- chco = smart_join(",", *args)
- return {"chco": chco }
+ return {"chco": smart_join(",", *args)}
+
+@option("chart-bar-colors", multi="|")
+def chart_bar_colors(*args):
+ return {"chco": smart_join("|", *args)}
#@option('chart-external')
#def chart_external(chart_name, color, item_label_list):
@@ -533,6 +540,38 @@ def chart_markers(dataset_index, iterable):
return {"chm": smart_join("|", *flatten(markers))}
+
+label_types = {
+ 'flag': 'f',
+ 'text': 't',
+ 'number': 'N',
+}
+
+@option("data-point-labels", multi="|")
+def data_point_labels(dataset_index, iterable):
+ """
+ Adds data labels as described here: http://code.google.com/apis/chart/labels.html#data_point_labels
+
+ You will need to provide an iterable yielding (label_type, label_contents, color, data_point, size, priority)
+
+ And keep in mind that flags and text labels require a very different `label_contents` than a set of numbers.
+ """
+ try:
+ it = iter(iterable)
+ except TypeError:
+ return {}
+
+ labels = []
+ for m in it:
+ try:
+ label_type, label_contents, color, data_point, size, priority = m
+ except ValueError:
+ continue
+ label = label_types.get(label_type, label_type)
+ labels.append(smart_join(",", label + label_contents, color, dataset_index, data_point, size, priority))
+
+ return {"chm": smart_join("|", *flatten(labels))}
+
@option("chart-map-area")
def chart_map_area(where):
return {'chtm': where}

0 comments on commit b1ef206

Please sign in to comment.
Something went wrong with that request. Please try again.