def cm_values_to_js(values, cm_name):
    """
    Take an array of values of the form (x, (r, g, b)), and return the
    corresponding JavaScript variable with the correct name.
    """

    dummy = ['[{x:.3f}, [{r:.3f}, {g:.3f}, {b:.3f}]]'.format(x=value[0],
                                                             r=value[1][0],
                                                             g=value[1][1],
                                                             b=value[1][2])
             for value in values]
    cm_values = ', '.join(dummy)

    return 'var {cm_name} = [{cm_values}];'.format(cm_name=cm_name,
                                                   cm_values=cm_values)