# Path: pycha/color.py
# class ColorScheme(dict):
#     """A color scheme is a dictionary where the keys match the keys
#     constructor argument and the values are colors"""
# 
#     __metaclass__ = ColorSchemeMetaclass
#     __registry__ = {}
# 
#     def __init__(self, keys):
#         super(ColorScheme, self).__init__()
# 
#     @classmethod
#     def registerColorScheme(cls):
#         key = cls.__name__.replace('ColorScheme', '').lower()
#         if key:
#             cls.__registry__[key] = cls
# 
#     @classmethod
#     def getColorScheme(cls, name, default=None):
#         return cls.__registry__.get(name, default)
# 
# def hex2rgb(hexstring, digits=2):
#     """Converts a hexstring color to a rgb tuple.
# 
#     Example: #ff0000 -> (1.0, 0.0, 0.0)
# 
#     digits is an integer number telling how many characters should be
#     interpreted for each component in the hexstring.
#     """
#     if isinstance(hexstring, (tuple, list)):
#         return hexstring
# 
#     top = float(int(digits * 'f', 16))
#     r = int(hexstring[1:digits+1], 16)
#     g = int(hexstring[digits+1:digits*2+1], 16)
#     b = int(hexstring[digits*2+1:digits*3+1], 16)
#     return r / top, g / top, b / top
# 
# DEFAULT_COLOR = '#3c581a'
# 
# Path: pycha/utils.py
# def safe_unicode(obj, encoding=None):
#     """Return a unicode value from the argument"""
#     if isinstance(obj, unicode):
#         return obj
#     elif isinstance(obj, str):
#         if encoding is None:
#             return unicode(obj)
#         else:
#             return unicode(obj, encoding)
#     else:
#         # it may be an int or a float
#         return unicode(obj)


import copy
import inspect
import math
import cairo
from pycha.color import ColorScheme, hex2rgb, DEFAULT_COLOR
from pycha.utils import safe_unicode
            cx.move_to(-xb, -yb)
            cx.show_text(label)
            if self.debug:
                cx.rectangle(0, 0, width, height)
                cx.stroke()
        else:
            x = x - width / 2.0
            cx.move_to(x - xb, y - yb)
            cx.show_text(label)
            if self.debug:
                cx.rectangle(x, y, width, height)
                cx.stroke()
        cx.restore()

    def _renderYAxisLabel(self, cx, label_text):
        label = safe_unicode(label_text, self.options.encoding)
        x = self.layout.y_label.x
        y = self.layout.y_label.y + self.layout.y_label.h / 2.0
        self._renderAxisLabel(cx, label, x, y, True)

    def _renderYAxis(self, cx):
        """Draws the vertical line represeting the Y axis"""
        cx.new_path()
        cx.move_to(self.layout.chart.x, self.layout.chart.y)
        cx.line_to(self.layout.chart.x,
                   self.layout.chart.y + self.layout.chart.h)
        cx.close_path()
        cx.stroke()

    def _renderXAxisLabel(self, cx, label_text):

# Path: pycha/color.py
# class ColorScheme(dict):
#     """A color scheme is a dictionary where the keys match the keys
#     constructor argument and the values are colors"""
# 
#     __metaclass__ = ColorSchemeMetaclass
#     __registry__ = {}
# 
#     def __init__(self, keys):
#         super(ColorScheme, self).__init__()
# 
#     @classmethod
#     def registerColorScheme(cls):
#         key = cls.__name__.replace('ColorScheme', '').lower()
#         if key:
#             cls.__registry__[key] = cls
# 
#     @classmethod
#     def getColorScheme(cls, name, default=None):
#         return cls.__registry__.get(name, default)
# 
# def hex2rgb(hexstring, digits=2):
#     """Converts a hexstring color to a rgb tuple.
# 
#     Example: #ff0000 -> (1.0, 0.0, 0.0)
# 
#     digits is an integer number telling how many characters should be
#     interpreted for each component in the hexstring.
#     """
#     if isinstance(hexstring, (tuple, list)):
#         return hexstring
# 
#     top = float(int(digits * 'f', 16))
#     r = int(hexstring[1:digits+1], 16)
#     g = int(hexstring[digits+1:digits*2+1], 16)
#     b = int(hexstring[digits*2+1:digits*3+1], 16)
#     return r / top, g / top, b / top
# 
# DEFAULT_COLOR = '#3c581a'
# 
# Path: pycha/utils.py
# def safe_unicode(obj, encoding=None):
#     """Return a unicode value from the argument"""
#     if isinstance(obj, unicode):
#         return obj
#     elif isinstance(obj, str):
#         if encoding is None:
#             return unicode(obj)
#         else:
#             return unicode(obj, encoding)
#     else:
#         # it may be an int or a float
#         return unicode(obj)


# Path: pycha/chart.py
import copy
import inspect
import math
import cairo
from pycha.color import ColorScheme, hex2rgb, DEFAULT_COLOR
from pycha.utils import safe_unicode

            cx.move_to(-xb, -yb)
            cx.show_text(label)
            if self.debug:
                cx.rectangle(0, 0, width, height)
                cx.stroke()
        else:
            x = x - width / 2.0
            cx.move_to(x - xb, y - yb)
            cx.show_text(label)
            if self.debug:
                cx.rectangle(x, y, width, height)
                cx.stroke()
        cx.restore()

    def _renderYAxisLabel(self, cx, label_text):
        label = safe_unicode(label_text, self.options.encoding)
        x = self.layout.y_label.x
        y = self.layout.y_label.y + self.layout.y_label.h / 2.0
        self._renderAxisLabel(cx, label, x, y, True)

    def _renderYAxis(self, cx):
        """Draws the vertical line represeting the Y axis"""
        cx.new_path()
        cx.move_to(self.layout.chart.x, self.layout.chart.y)
        cx.line_to(self.layout.chart.x,
                   self.layout.chart.y + self.layout.chart.h)
        cx.close_path()
        cx.stroke()

    def _renderXAxisLabel(self, cx, label_text):

        label = safe_unicode(label_text, self.options.encoding)