One series in the GraphiteGraph.
| 51 | |
| 52 | |
| 53 | class Series: |
| 54 | """One series in the GraphiteGraph.""" |
| 55 | |
| 56 | def __init__(self, name): |
| 57 | self.name = name |
| 58 | |
| 59 | def apply(self, funcname, *args): |
| 60 | """Applies a function to this series. |
| 61 | |
| 62 | :return: Returns self |
| 63 | """ |
| 64 | self.name = "{}({}, {})".format(funcname, self.name, ", ".join(repr(a) for a in args)) |
| 65 | return self |
| 66 | |
| 67 | def alias(self, name): |
| 68 | """Shorthand for calling s.apply("alias", name)""" |
| 69 | return self.apply("alias", name) |
| 70 | |
| 71 | def __repr__(self): |
| 72 | return "<series: %r>" % self.name |
| 73 | |
| 74 | def __str__(self): |
| 75 | # Returning empty string to allow template use $g.add("foo") without printing anything. |
| 76 | return "" |
| 77 | |
| 78 | |
| 79 | def setup(): |