-1

When I import my data into CartoDB and add a filter, it automatically detects the filter range/intervals.

For example, take sales data.

I can filter sales from $72.6M to $1.1B, $167M to $1.1B, $261M to $1.1B, etc., but I can't define a filter that is not exactly those dollars. CartoDB automatically chooses the filer range and I can't change it. I can't do $50M-$75M, for example.

How can I create a custom filter based on values that I define?

1

CartoDB create choropleth maps scales by using some statistics -- you can choose the method: jenks/equal interval...

If none of them suits your case and you want to specify ranges by yourself, then you will need to edit manually the CartoCSS code and the legends of your map.

First, go to the CartoCSS tab and make the changes in the filters so that your new scales are taken into account.

Here, if you already have a Choropleth map set up, you will see some filters such as:

#table_1_0_month [ mag <= 6.8] {
   marker-fill: ...
}
#table_1_0_month [ mag <= 6.7] {
   marker-fill: ...
}
#table_1_0_month [ mag <= 6.566666666666666] {
   marker-fill: 
}

Which you can read as: In the layer table_1_0_month, filter the data whose mag column value is smaller or equal than 6.8 and apply this specific style.

So you can change the amount as you need:

#table_1_0_month [ mag <= 10] {
   marker-fill: ...
}
#table_1_0_month [ mag <= 5] {
   marker-fill: ...
}
#table_1_0_month [ mag <= 1] {
   marker-fill: 
}

Then, in Legends you might want to update the labels for the max and min values of your range.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.