Axes argument list

24 views
Skip to first unread message

Tim Welch

unread,
Mar 17, 2009, 8:09:01 PM3/17/09
to GChartWrapper
Hey folks,

I have a list of strings I'd like to use as axes labels. The values
are dynamic in that the number of labels and their value vary each
time I generate the chart.

My issue is it seems the Chart.axes.label method only accepts an
argument list where each label is specificed individually as an
argument. Eg.

def label(self, *args):
label = '|'.join(map(str,args)).

This works great if your labels are static and you know them all, but
my labels vary each time. Unless there's a way to use a list as a
method argument list it seems this method should be able to accept a
list of labels instead. For example:

def label(self, list):
label = '|'.join(map(str,list)).

Please enlighten me if the current method supports my use case. Thank
you much for your contribution of this project.

Tim

justin quick

unread,
Mar 18, 2009, 9:37:55 AM3/18/09
to gchart...@googlegroups.com
Tim,

This is not so much of a problem with the API, but rather how you
are using it. If you have dynamic labels or any kind of data for that
matter, the easiest thing to do is create a function that returns a
list of all of them. Here is an example of one that generates a list
of random numbers

def generate_list():
list = []
for i in range(10):
list.append(random.randint(0,10))
return list

You would then use it with the wrapper like so

G.label(*generate_list())

Notice the *, that means to pass the items in a list as arguments to
the function. It works for static lists too: G.label(*[1,2,3,4,5])

I hope that this clears it up!

Justin

Tim Welch

unread,
Mar 18, 2009, 10:39:15 AM3/18/09
to gchart...@googlegroups.com
Thanks Justin.
Reply all
Reply to author
Forward
0 new messages