Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'filter': animation_filter
},
'line': {
'color': 'opacity(ramp(linear(${0}, {1}, {2}), {3}), {4})'.format(
value, range_min, range_max,
serialize_palette(palette) or default_palette,
get_value(opacity, 'line', 'opacity')
),
'width': get_value(size, 'line', 'width'),
'filter': animation_filter
},
'polygon': {
'color': 'opacity(ramp(linear(${0}, {1}, {2}), {3}), {4})'.format(
value, range_min, range_max,
serialize_palette(palette) or default_palette,
get_value(opacity, 'polygon', 'opacity')
),
'strokeColor': get_value(stroke_color, 'polygon', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'polygon', 'strokeWidth'),
'filter': animation_filter
}
},
popup=popup and not animate and get_popup(
popup, title, value, value),
legend=legend and {
'type': {
'point': 'color-continuous-point',
'line': 'color-continuous-line',
'polygon': 'color-continuous-polygon'
},
'title': title or value,
'description': description,
'point': {
'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
func, value, breaks or bins,
serialize_palette(palette) or default_palette,
get_value(opacity, 'point', 'opacity')
),
'width': get_value(size, 'point', 'width'),
'strokeColor': get_value(stroke_color, 'point', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'point', 'strokeWidth'),
'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, 'line', 'opacity')
),
'width': get_value(size, 'line', 'width'),
'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, 'polygon', 'opacity')
),
'strokeColor': get_value(stroke_color, 'polygon', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'polygon', 'strokeWidth'),
'filter': animation_filter
}
},
popup=popup and not animate and get_popup(
Returns:
cartoframes.viz.Layer: Layer styled by `value`. Includes Widget `value`.
"""
if opacity is None:
opacity = '0.8'
return Layer(
source,
style={
'point': {
'width': get_value(size, 'point', 'width'),
'color': 'opacity({0}, {1})'.format(
color or '#EE4D5A', opacity),
'strokeColor': get_value(stroke_color, 'point', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'point', 'strokeWidth'),
'filter': 'animation(linear(${0}), {1}, fade{2})'.format(
value, duration or 20, fade or '(1, 1)')
},
'line': {
'width': get_value(size, 'line', 'width'),
'color': 'opacity({0}, {1})'.format(
color or '#4CC8A3', opacity),
'filter': 'animation(linear(${0}), {1}, fade{2})'.format(
value, duration or 20, fade or '(1, 1)')
},
'polygon': {
'color': get_value(color, 'polygon', 'color'),
'strokeColor': get_value(stroke_color, 'polygon', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'polygon', 'strokeWidth'),
'filter': 'animation(linear(${0}), {1}, fade{2})'.format(
'line': {
'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
func, value, breaks or bins,
serialize_palette(palette) or default_palette,
get_value(opacity, 'line', 'opacity')
),
'width': get_value(size, 'line', 'width'),
'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, 'polygon', 'opacity')
),
'strokeColor': get_value(stroke_color, 'polygon', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'polygon', 'strokeWidth'),
'filter': animation_filter
}
},
popup=popup and not animate and get_popup(
popup, title, value, value),
legend=legend and {
'type': {
'point': 'color-bins-point',
'line': 'color-bins-line',
'polygon': 'color-bins-polygon'
},
'title': title or value,
'description': description,
'footer': footer
},
When a :py:class:`Source ` is passed as source,
these credentials is simply ignored. If not provided the credentials will be
automatically obtained from the default credentials.
Returns:
cartoframes.viz.Layer: Layer styled by `value`. Includes Widget `value`.
"""
if opacity is None:
opacity = '0.8'
return Layer(
source,
style={
'point': {
'width': get_value(size, 'point', 'width'),
'color': 'opacity({0}, {1})'.format(
color or '#EE4D5A', opacity),
'strokeColor': get_value(stroke_color, 'point', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'point', 'strokeWidth'),
'filter': 'animation(linear(${0}), {1}, fade{2})'.format(
value, duration or 20, fade or '(1, 1)')
},
'line': {
'width': get_value(size, 'line', 'width'),
'color': 'opacity({0}, {1})'.format(
color or '#4CC8A3', opacity),
'filter': 'animation(linear(${0}), {1}, fade{2})'.format(
value, duration or 20, fade or '(1, 1)')
},
'polygon': {
'color': get_value(color, 'polygon', 'color'),
'color': 'opacity({0}, {1})'.format(
color or '#EE4D5A', opacity),
'strokeColor': get_value(stroke_color, 'point', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'point', 'strokeWidth'),
'filter': 'animation(linear(${0}), {1}, fade{2})'.format(
value, duration or 20, fade or '(1, 1)')
},
'line': {
'width': get_value(size, 'line', 'width'),
'color': 'opacity({0}, {1})'.format(
color or '#4CC8A3', opacity),
'filter': 'animation(linear(${0}), {1}, fade{2})'.format(
value, duration or 20, fade or '(1, 1)')
},
'polygon': {
'color': get_value(color, 'polygon', 'color'),
'strokeColor': get_value(stroke_color, 'polygon', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'polygon', 'strokeWidth'),
'filter': 'animation(linear(${0}), {1}, fade{2})'.format(
value, duration or 20, fade or '(1, 1)')
}
},
widgets=[{
'type': widget_type,
'value': value,
'title': title,
'description': description
}],
credentials=credentials
)
Includes a legend, popup and widget on `value`.
"""
func = 'buckets' if cat else 'top'
default_palette = 'bold'
animation_filter = 'animation(linear(${}), 20, fade(1,1))'.format(animate) if animate else '1'
return Layer(
source,
style={
'point': {
'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
func, value, cat or top,
serialize_palette(palette) or default_palette,
get_value(opacity, 'point', 'opacity')
),
'width': get_value(size, 'point', 'width'),
'strokeColor': get_value(stroke_color, 'point', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'point', 'strokeWidth'),
'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, 'line', 'opacity')
),
'width': get_value(size, 'line', 'width'),
'filter': animation_filter
},
'polygon': {
'color': 'opacity(ramp({0}(${1}, {2}), {3}), {4})'.format(
func, value, cat or top,
'line': {
'color': 'opacity(ramp({0}(${1}, {2}), {3}),{4})'.format(
func, value, cat or top,
serialize_palette(palette) or default_palette,
get_value(opacity, 'line', 'opacity')
),
'width': get_value(size, 'line', 'width'),
'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, 'polygon', 'opacity')
),
'strokeColor': get_value(stroke_color, 'polygon', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'polygon', 'strokeWidth'),
'filter': animation_filter
}
},
popup=popup and not animate and get_popup(
popup, title, value, value),
legend=legend and {
'type': {
'point': 'color-category-point',
'line': 'color-category-line',
'polygon': 'color-category-polygon'
},
'title': title or value,
'description': description,
'footer': footer
},
animation_filter = 'animation(linear(${}), 20, fade(1,1))'.format(animate) if animate else '1'
if range_min is None:
range_min = 'globalMIN(${0})'.format(value)
if range_max is None:
range_max = 'globalMAX(${0})'.format(value)
return Layer(
source,
style={
'point': {
'color': 'opacity(ramp(linear(${0}, {1}, {2}), {3}), {4})'.format(
value, range_min, range_max,
serialize_palette(palette) or default_palette,
get_value(opacity, 'point', 'opacity')
),
'width': get_value(size, 'point', 'width'),
'strokeColor': get_value(stroke_color, 'point', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'point', 'strokeWidth'),
'filter': animation_filter
},
'line': {
'color': 'opacity(ramp(linear(${0}, {1}, {2}), {3}), {4})'.format(
value, range_min, range_max,
serialize_palette(palette) or default_palette,
get_value(opacity, 'line', 'opacity')
),
'width': get_value(size, 'line', 'width'),
'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, 'line', 'opacity')
),
'width': get_value(size, 'line', 'width'),
'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, 'polygon', 'opacity')
),
'strokeColor': get_value(stroke_color, 'polygon', 'strokeColor'),
'strokeWidth': get_value(stroke_width, 'polygon', 'strokeWidth'),
'filter': animation_filter
}
},
popup=popup and not animate and get_popup(
popup, title, value, value),
legend=legend and {
'type': {
'point': 'color-category-point',
'line': 'color-category-line',
'polygon': 'color-category-polygon'
},
'title': title or value,
'description': description,
'footer': footer
},
widgets=[