turbo-carto
Advanced tools
Comparing version 0.15.0 to 0.15.1
# Changelog | ||
## Version 0.15.1 | ||
Released 2016-07-20 | ||
- Fix category ramps: force equality filter on non numeric filters. | ||
## Version 0.15.0 | ||
@@ -4,0 +10,0 @@ Released 2016-07-19 |
{ | ||
"name": "turbo-carto", | ||
"version": "0.15.0", | ||
"version": "0.15.1", | ||
"description": "CartoCSS preprocessor", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
# Turbo-Carto | ||
Next-Gen Styling for Data-Driven Maps, AKA CartoCSS preprocessor | ||
Next-Gen Styling for Data-Driven Maps, AKA CartoCSS preprocessor. | ||
@@ -19,3 +19,3 @@ tl;dr Enables adding functions to CartoCSS that can be evaluated asynchronously. | ||
In CartoCSS you usually assign values to properties, and apply filters in order to change those values based on some | ||
In CartoCSS you usually assign values to properties and apply filters in order to change those values based on some | ||
data attributes. | ||
@@ -34,3 +34,3 @@ | ||
An example for a filter based on price attribute: | ||
An example of a filter based on price attribute: | ||
@@ -48,3 +48,3 @@ ```css | ||
Turbo-Carto high level API for ramps is as follows: | ||
Turbo-Carto high-level API for ramps is as follows: | ||
@@ -72,3 +72,3 @@ ```css | ||
In this case the first value is the default value. | ||
In this case, the first value is the default value. | ||
@@ -91,3 +91,3 @@ | ||
#selector { | ||
marker-width: ramp([room_type], (green, red), ("Private room"), =); | ||
marker-fill: ramp([room_type], (green, red), ("Private room"), =); | ||
} | ||
@@ -145,3 +145,3 @@ ``` | ||
For color ramps there are a couple of handy functions to retrieve color palettes: `cartocolor` and `colorbrewer`. | ||
For color ramps, there are a couple of handy functions to retrieve color palettes: `cartocolor` and `colorbrewer`. | ||
@@ -148,0 +148,0 @@ You can create a choropleth map using Reds color palette from colorbrewer (see [examples/readme/example-6.css](./examples/readme/example-6.css)): |
@@ -63,2 +63,6 @@ 'use strict'; | ||
return Number.isFinite(value) ? '[ ' + column + ' = ' + value + ' ]' : '[ ' + column + ' = "' + value + '" ]'; | ||
}), | ||
'=': createSplitStrategy(function exactSelector (column, value) { | ||
return Number.isFinite(value) ? '[ ' + column + ' = ' + value + ' ]' : '[ ' + column + ' = "' + value + '" ]'; | ||
}) | ||
@@ -65,0 +69,0 @@ }; |
@@ -16,3 +16,10 @@ 'use strict'; | ||
FiltersResult.prototype.getStrategy = function () { | ||
if (this.result.some(nonNumeric)) { | ||
return '='; | ||
} | ||
return this.strategy; | ||
}; | ||
function nonNumeric (item) { | ||
return !Number.isFinite(item); | ||
} |
@@ -14,3 +14,3 @@ 'use strict'; | ||
'#layer{', | ||
' marker-width: ramp([population], (10, 20, 30, 40), (_, Spain, Portugal, France), category);', | ||
' marker-width: ramp([population], (10, 20, 30, 40), (Spain, Portugal, France), category);', | ||
'}' | ||
@@ -20,11 +20,32 @@ ].join('\n'), | ||
'#layer{', | ||
' marker-width: 10;', | ||
' marker-width: 40;', | ||
' [ population = "Spain" ]{', | ||
' marker-width: 10', | ||
' }', | ||
' [ population = "Portugal" ]{', | ||
' marker-width: 20', | ||
' }', | ||
' [ population = "Portugal" ]{', | ||
' [ population = "France" ]{', | ||
' marker-width: 30', | ||
' }', | ||
'}' | ||
].join('\n') | ||
}, | ||
{ | ||
desc: 'will not use default value when exact number of values and filters is provided', | ||
cartocss: [ | ||
'#layer{', | ||
' marker-width: ramp([population], (10, 20, 30), (Spain, Portugal, France), category);', | ||
'}' | ||
].join('\n'), | ||
expectedCartocss: [ | ||
'#layer{', | ||
' [ population = "Spain" ]{', | ||
' marker-width: 10', | ||
' }', | ||
' [ population = "Portugal" ]{', | ||
' marker-width: 20', | ||
' }', | ||
' [ population = "France" ]{', | ||
' marker-width: 40', | ||
' marker-width: 30', | ||
' }', | ||
@@ -38,3 +59,3 @@ '}' | ||
'#layer{', | ||
' marker-width: ramp([population], (10, 20, 30, 40), (_, Spain, Portugal, France), category);', | ||
' marker-width: ramp([population], (10, 20, 30, 40), (Spain, Portugal, France), category);', | ||
'}' | ||
@@ -44,11 +65,11 @@ ].join('\n'), | ||
'#layer{', | ||
' marker-width: 10;', | ||
' marker-width: 40;', | ||
' [ population = "Spain" ]{', | ||
' marker-width: 20', | ||
' marker-width: 10', | ||
' }', | ||
' [ population = "Portugal" ]{', | ||
' marker-width: 30', | ||
' marker-width: 20', | ||
' }', | ||
' [ population = "France" ]{', | ||
' marker-width: 40', | ||
' marker-width: 30', | ||
' }', | ||
@@ -62,3 +83,3 @@ '}' | ||
'#layer{', | ||
' marker-width: ramp([population], (10, 20, 30, 40), (_, "Spain\'s", Portugal, France), category);', | ||
' marker-width: ramp([population], (10, 20, 30, 40), ("Spain\'s", Portugal, France), category);', | ||
'}' | ||
@@ -68,11 +89,11 @@ ].join('\n'), | ||
'#layer{', | ||
' marker-width: 10;', | ||
' marker-width: 40;', | ||
' [ population = "Spain\'s" ]{', | ||
' marker-width: 20', | ||
' marker-width: 10', | ||
' }', | ||
' [ population = "Portugal" ]{', | ||
' marker-width: 30', | ||
' marker-width: 20', | ||
' }', | ||
' [ population = "France" ]{', | ||
' marker-width: 40', | ||
' marker-width: 30', | ||
' }', | ||
@@ -167,2 +188,23 @@ '}' | ||
].join('\n') | ||
}, | ||
{ | ||
desc: 'should work with old string categories style', | ||
cartocss: [ | ||
'#layer{', | ||
' marker-width: ramp([population], (8, 24, 96), ("WADUS", "FOO", "BAR"));', | ||
'}' | ||
].join('\n'), | ||
expectedCartocss: [ | ||
'#layer{', | ||
' [ population = "WADUS" ]{', | ||
' marker-width: 8', | ||
' }', | ||
' [ population = "FOO" ]{', | ||
' marker-width: 24', | ||
' }', | ||
' [ population = "BAR" ]{', | ||
' marker-width: 96', | ||
' }', | ||
'}' | ||
].join('\n') | ||
} | ||
@@ -169,0 +211,0 @@ ]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93865
2389