In this article we will teach you how to use query styles to provide advanced customization for your styling options.
Throughout this article we will be using the sample dataset Countries from Natural Earth (available here). You can use this dataset by using the 'Upload Dataset' feature of AmigoCloud. Here are some records of the Countries dataset:
In our examples we will be using the columns pop_est, economy, continent, region_un and name_len.
Initially the full dataset is rendered like this:
Note that we are using the default styling options and all records in our dataset are using the same options.
In order to use advanced Styling Options go to: 'Show Styling Options' -> 'Query' then click the + symbol to add a new filter.
For our first filter we will exemplify equality of field values, in particular let's focus on Asia and North America:
To use this filter click on the Save button and the new view of our dataset will be:
Let's now show the countries of America whose name's length is in the range of 5-7. This time the filter becomes "region_un='Americas' AND name_len > 4 AND name_len < 8", the result is:
Now let's highlight the countries of South America with an emerging economy and with a population of at least 10 million citizens. The filter for this is "economy LIKE '%Emerging region%' AND pop_est > 10000000 AND continent='South America'" and the result is:
Let's focus on the countries which contain photos of our trip. For this add a gallery column to the dataset (using AmigoCloud's schema editor) and add a few photos to countries of your interest. In this example we added photos to Brasil, Mexico and Russia. The filter now is more interesting as we need to consider the related table where the photos are stored: "amigo_id in ( select source_amigo_id from gallery_244 )", and the result is:
The gallery name ("gallery_244" in this case) is obtained by going to https://www.amigocloud.com/api/v1/users/<user_id>/projects/<project_id>/datasets/<dataset_id>/related_tables and looking for the value of the field 'table_name' corresponding to the appropriate column.
Finally, we will split the countries based on their area in km^2 using an (arbitrary) threshold of 1 million km^2, the filters used are:
And the end result becomes:
Important: Filters using related tables (such as our example using the photos) do not update when the related table is modified (eg: if you add a photo to another country the filter will not highlight the new country). This is a work in progress.