How to use the cartoframes.viz.styles.utils.get_value function in cartoframes

To help you get started, we’ve selected a few cartoframes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CartoDB / cartoframes / cartoframes / viz / styles / color_category_style.py View on Github external
'strokeWidth': get_value(stroke_width, 'strokeWidth', 'point'),
              'filter': animation_filter
          },
          'line': {
              'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
                  func, value, cat or top,
                  serialize_palette(palette) or default_palette,
                  get_value(opacity, 1)),
              'width': get_value(size, 'width', 'line'),
              'filter': animation_filter
          },
          'polygon': {
              'color': 'opacity(ramp({0}(${1}, {2}), {3}), {4})'.format(
                  func, value, cat or top,
                  serialize_palette(palette) or default_palette,
                  get_value(opacity, 0.9)
              ),
              'strokeColor': get_value(stroke_color, 'strokeColor', 'polygon'),
              'strokeWidth': get_value(stroke_width, 'strokeWidth', 'polygon'),
              'filter': animation_filter
          }
    }

    return Style(data, 'color-category', value)
github CartoDB / cartoframes / cartoframes / viz / styles / color_bins_style.py View on Github external
'equal': 'purpor',
            'stdev': 'temps'
        }.get(method)
    else:
        func = 'buckets'
        default_palette = 'purpor'
        breaks = list(breaks)

    animation_filter = 'animation(linear(${}), 20, fade(1,1))'.format(animate) if animate else '1'

    data = {
        'point': {
            'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
                func, value, breaks or bins,
                serialize_palette(palette) or default_palette,
                get_value(opacity, 1)),
            'width': get_value(size, 'width', 'point'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'point'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'point'),
            'filter': animation_filter
        },
        'line': {
            'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
                func, value, breaks or bins,
                serialize_palette(palette) or default_palette,
                get_value(opacity, 1)),
            'width': get_value(size, 'width', 'line'),
            'filter': animation_filter
        },
        'polygon': {
            'color': 'opacity(ramp({0}(${1}, {2}), {3}), {4})'.format(
                func, value, breaks or bins,
github CartoDB / cartoframes / cartoframes / viz / styles / color_category_style.py View on Github external
},
          'line': {
              'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
                  func, value, cat or top,
                  serialize_palette(palette) or default_palette,
                  get_value(opacity, 1)),
              'width': get_value(size, 'width', 'line'),
              'filter': animation_filter
          },
          'polygon': {
              'color': 'opacity(ramp({0}(${1}, {2}), {3}), {4})'.format(
                  func, value, cat or top,
                  serialize_palette(palette) or default_palette,
                  get_value(opacity, 0.9)
              ),
              'strokeColor': get_value(stroke_color, 'strokeColor', 'polygon'),
              'strokeWidth': get_value(stroke_width, 'strokeWidth', 'polygon'),
              'filter': animation_filter
          }
    }

    return Style(data, 'color-category', value)
github CartoDB / cartoframes / cartoframes / viz / styles / basic_style.py View on Github external
data = {
        'point': {
            'color': get_value(color, 'color', 'point'),
            'width': get_value(size, 'width', 'point'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'point'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'point'),
            'filter': get_value(opacity, 1)
        },
        'line': {
            'color': get_value(color, 'color', 'line'),
            'width': get_value(size, 'width', 'line'),
            'filter': get_value(opacity, 1)
        },
        'polygon': {
            'color': get_value(color, 'color', 'polygon'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'polygon'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'polygon'),
            'filter': get_value(opacity, 0.9)
        }
    }

    return Style(data, 'default')
github CartoDB / cartoframes / cartoframes / viz / styles / color_bins_style.py View on Github external
'point': {
            'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
                func, value, breaks or bins,
                serialize_palette(palette) or default_palette,
                get_value(opacity, 1)),
            'width': get_value(size, 'width', 'point'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'point'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'point'),
            'filter': animation_filter
        },
        'line': {
            'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
                func, value, breaks or bins,
                serialize_palette(palette) or default_palette,
                get_value(opacity, 1)),
            'width': get_value(size, 'width', 'line'),
            'filter': animation_filter
        },
        'polygon': {
            'color': 'opacity(ramp({0}(${1}, {2}), {3}), {4})'.format(
                func, value, breaks or bins,
                serialize_palette(palette) or default_palette,
                get_value(opacity, 0.9)),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'polygon'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'polygon'),
            'filter': animation_filter
        }
    }

    return Style(data, 'color-bins', value)
github CartoDB / cartoframes / cartoframes / viz / styles / color_category_style.py View on Github external
'line': {
              'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
                  func, value, cat or top,
                  serialize_palette(palette) or default_palette,
                  get_value(opacity, 1)),
              'width': get_value(size, 'width', 'line'),
              'filter': animation_filter
          },
          'polygon': {
              'color': 'opacity(ramp({0}(${1}, {2}), {3}), {4})'.format(
                  func, value, cat or top,
                  serialize_palette(palette) or default_palette,
                  get_value(opacity, 0.9)
              ),
              'strokeColor': get_value(stroke_color, 'strokeColor', 'polygon'),
              'strokeWidth': get_value(stroke_width, 'strokeWidth', 'polygon'),
              'filter': animation_filter
          }
    }

    return Style(data, 'color-category', value)
github CartoDB / cartoframes / cartoframes / viz / styles / animation_style.py View on Github external
get_value(opacity, 1)),
            'width': get_value(size, 'width', 'point'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'point'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'point'),
            'filter': _animation_filter(value, duration, fade)
        },
        'line': {
            'color': 'opacity({0}, {1})'.format(
                get_value(color, 'color', 'line'),
                get_value(opacity, 1)),
            'width': get_value(size, 'width', 'line'),
            'filter': _animation_filter(value, duration, fade)
        },
        'polygon': {
            'color': 'opacity({0}, {1})'.format(
                get_value(color, 'color', 'polygon'),
                get_value(opacity, 0.8)),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'polygon'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'polygon'),
            'filter': _animation_filter(value, duration, fade)
        }
    }

    return Style(data, 'animation', value)
github CartoDB / cartoframes / cartoframes / viz / styles / basic_style.py View on Github external
data = {
        'point': {
            'color': get_value(color, 'color', 'point'),
            'width': get_value(size, 'width', 'point'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'point'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'point'),
            'filter': get_value(opacity, 1)
        },
        'line': {
            'color': get_value(color, 'color', 'line'),
            'width': get_value(size, 'width', 'line'),
            'filter': get_value(opacity, 1)
        },
        'polygon': {
            'color': get_value(color, 'color', 'polygon'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'polygon'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'polygon'),
            'filter': get_value(opacity, 0.9)
        }
    }

    return Style(data, 'default')
github CartoDB / cartoframes / cartoframes / viz / styles / basic_style.py View on Github external
'color': get_value(color, 'color', 'point'),
            'width': get_value(size, 'width', 'point'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'point'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'point'),
            'filter': get_value(opacity, 1)
        },
        'line': {
            'color': get_value(color, 'color', 'line'),
            'width': get_value(size, 'width', 'line'),
            'filter': get_value(opacity, 1)
        },
        'polygon': {
            'color': get_value(color, 'color', 'polygon'),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'polygon'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'polygon'),
            'filter': get_value(opacity, 0.9)
        }
    }

    return Style(data, 'default')
github CartoDB / cartoframes / cartoframes / viz / styles / cluster_size_style.py View on Github external
Returns:
        :py:class:`Style `
    """

    cluster_operation = _get_cluster_operation(operation, value)
    cluster_operation_title = _get_cluster_operation_title(operation, value)
    breakpoints = _get_breakpoints(resolution)
    animation_filter = _get_animation(animate, cluster_operation)

    data = {
        'point': {
            'width': 'ramp(linear({0}, viewportMIN({0}), viewportMAX({0})), [{1}])'.format(
                cluster_operation, breakpoints),
            'color': 'opacity({0}, {1})'.format(
                color or '#FFB927', get_value(opacity, 0.8)),
            'strokeColor': get_value(stroke_color, 'strokeColor', 'point'),
            'strokeWidth': get_value(stroke_width, 'strokeWidth', 'point'),
            'filter': animation_filter,
            'resolution': '{0}'.format(resolution)
        }
    }

    popups = {
        'hover': get_popup(True, alt_title=cluster_operation_title, alt_value=cluster_operation, operation=True)
    }

    return Style(data, 'cluster-size', value, popups)