[Answered ]-Create dynamic labels for Google Chart using GChartWrapper

2πŸ‘

βœ…

In order to understand how to properly pass the labels it’s important to know what *args means.

*args (which is an asterisk + an arbitrary argument name) in a function (or method as in this case) definition means any number (including 0) of anonymous arguments.

See this answer for a more thorough explanation.

This means that the method in question accepts one obligatory argument index which is the index of the axis to be labelled and any number of anonymous arguments (actual labels).

Knowing this, it should already be clear that the proper way to call label() is as follows:

chart.axes.label( 0, 'date 1', 'date 2', 'date 3', ... )

where 0 is the index of the X-axis and all the other arguments are respective labels.

The reason why this is implemented in this manner is that the number of lables is unknown – it depends on the chart, so accepting any number of labels seems like a good idea.

You may also want to take a look at the example here

πŸ‘€kgr

Leave a comment