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

Commit

Permalink
Added option
Browse files Browse the repository at this point in the history
  • Loading branch information
tupperware14 committed Jan 18, 2009
1 parent 5ad0cc2 commit 2773006
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions googlecharts/templatetags/charts.py
Expand Up @@ -428,6 +428,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}
Expand Down

0 comments on commit 2773006

Please sign in to comment.