Skip to content

Commit

Permalink
Merge pull request #1450 from CartoDB/fix/1442-update-legend-properties
Browse files Browse the repository at this point in the history
Update legend properties
  • Loading branch information
elenatorro committed Jan 9, 2020
2 parents 86a7e7e + c4173df commit 2a348f8
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions cartoframes/viz/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@

LEGEND_PROPERTIES = [
'color',
'stroke-color',
'stroke_color',
'size',
'stroke-width'
'stroke_width'
]

VIZ_PROPERTIES_MAP = {
'color': 'color',
'stroke-color': 'strokeColor',
'stroke_color': 'strokeColor',
'size': 'width',
'stroke-width': 'strokeWidth'
'stroke_width': 'strokeWidth'
}

LEGEND_TYPES = [
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/viz/legends/color_bins_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def color_bins_legend(title='', description='', footer='', prop='color',
Description in legend.
footer (str, optional):
Footer of legend. This is often used to attribute data sources.
prop (str, optional): Allowed properties are 'color' and 'stroke-color'.
prop (str, optional): Allowed properties are 'color' and 'stroke_color'.
It is 'color' by default.
variable (str, optional):
If the information in the legend depends on a different value than the
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/viz/legends/color_category_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def color_category_legend(title='', description='', footer='', prop='color',
Description in legend.
footer (str, optional):
Footer of legend. This is often used to attribute data sources.
prop (str, optional): Allowed properties are 'color' and 'stroke-color'.
prop (str, optional): Allowed properties are 'color' and 'stroke_color'.
It is 'color' by default.
variable (str, optional):
If the information in the legend depends on a different value than the
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/viz/legends/color_continuous_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def color_continuous_legend(title='', description='', footer='', prop='color',
Description in legend.
footer (str, optional):
Footer of legend. This is often used to attribute data sources.
prop (str, optional): Allowed properties are 'color' and 'stroke-color'.
prop (str, optional): Allowed properties are 'color' and 'stroke_color'.
It is 'color' by default.
variable (str, optional):
If the information in the legend depends on a different value than the
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/viz/legends/size_bins_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def size_bins_legend(title='', description='', footer='', prop='size',
Description in legend.
footer (str, optional):
Footer of legend. This is often used to attribute data sources.
prop (str, optional): Allowed properties are 'size' and 'stroke-width'.
prop (str, optional): Allowed properties are 'size' and 'stroke_width'.
It is 'size' by default.
variable (str, optional):
If the information in the legend depends on a different value than the
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/viz/legends/size_category_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def size_category_legend(title='', description='', footer='', prop='size',
Description in legend.
footer (str, optional):
Footer of legend. This is often used to attribute data sources.
prop (str, optional): Allowed properties are 'size' and 'stroke-width'.
prop (str, optional): Allowed properties are 'size' and 'stroke_width'.
It is 'size' by default.
variable (str, optional):
If the information in the legend depends on a different value than the
Expand Down
6 changes: 3 additions & 3 deletions docs/developers/migrations/rc1.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ Map(
Available properties for legends are changed to:

* "color" -> "color"
* "strokeColor" -> "stroke-color"
* "strokeColor" -> "stroke_color"
* "width" -> "size"
* "strokeWidth" -> "stroke-width"
* "strokeWidth" -> "stroke_width"

* From:

Expand All @@ -377,7 +377,7 @@ Map(
Layer(
'table_name',
style=color_category_style('column_name'),
legends=color_category_legend('color-bins', title='Legend Title', prop='stroke-color')
legends=color_category_legend('color-bins', title='Legend Title', prop='stroke_color')
)
)
```
Expand Down
2 changes: 1 addition & 1 deletion examples/legends/size_bins_legend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Size bins legend\n",
"\n",
"The `size-bins` type draws a classed legend based on point or line data using either the `size` (default) or `stroke-width` property of your visualization.\n",
"The `size-bins` type draws a classed legend based on point or line data using either the `size` (default) or `stroke_width` property of your visualization.\n",
"\n",
"To view available legend parameters, run `help(size_bins_legend)`\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/legends/size_category_legend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Size category legend\n",
"\n",
"The `size-category` type draws a legend based on categorical data and geometry type using either the `size` (default) or `stroke-width` property of your visualization.\n",
"The `size-category` type draws a legend based on categorical data and geometry type using either the `size` (default) or `stroke_width` property of your visualization.\n",
"\n",
"To view available legend parameters, run `help(size_category_legend)`\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/legends/size_continuous_legend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Size continuous legend\n",
"\n",
"The `size-continuous` type draws an unclassed legend based on your data's geometry using either the `size` (default) or `stroke-width` property of your visualization.\n",
"The `size-continuous` type draws an unclassed legend based on your data's geometry using either the `size` (default) or `stroke_width` property of your visualization.\n",
"\n",
"To view available legend parameters, run `help(size_continuous_legend)`\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions examples/legends/stroke_color_legend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"source": [
"# Use stroke color for legend\n",
"\n",
"For any color-based legend type, you can use either the `color` or `stroke-color` property of your visualization to draw legend items using the `prop` parameter.\n",
"For any color-based legend type, you can use either the `color` or `stroke_color` property of your visualization to draw legend items using the `prop` parameter.\n",
"\n",
"In this example, displaying the top 5 tree species in San Francisco, the legend is set to read from the `stroke-color` property."
"In this example, displaying the top 5 tree species in San Francisco, the legend is set to read from the `stroke_color` property."
]
},
{
Expand Down Expand Up @@ -958,7 +958,7 @@
" strokeWidth: 1.5\n",
" ''',\n",
" legends=color_category_legend(\n",
" prop='stroke-color',\n",
" prop='stroke_color',\n",
" title='Trees in San Francisco',\n",
" description='Top 5 species',\n",
" footer='Data: City of SF'\n",
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/viz/test_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ def test_is_legend_defined(self):
def test_legend_init_properties(self):
"""Legend should be properly initialized when passing properties"""
legend = Legend('color-category',
prop='stroke-color',
prop='stroke_color',
title='[title]',
description='[description]',
footer='[footer]',
dynamic=False)

assert legend._type == 'color-category'
assert legend._prop == 'stroke-color'
assert legend._prop == 'stroke_color'
assert legend._title == '[title]'
assert legend._description == '[description]'
assert legend._footer == '[footer]'
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_wrong_type(self):
def test_wrong_prop(self):
"""Legend should raise an error if legend prop is not valid"""
msg = 'Legend property "xxx" is not valid. Valid legend properties are: ' + \
'color, stroke-color, size, stroke-width.'
'color, stroke_color, size, stroke_width.'
with pytest.raises(ValueError) as e:
Legend('color-category', prop='xxx').get_info()
assert str(e.value) == msg

0 comments on commit 2a348f8

Please sign in to comment.